Use EntityFeature enum in components (v**) (#69465)
* Use EntityFeature enum in vallox * Use EntityFeature enum in velbus * Use EntityFeature enum in velux * Use EntityFeature enum in venstar * Use EntityFeature enum in vera * Use EntityFeature enum in verisure * Use EntityFeature enum in vesync * Use EntityFeature enum in vicare * Use EntityFeature enum in vivotek * Use EntityFeature enum in vizio * Use EntityFeature enum in vlc * Use EntityFeature enum in vlc_telnet * Use EntityFeature enum in volumiopull/69534/head
parent
10a1b1f734
commit
f194f7809b
|
@ -9,8 +9,8 @@ from vallox_websocket_api import Vallox
|
|||
from vallox_websocket_api.exceptions import ValloxApiException
|
||||
|
||||
from homeassistant.components.fan import (
|
||||
SUPPORT_PRESET_MODE,
|
||||
FanEntity,
|
||||
FanEntityFeature,
|
||||
NotValidPresetModeError,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -83,6 +83,8 @@ async def async_setup_entry(
|
|||
class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
|
||||
"""Representation of the fan."""
|
||||
|
||||
_attr_supported_features = FanEntityFeature.PRESET_MODE
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
|
@ -98,11 +100,6 @@ class ValloxFan(CoordinatorEntity[ValloxDataUpdateCoordinator], FanEntity):
|
|||
|
||||
self._attr_unique_id = str(self.coordinator.data.get_uuid())
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_PRESET_MODE
|
||||
|
||||
@property
|
||||
def preset_modes(self) -> list[str]:
|
||||
"""Return a list of available preset modes."""
|
||||
|
|
|
@ -5,12 +5,8 @@ from typing import Any
|
|||
|
||||
from velbusaio.channels import Temperature as VelbusTemp
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_HEAT,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import HVAC_MODE_HEAT
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -38,7 +34,9 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
|
|||
"""Representation of a Velbus thermostat."""
|
||||
|
||||
_channel: VelbusTemp
|
||||
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
_attr_temperature_unit = TEMP_CELSIUS
|
||||
_attr_hvac_mode = HVAC_MODE_HEAT
|
||||
_attr_hvac_modes = [HVAC_MODE_HEAT]
|
||||
|
|
|
@ -7,11 +7,8 @@ from velbusaio.channels import Blind as VelbusBlind
|
|||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_STOP,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -45,10 +42,17 @@ class VelbusCover(VelbusEntity, CoverEntity):
|
|||
super().__init__(channel)
|
||||
if self._channel.support_position():
|
||||
self._attr_supported_features = (
|
||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.STOP
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
else:
|
||||
self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.STOP
|
||||
)
|
||||
|
||||
@property
|
||||
def is_closed(self) -> bool | None:
|
||||
|
|
|
@ -7,16 +7,9 @@ from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter,
|
|||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_CLOSE_TILT,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_OPEN_TILT,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_SET_TILT_POSITION,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_STOP_TILT,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -46,14 +39,17 @@ class VeluxCover(VeluxEntity, CoverEntity):
|
|||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
supported_features = (
|
||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION | SUPPORT_STOP
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
| CoverEntityFeature.STOP
|
||||
)
|
||||
if self.current_cover_tilt_position is not None:
|
||||
supported_features |= (
|
||||
SUPPORT_OPEN_TILT
|
||||
| SUPPORT_CLOSE_TILT
|
||||
| SUPPORT_SET_TILT_POSITION
|
||||
| SUPPORT_STOP_TILT
|
||||
CoverEntityFeature.OPEN_TILT
|
||||
| CoverEntityFeature.CLOSE_TILT
|
||||
| CoverEntityFeature.SET_TILT_POSITION
|
||||
| CoverEntityFeature.STOP_TILT
|
||||
)
|
||||
return supported_features
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@ from __future__ import annotations
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
||||
from homeassistant.components.climate import (
|
||||
PLATFORM_SCHEMA,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_HVAC_MODE,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
|
@ -20,11 +24,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_OFF,
|
||||
PRESET_AWAY,
|
||||
PRESET_NONE,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_HUMIDITY,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -134,13 +133,17 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_PRESET_MODE
|
||||
features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
if self._client.mode == self._client.MODE_AUTO:
|
||||
features |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
|
||||
if self._client.hum_setpoint is not None:
|
||||
features |= SUPPORT_TARGET_HUMIDITY
|
||||
features |= ClimateEntityFeature.TARGET_HUMIDITY
|
||||
|
||||
return features
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@ from typing import Any
|
|||
|
||||
import pyvera as veraApi
|
||||
|
||||
from homeassistant.components.climate import ENTITY_ID_FORMAT, ClimateEntity
|
||||
from homeassistant.components.climate import (
|
||||
ENTITY_ID_FORMAT,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate.const import (
|
||||
FAN_AUTO,
|
||||
FAN_ON,
|
||||
|
@ -13,8 +17,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -31,7 +33,6 @@ from .common import ControllerData, get_controller_data
|
|||
|
||||
FAN_OPERATION_LIST = [FAN_ON, FAN_AUTO]
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
|
||||
SUPPORT_HVAC = [HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF]
|
||||
|
||||
|
||||
|
@ -54,6 +55,10 @@ async def async_setup_entry(
|
|||
class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
|
||||
"""Representation of a Vera Thermostat."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self, vera_device: veraApi.VeraThermostat, controller_data: ControllerData
|
||||
) -> None:
|
||||
|
@ -61,11 +66,6 @@ class VeraThermostat(VeraDevice[veraApi.VeraThermostat], ClimateEntity):
|
|||
VeraDevice.__init__(self, vera_device, controller_data)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> str:
|
||||
"""Return hvac operation ie. heat, cool mode.
|
||||
|
|
|
@ -6,10 +6,7 @@ import asyncio
|
|||
from homeassistant.components.alarm_control_panel import (
|
||||
FORMAT_NUMBER,
|
||||
AlarmControlPanelEntity,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -37,7 +34,10 @@ class VerisureAlarm(
|
|||
|
||||
_attr_code_format = FORMAT_NUMBER
|
||||
_attr_name = "Verisure Alarm"
|
||||
_attr_supported_features = SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import logging
|
||||
import math
|
||||
|
||||
from homeassistant.components.fan import SUPPORT_SET_SPEED, FanEntity
|
||||
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -83,16 +83,13 @@ def _setup_entities(devices, async_add_entities):
|
|||
class VeSyncFanHA(VeSyncDevice, FanEntity):
|
||||
"""Representation of a VeSync fan."""
|
||||
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
def __init__(self, fan):
|
||||
"""Initialize the VeSync fan device."""
|
||||
super().__init__(fan)
|
||||
self.smartfan = fan
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_SET_SPEED
|
||||
|
||||
@property
|
||||
def percentage(self):
|
||||
"""Return the current speed."""
|
||||
|
|
|
@ -10,7 +10,7 @@ from PyViCare.PyViCareUtils import (
|
|||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
|
@ -20,8 +20,6 @@ from homeassistant.components.climate.const import (
|
|||
PRESET_COMFORT,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -72,8 +70,6 @@ VICARE_HOLD_MODE_OFF = "off"
|
|||
VICARE_TEMP_HEATING_MIN = 3
|
||||
VICARE_TEMP_HEATING_MAX = 37
|
||||
|
||||
SUPPORT_FLAGS_HEATING = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
VICARE_TO_HA_HVAC_HEATING = {
|
||||
VICARE_MODE_DHW: HVAC_MODE_OFF,
|
||||
VICARE_MODE_HEATING: HVAC_MODE_HEAT,
|
||||
|
@ -151,6 +147,10 @@ async def async_setup_entry(
|
|||
class ViCareClimate(ClimateEntity):
|
||||
"""Representation of the ViCare heating climate device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
def __init__(self, name, api, circuit, device_config, heating_type):
|
||||
"""Initialize the climate device."""
|
||||
self._name = name
|
||||
|
@ -249,11 +249,6 @@ class ViCareClimate(ClimateEntity):
|
|||
except PyViCareInvalidDataError as invalid_data_exception:
|
||||
_LOGGER.error("Invalid data from Vicare server: %s", invalid_data_exception)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS_HEATING
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the climate device."""
|
||||
|
|
|
@ -10,8 +10,8 @@ from PyViCare.PyViCareUtils import (
|
|||
import requests
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
WaterHeaterEntity,
|
||||
WaterHeaterEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -45,8 +45,6 @@ VICARE_TEMP_WATER_MAX = 60
|
|||
OPERATION_MODE_ON = "on"
|
||||
OPERATION_MODE_OFF = "off"
|
||||
|
||||
SUPPORT_FLAGS_HEATER = SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
VICARE_TO_HA_HVAC_DHW = {
|
||||
VICARE_MODE_DHW: OPERATION_MODE_ON,
|
||||
VICARE_MODE_DHWANDHEATING: OPERATION_MODE_ON,
|
||||
|
@ -101,6 +99,8 @@ async def async_setup_entry(
|
|||
class ViCareWater(WaterHeaterEntity):
|
||||
"""Representation of the ViCare domestic hot water device."""
|
||||
|
||||
_attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def __init__(self, name, api, circuit, device_config, heating_type):
|
||||
"""Initialize the DHW water_heater device."""
|
||||
self._name = name
|
||||
|
@ -155,11 +155,6 @@ class ViCareWater(WaterHeaterEntity):
|
|||
"configuration_url": "https://developer.viessmann.com/",
|
||||
}
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS_HEATER
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the water_heater device."""
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from libpyvivotek import VivotekCamera
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_STREAM, Camera
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera, CameraEntityFeature
|
||||
from homeassistant.const import (
|
||||
CONF_AUTHENTICATION,
|
||||
CONF_IP_ADDRESS,
|
||||
|
@ -76,6 +76,8 @@ def setup_platform(
|
|||
class VivotekCam(Camera):
|
||||
"""A Vivotek IP camera."""
|
||||
|
||||
_attr_supported_features = CameraEntityFeature.STREAM
|
||||
|
||||
def __init__(self, config, cam, stream_source):
|
||||
"""Initialize a Vivotek camera."""
|
||||
super().__init__()
|
||||
|
@ -87,11 +89,6 @@ class VivotekCam(Camera):
|
|||
self._name = config[CONF_NAME]
|
||||
self._stream_source = stream_source
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return supported features for this camera."""
|
||||
return SUPPORT_STREAM
|
||||
|
||||
@property
|
||||
def frame_interval(self):
|
||||
"""Return the interval between frames of the mjpeg stream."""
|
||||
|
|
|
@ -10,9 +10,9 @@ from pyvizio.api.apps import find_app_name
|
|||
from pyvizio.const import APP_HOME, INPUT_APPS, NO_APP_RUNNING, UNKNOWN_APP
|
||||
|
||||
from homeassistant.components.media_player import (
|
||||
SUPPORT_SELECT_SOUND_MODE,
|
||||
MediaPlayerDeviceClass,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -229,7 +229,9 @@ class VizioDevice(MediaPlayerEntity):
|
|||
self._attr_is_volume_muted = None
|
||||
|
||||
if VIZIO_SOUND_MODE in audio_settings:
|
||||
self._attr_supported_features |= SUPPORT_SELECT_SOUND_MODE
|
||||
self._attr_supported_features |= (
|
||||
MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
)
|
||||
self._attr_sound_mode = audio_settings[VIZIO_SOUND_MODE]
|
||||
if not self._attr_sound_mode_list:
|
||||
self._attr_sound_mode_list = await self._device.get_setting_options(
|
||||
|
@ -238,8 +240,10 @@ class VizioDevice(MediaPlayerEntity):
|
|||
log_api_exception=False,
|
||||
)
|
||||
else:
|
||||
# Explicitly remove SUPPORT_SELECT_SOUND_MODE from supported features
|
||||
self._attr_supported_features &= ~SUPPORT_SELECT_SOUND_MODE
|
||||
# Explicitly remove MediaPlayerEntityFeature.SELECT_SOUND_MODE from supported features
|
||||
self._attr_supported_features &= (
|
||||
~MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
)
|
||||
|
||||
if input_ := await self._device.get_current_input(log_api_exception=False):
|
||||
self._current_input = input_
|
||||
|
|
|
@ -6,16 +6,12 @@ import logging
|
|||
import vlc
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -28,15 +24,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
CONF_ARGUMENTS = "arguments"
|
||||
DEFAULT_NAME = "Vlc"
|
||||
|
||||
SUPPORT_VLC = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_STOP
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(CONF_ARGUMENTS, default=""): cv.string,
|
||||
|
@ -60,6 +47,15 @@ def setup_platform(
|
|||
class VlcDevice(MediaPlayerEntity):
|
||||
"""Representation of a vlc player."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
)
|
||||
|
||||
def __init__(self, name, arguments):
|
||||
"""Initialize the vlc device."""
|
||||
self._instance = vlc.Instance(arguments)
|
||||
|
@ -112,11 +108,6 @@ class VlcDevice(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._muted
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_VLC
|
||||
|
||||
@property
|
||||
def media_content_type(self):
|
||||
"""Content type of current playing media."""
|
||||
|
|
|
@ -14,23 +14,10 @@ from homeassistant.components import media_source
|
|||
from homeassistant.components.media_player import (
|
||||
BrowseMedia,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
async_process_play_media_url,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_CLEAR_PLAYLIST,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_SHUFFLE_SET,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||
from homeassistant.config_entries import SOURCE_HASSIO, ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -44,21 +31,6 @@ from .const import DATA_AVAILABLE, DATA_VLC, DEFAULT_NAME, DOMAIN, LOGGER
|
|||
|
||||
MAX_VOLUME = 500
|
||||
|
||||
SUPPORT_VLC = (
|
||||
SUPPORT_CLEAR_PLAYLIST
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_SHUFFLE_SET
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
)
|
||||
|
||||
_T = TypeVar("_T", bound="VlcDevice")
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
|
@ -99,6 +71,21 @@ def catch_vlc_errors(
|
|||
class VlcDevice(MediaPlayerEntity):
|
||||
"""Representation of a vlc player."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.SEEK
|
||||
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self, config_entry: ConfigEntry, vlc: Client, name: str, available: bool
|
||||
) -> None:
|
||||
|
@ -214,11 +201,6 @@ class VlcDevice(MediaPlayerEntity):
|
|||
"""Boolean if volume is currently muted."""
|
||||
return self._muted
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_VLC
|
||||
|
||||
@property
|
||||
def media_content_type(self) -> str:
|
||||
"""Content type of current playing media."""
|
||||
|
|
|
@ -6,26 +6,14 @@ Volumio rest API: https://volumio.github.io/docs/API/REST_API.html
|
|||
from datetime import timedelta
|
||||
import json
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
REPEAT_MODE_ALL,
|
||||
REPEAT_MODE_OFF,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_CLEAR_PLAYLIST,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_REPEAT_SET,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_SHUFFLE_SET,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -43,24 +31,6 @@ from homeassistant.util import Throttle
|
|||
from .browse_media import browse_node, browse_top_level
|
||||
from .const import DATA_INFO, DATA_VOLUMIO, DOMAIN
|
||||
|
||||
SUPPORT_VOLUMIO = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_REPEAT_SET
|
||||
| SUPPORT_SHUFFLE_SET
|
||||
| SUPPORT_CLEAR_PLAYLIST
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
)
|
||||
|
||||
PLAYLIST_UPDATE_INTERVAL = timedelta(seconds=15)
|
||||
|
||||
|
||||
|
@ -84,6 +54,24 @@ async def async_setup_entry(
|
|||
class Volumio(MediaPlayerEntity):
|
||||
"""Volumio Player Object."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.SEEK
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.REPEAT_SET
|
||||
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
def __init__(self, volumio, uid, name, info):
|
||||
"""Initialize the media player."""
|
||||
self._volumio = volumio
|
||||
|
@ -203,11 +191,6 @@ class Volumio(MediaPlayerEntity):
|
|||
"""Name of the current input source."""
|
||||
return self._currentplaylist
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag of media commands that are supported."""
|
||||
return SUPPORT_VOLUMIO
|
||||
|
||||
async def async_media_next_track(self):
|
||||
"""Send media_next command to media player."""
|
||||
await self._volumio.next()
|
||||
|
|
Loading…
Reference in New Issue