mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Use EntityFeature enum in components (d**) (#69358)
This commit is contained in:
parent
9e2198fa47
commit
c8df2656b1
@ -5,7 +5,11 @@ import logging
|
||||
|
||||
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_FAN_MODE,
|
||||
ATTR_HVAC_MODE,
|
||||
@ -25,10 +29,6 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_BOOST,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_SWING_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, TEMP_CELSIUS
|
||||
@ -130,19 +130,19 @@ class DaikinClimate(ClimateEntity):
|
||||
ATTR_SWING_MODE: self._api.device.swing_modes,
|
||||
}
|
||||
|
||||
self._supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
if (
|
||||
self._api.device.support_away_mode
|
||||
or self._api.device.support_advanced_modes
|
||||
):
|
||||
self._supported_features |= SUPPORT_PRESET_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
if self._api.device.support_fan_rate:
|
||||
self._supported_features |= SUPPORT_FAN_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||
|
||||
if self._api.device.support_swing_mode:
|
||||
self._supported_features |= SUPPORT_SWING_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
|
||||
|
||||
async def _set(self, settings):
|
||||
"""Set device settings using API."""
|
||||
@ -172,11 +172,6 @@ class DaikinClimate(ClimateEntity):
|
||||
if values:
|
||||
await self._api.device.set(values)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return self._supported_features
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the thermostat, if any."""
|
||||
|
@ -19,10 +19,8 @@ from pydeconz.sensor import (
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
DOMAIN,
|
||||
FORMAT_NUMBER,
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -124,7 +122,9 @@ class DeconzAlarmControlPanel(DeconzDevice, AlarmControlPanelEntity):
|
||||
|
||||
_attr_code_format = FORMAT_NUMBER
|
||||
_attr_supported_features = (
|
||||
SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_NIGHT
|
||||
AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||
)
|
||||
|
||||
def __init__(
|
||||
|
@ -25,7 +25,7 @@ from pydeconz.sensor import (
|
||||
Thermostat,
|
||||
)
|
||||
|
||||
from homeassistant.components.climate import DOMAIN, ClimateEntity
|
||||
from homeassistant.components.climate import DOMAIN, ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
FAN_AUTO,
|
||||
FAN_HIGH,
|
||||
@ -40,9 +40,6 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_BOOST,
|
||||
PRESET_COMFORT,
|
||||
PRESET_ECO,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
@ -162,13 +159,13 @@ class DeconzThermostat(DeconzDevice, ClimateEntity):
|
||||
value: key for key, value in self._hvac_mode_to_deconz.items()
|
||||
}
|
||||
|
||||
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
if device.fan_mode:
|
||||
self._attr_supported_features |= SUPPORT_FAN_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||
|
||||
if device.preset:
|
||||
self._attr_supported_features |= SUPPORT_PRESET_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
# Fan control
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Support for deCONZ covers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, cast
|
||||
@ -10,16 +9,9 @@ from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
DOMAIN,
|
||||
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.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -84,16 +76,16 @@ class DeconzCover(DeconzDevice, CoverEntity):
|
||||
"""Set up cover device."""
|
||||
super().__init__(device, gateway)
|
||||
|
||||
self._attr_supported_features = SUPPORT_OPEN
|
||||
self._attr_supported_features |= SUPPORT_CLOSE
|
||||
self._attr_supported_features |= SUPPORT_STOP
|
||||
self._attr_supported_features |= SUPPORT_SET_POSITION
|
||||
self._attr_supported_features = CoverEntityFeature.OPEN
|
||||
self._attr_supported_features |= CoverEntityFeature.CLOSE
|
||||
self._attr_supported_features |= CoverEntityFeature.STOP
|
||||
self._attr_supported_features |= CoverEntityFeature.SET_POSITION
|
||||
|
||||
if self._device.tilt is not None:
|
||||
self._attr_supported_features |= SUPPORT_OPEN_TILT
|
||||
self._attr_supported_features |= SUPPORT_CLOSE_TILT
|
||||
self._attr_supported_features |= SUPPORT_STOP_TILT
|
||||
self._attr_supported_features |= SUPPORT_SET_TILT_POSITION
|
||||
self._attr_supported_features |= CoverEntityFeature.OPEN_TILT
|
||||
self._attr_supported_features |= CoverEntityFeature.CLOSE_TILT
|
||||
self._attr_supported_features |= CoverEntityFeature.STOP_TILT
|
||||
self._attr_supported_features |= CoverEntityFeature.SET_TILT_POSITION
|
||||
|
||||
self._attr_device_class = DEVICE_CLASS.get(self._device.type)
|
||||
|
||||
|
@ -12,7 +12,7 @@ from pydeconz.light import (
|
||||
Fan,
|
||||
)
|
||||
|
||||
from homeassistant.components.fan import DOMAIN, SUPPORT_SET_SPEED, FanEntity
|
||||
from homeassistant.components.fan import DOMAIN, FanEntity, FanEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@ -78,7 +78,7 @@ class DeconzFan(DeconzDevice, FanEntity):
|
||||
TYPE = DOMAIN
|
||||
_device: Fan
|
||||
|
||||
_attr_supported_features = SUPPORT_SET_SPEED
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
def __init__(self, device: Fan, gateway: DeconzGateway) -> None:
|
||||
"""Set up fan."""
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Support for deCONZ lights."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
@ -30,10 +29,8 @@ from homeassistant.components.light import (
|
||||
EFFECT_COLORLOOP,
|
||||
FLASH_LONG,
|
||||
FLASH_SHORT,
|
||||
SUPPORT_EFFECT,
|
||||
SUPPORT_FLASH,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -149,11 +146,11 @@ class DeconzBaseLight(DeconzDevice, LightEntity):
|
||||
self._attr_supported_color_modes.add(COLOR_MODE_ONOFF)
|
||||
|
||||
if device.brightness is not None:
|
||||
self._attr_supported_features |= SUPPORT_FLASH
|
||||
self._attr_supported_features |= SUPPORT_TRANSITION
|
||||
self._attr_supported_features |= LightEntityFeature.FLASH
|
||||
self._attr_supported_features |= LightEntityFeature.TRANSITION
|
||||
|
||||
if device.effect is not None:
|
||||
self._attr_supported_features |= SUPPORT_EFFECT
|
||||
self._attr_supported_features |= LightEntityFeature.EFFECT
|
||||
self._attr_effect_list = [EFFECT_COLORLOOP]
|
||||
|
||||
@property
|
||||
|
@ -17,8 +17,8 @@ from homeassistant.components.light import (
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_ONOFF,
|
||||
PLATFORM_SCHEMA,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -115,7 +115,7 @@ class DecoraWifiLight(LightEntity):
|
||||
def supported_features(self):
|
||||
"""Return supported features."""
|
||||
if self._switch.canSetLevel:
|
||||
return SUPPORT_TRANSITION
|
||||
return LightEntityFeature.TRANSITION
|
||||
return 0
|
||||
|
||||
@property
|
||||
|
@ -6,18 +6,10 @@ import telnetlib
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -30,18 +22,18 @@ _LOGGER = logging.getLogger(__name__)
|
||||
DEFAULT_NAME = "Music station"
|
||||
|
||||
SUPPORT_DENON = (
|
||||
SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
SUPPORT_MEDIA_MODES = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
@ -17,22 +17,13 @@ from denonavr.exceptions import (
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SELECT_SOUND_MODE,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -63,21 +54,21 @@ ATTR_SOUND_MODE_RAW = "sound_mode_raw"
|
||||
ATTR_DYNAMIC_EQ = "dynamic_eq"
|
||||
|
||||
SUPPORT_DENON = (
|
||||
SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_VOLUME_SET
|
||||
MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
)
|
||||
|
||||
SUPPORT_MEDIA_MODES = (
|
||||
SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=10)
|
||||
@ -167,7 +158,8 @@ class DenonDevice(MediaPlayerEntity):
|
||||
|
||||
self._supported_features_base = SUPPORT_DENON
|
||||
self._supported_features_base |= (
|
||||
self._receiver.support_sound_mode and SUPPORT_SELECT_SOUND_MODE
|
||||
self._receiver.support_sound_mode
|
||||
and MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
)
|
||||
self._available = True
|
||||
|
||||
|
@ -9,9 +9,9 @@ from devolo_home_control_api.homecontrol import HomeControl
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_TEMPERATURE,
|
||||
HVAC_MODE_HEAT,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
TEMP_CELSIUS,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PRECISION_HALVES, PRECISION_TENTHS
|
||||
@ -65,7 +65,7 @@ class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntit
|
||||
self._attr_min_temp = self._multi_level_switch_property.min
|
||||
self._attr_max_temp = self._multi_level_switch_property.max
|
||||
self._attr_precision = PRECISION_TENTHS
|
||||
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
self._attr_target_temperature_step = PRECISION_HALVES
|
||||
self._attr_temperature_unit = TEMP_CELSIUS
|
||||
|
||||
|
@ -7,11 +7,9 @@ from devolo_home_control_api.devices.zwave import Zwave
|
||||
from devolo_home_control_api.homecontrol import HomeControl
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -57,7 +55,9 @@ class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
|
||||
|
||||
self._attr_device_class = CoverDeviceClass.BLIND
|
||||
self._attr_supported_features = (
|
||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -8,20 +8,13 @@ from directv import DIRECTV
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerDeviceClass,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
MEDIA_TYPE_MOVIE,
|
||||
MEDIA_TYPE_MUSIC,
|
||||
MEDIA_TYPE_TVSHOW,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING
|
||||
@ -43,23 +36,23 @@ _LOGGER = logging.getLogger(__name__)
|
||||
KNOWN_MEDIA_TYPES = [MEDIA_TYPE_MOVIE, MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW]
|
||||
|
||||
SUPPORT_DTV = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
SUPPORT_DTV_CLIENT = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ from homeassistant.components import media_source, ssdp
|
||||
from homeassistant.components.media_player import (
|
||||
BrowseMedia,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
async_process_play_media_url,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
@ -28,19 +29,6 @@ from homeassistant.components.media_player.const import (
|
||||
REPEAT_MODE_ALL,
|
||||
REPEAT_MODE_OFF,
|
||||
REPEAT_MODE_ONE,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_REPEAT_SET,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_SELECT_SOUND_MODE,
|
||||
SUPPORT_SHUFFLE_SET,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE_ID,
|
||||
@ -503,32 +491,35 @@ class DlnaDmrEntity(MediaPlayerEntity):
|
||||
supported_features = 0
|
||||
|
||||
if self._device.has_volume_level:
|
||||
supported_features |= SUPPORT_VOLUME_SET
|
||||
supported_features |= MediaPlayerEntityFeature.VOLUME_SET
|
||||
if self._device.has_volume_mute:
|
||||
supported_features |= SUPPORT_VOLUME_MUTE
|
||||
supported_features |= MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
if self._device.can_play:
|
||||
supported_features |= SUPPORT_PLAY
|
||||
supported_features |= MediaPlayerEntityFeature.PLAY
|
||||
if self._device.can_pause:
|
||||
supported_features |= SUPPORT_PAUSE
|
||||
supported_features |= MediaPlayerEntityFeature.PAUSE
|
||||
if self._device.can_stop:
|
||||
supported_features |= SUPPORT_STOP
|
||||
supported_features |= MediaPlayerEntityFeature.STOP
|
||||
if self._device.can_previous:
|
||||
supported_features |= SUPPORT_PREVIOUS_TRACK
|
||||
supported_features |= MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
if self._device.can_next:
|
||||
supported_features |= SUPPORT_NEXT_TRACK
|
||||
supported_features |= MediaPlayerEntityFeature.NEXT_TRACK
|
||||
if self._device.has_play_media:
|
||||
supported_features |= SUPPORT_PLAY_MEDIA | SUPPORT_BROWSE_MEDIA
|
||||
supported_features |= (
|
||||
MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
if self._device.can_seek_rel_time:
|
||||
supported_features |= SUPPORT_SEEK
|
||||
supported_features |= MediaPlayerEntityFeature.SEEK
|
||||
|
||||
play_modes = self._device.valid_play_modes
|
||||
if play_modes & {PlayMode.RANDOM, PlayMode.SHUFFLE}:
|
||||
supported_features |= SUPPORT_SHUFFLE_SET
|
||||
supported_features |= MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
if play_modes & {PlayMode.REPEAT_ONE, PlayMode.REPEAT_ALL}:
|
||||
supported_features |= SUPPORT_REPEAT_SET
|
||||
supported_features |= MediaPlayerEntityFeature.REPEAT_SET
|
||||
|
||||
if self._device.has_presets:
|
||||
supported_features |= SUPPORT_SELECT_SOUND_MODE
|
||||
supported_features |= MediaPlayerEntityFeature.SELECT_SOUND_MODE
|
||||
|
||||
return supported_features
|
||||
|
||||
|
@ -8,7 +8,7 @@ import logging
|
||||
import aiohttp
|
||||
import async_timeout
|
||||
|
||||
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
||||
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
@ -96,7 +96,9 @@ class DoorBirdCamera(DoorBirdEntity, Camera):
|
||||
self._stream_url = stream_url
|
||||
self._attr_name = name
|
||||
self._last_image: bytes | None = None
|
||||
self._attr_supported_features = SUPPORT_STREAM if self._stream_url else 0
|
||||
self._attr_supported_features = (
|
||||
CameraEntityFeature.STREAM if self._stream_url else 0
|
||||
)
|
||||
self._interval = interval
|
||||
self._last_update = datetime.datetime.min
|
||||
self._attr_unique_id = f"{self._mac_addr}_{camera_id}"
|
||||
|
@ -9,14 +9,7 @@ import voluptuous as vol
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -46,12 +39,12 @@ PLATFORM_SCHEMA: Final = PARENT_PLATFORM_SCHEMA.extend(
|
||||
)
|
||||
|
||||
DUNEHD_PLAYER_SUPPORT: Final[int] = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user