Use EntityFeature enum in components (d**) (#69358)

This commit is contained in:
epenet 2022-04-06 00:00:37 +02:00 committed by GitHub
parent 9e2198fa47
commit c8df2656b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 114 additions and 170 deletions

View file

@ -5,7 +5,11 @@ import logging
import voluptuous as vol 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 ( from homeassistant.components.climate.const import (
ATTR_FAN_MODE, ATTR_FAN_MODE,
ATTR_HVAC_MODE, ATTR_HVAC_MODE,
@ -25,10 +29,6 @@ from homeassistant.components.climate.const import (
PRESET_BOOST, PRESET_BOOST,
PRESET_ECO, PRESET_ECO,
PRESET_NONE, PRESET_NONE,
SUPPORT_FAN_MODE,
SUPPORT_PRESET_MODE,
SUPPORT_SWING_MODE,
SUPPORT_TARGET_TEMPERATURE,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, TEMP_CELSIUS 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, ATTR_SWING_MODE: self._api.device.swing_modes,
} }
self._supported_features = SUPPORT_TARGET_TEMPERATURE self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
if ( if (
self._api.device.support_away_mode self._api.device.support_away_mode
or self._api.device.support_advanced_modes 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: 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: 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): async def _set(self, settings):
"""Set device settings using API.""" """Set device settings using API."""
@ -172,11 +172,6 @@ class DaikinClimate(ClimateEntity):
if values: if values:
await self._api.device.set(values) await self._api.device.set(values)
@property
def supported_features(self):
"""Return the list of supported features."""
return self._supported_features
@property @property
def name(self): def name(self):
"""Return the name of the thermostat, if any.""" """Return the name of the thermostat, if any."""

View file

@ -19,10 +19,8 @@ from pydeconz.sensor import (
from homeassistant.components.alarm_control_panel import ( from homeassistant.components.alarm_control_panel import (
DOMAIN, DOMAIN,
FORMAT_NUMBER, FORMAT_NUMBER,
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME,
SUPPORT_ALARM_ARM_NIGHT,
AlarmControlPanelEntity, AlarmControlPanelEntity,
AlarmControlPanelEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -124,7 +122,9 @@ class DeconzAlarmControlPanel(DeconzDevice, AlarmControlPanelEntity):
_attr_code_format = FORMAT_NUMBER _attr_code_format = FORMAT_NUMBER
_attr_supported_features = ( _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__( def __init__(

View file

@ -25,7 +25,7 @@ from pydeconz.sensor import (
Thermostat, Thermostat,
) )
from homeassistant.components.climate import DOMAIN, ClimateEntity from homeassistant.components.climate import DOMAIN, ClimateEntity, ClimateEntityFeature
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
FAN_AUTO, FAN_AUTO,
FAN_HIGH, FAN_HIGH,
@ -40,9 +40,6 @@ from homeassistant.components.climate.const import (
PRESET_BOOST, PRESET_BOOST,
PRESET_COMFORT, PRESET_COMFORT,
PRESET_ECO, PRESET_ECO,
SUPPORT_FAN_MODE,
SUPPORT_PRESET_MODE,
SUPPORT_TARGET_TEMPERATURE,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS 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() 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: if device.fan_mode:
self._attr_supported_features |= SUPPORT_FAN_MODE self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
if device.preset: if device.preset:
self._attr_supported_features |= SUPPORT_PRESET_MODE self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
# Fan control # Fan control

View file

@ -1,5 +1,4 @@
"""Support for deCONZ covers.""" """Support for deCONZ covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any, cast from typing import Any, cast
@ -10,16 +9,9 @@ from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
DOMAIN, DOMAIN,
SUPPORT_CLOSE,
SUPPORT_CLOSE_TILT,
SUPPORT_OPEN,
SUPPORT_OPEN_TILT,
SUPPORT_SET_POSITION,
SUPPORT_SET_TILT_POSITION,
SUPPORT_STOP,
SUPPORT_STOP_TILT,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -84,16 +76,16 @@ class DeconzCover(DeconzDevice, CoverEntity):
"""Set up cover device.""" """Set up cover device."""
super().__init__(device, gateway) super().__init__(device, gateway)
self._attr_supported_features = SUPPORT_OPEN self._attr_supported_features = CoverEntityFeature.OPEN
self._attr_supported_features |= SUPPORT_CLOSE self._attr_supported_features |= CoverEntityFeature.CLOSE
self._attr_supported_features |= SUPPORT_STOP self._attr_supported_features |= CoverEntityFeature.STOP
self._attr_supported_features |= SUPPORT_SET_POSITION self._attr_supported_features |= CoverEntityFeature.SET_POSITION
if self._device.tilt is not None: if self._device.tilt is not None:
self._attr_supported_features |= SUPPORT_OPEN_TILT self._attr_supported_features |= CoverEntityFeature.OPEN_TILT
self._attr_supported_features |= SUPPORT_CLOSE_TILT self._attr_supported_features |= CoverEntityFeature.CLOSE_TILT
self._attr_supported_features |= SUPPORT_STOP_TILT self._attr_supported_features |= CoverEntityFeature.STOP_TILT
self._attr_supported_features |= SUPPORT_SET_TILT_POSITION self._attr_supported_features |= CoverEntityFeature.SET_TILT_POSITION
self._attr_device_class = DEVICE_CLASS.get(self._device.type) self._attr_device_class = DEVICE_CLASS.get(self._device.type)

View file

@ -12,7 +12,7 @@ from pydeconz.light import (
Fan, 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.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -78,7 +78,7 @@ class DeconzFan(DeconzDevice, FanEntity):
TYPE = DOMAIN TYPE = DOMAIN
_device: Fan _device: Fan
_attr_supported_features = SUPPORT_SET_SPEED _attr_supported_features = FanEntityFeature.SET_SPEED
def __init__(self, device: Fan, gateway: DeconzGateway) -> None: def __init__(self, device: Fan, gateway: DeconzGateway) -> None:
"""Set up fan.""" """Set up fan."""

View file

@ -1,5 +1,4 @@
"""Support for deCONZ lights.""" """Support for deCONZ lights."""
from __future__ import annotations from __future__ import annotations
from typing import Any from typing import Any
@ -30,10 +29,8 @@ from homeassistant.components.light import (
EFFECT_COLORLOOP, EFFECT_COLORLOOP,
FLASH_LONG, FLASH_LONG,
FLASH_SHORT, FLASH_SHORT,
SUPPORT_EFFECT,
SUPPORT_FLASH,
SUPPORT_TRANSITION,
LightEntity, LightEntity,
LightEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -149,11 +146,11 @@ class DeconzBaseLight(DeconzDevice, LightEntity):
self._attr_supported_color_modes.add(COLOR_MODE_ONOFF) self._attr_supported_color_modes.add(COLOR_MODE_ONOFF)
if device.brightness is not None: if device.brightness is not None:
self._attr_supported_features |= SUPPORT_FLASH self._attr_supported_features |= LightEntityFeature.FLASH
self._attr_supported_features |= SUPPORT_TRANSITION self._attr_supported_features |= LightEntityFeature.TRANSITION
if device.effect is not None: if device.effect is not None:
self._attr_supported_features |= SUPPORT_EFFECT self._attr_supported_features |= LightEntityFeature.EFFECT
self._attr_effect_list = [EFFECT_COLORLOOP] self._attr_effect_list = [EFFECT_COLORLOOP]
@property @property

View file

@ -17,8 +17,8 @@ from homeassistant.components.light import (
COLOR_MODE_BRIGHTNESS, COLOR_MODE_BRIGHTNESS,
COLOR_MODE_ONOFF, COLOR_MODE_ONOFF,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SUPPORT_TRANSITION,
LightEntity, LightEntity,
LightEntityFeature,
) )
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -115,7 +115,7 @@ class DecoraWifiLight(LightEntity):
def supported_features(self): def supported_features(self):
"""Return supported features.""" """Return supported features."""
if self._switch.canSetLevel: if self._switch.canSetLevel:
return SUPPORT_TRANSITION return LightEntityFeature.TRANSITION
return 0 return 0
@property @property

View file

@ -6,18 +6,10 @@ import telnetlib
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity from homeassistant.components.media_player import (
from homeassistant.components.media_player.const import ( PLATFORM_SCHEMA,
SUPPORT_NEXT_TRACK, MediaPlayerEntity,
SUPPORT_PAUSE, MediaPlayerEntityFeature,
SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_SELECT_SOURCE,
SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
) )
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -30,18 +22,18 @@ _LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = "Music station" DEFAULT_NAME = "Music station"
SUPPORT_DENON = ( SUPPORT_DENON = (
SUPPORT_VOLUME_SET MediaPlayerEntityFeature.VOLUME_SET
| SUPPORT_VOLUME_MUTE | MediaPlayerEntityFeature.VOLUME_MUTE
| SUPPORT_TURN_ON | MediaPlayerEntityFeature.TURN_ON
| SUPPORT_TURN_OFF | MediaPlayerEntityFeature.TURN_OFF
| SUPPORT_SELECT_SOURCE | MediaPlayerEntityFeature.SELECT_SOURCE
) )
SUPPORT_MEDIA_MODES = ( SUPPORT_MEDIA_MODES = (
SUPPORT_PAUSE MediaPlayerEntityFeature.PAUSE
| SUPPORT_STOP | MediaPlayerEntityFeature.STOP
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
) )
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(

View file

@ -17,22 +17,13 @@ from denonavr.exceptions import (
) )
import voluptuous as vol 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 ( from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_CHANNEL,
MEDIA_TYPE_MUSIC, 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.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -63,21 +54,21 @@ ATTR_SOUND_MODE_RAW = "sound_mode_raw"
ATTR_DYNAMIC_EQ = "dynamic_eq" ATTR_DYNAMIC_EQ = "dynamic_eq"
SUPPORT_DENON = ( SUPPORT_DENON = (
SUPPORT_VOLUME_STEP MediaPlayerEntityFeature.VOLUME_STEP
| SUPPORT_VOLUME_MUTE | MediaPlayerEntityFeature.VOLUME_MUTE
| SUPPORT_TURN_ON | MediaPlayerEntityFeature.TURN_ON
| SUPPORT_TURN_OFF | MediaPlayerEntityFeature.TURN_OFF
| SUPPORT_SELECT_SOURCE | MediaPlayerEntityFeature.SELECT_SOURCE
| SUPPORT_VOLUME_SET | MediaPlayerEntityFeature.VOLUME_SET
) )
SUPPORT_MEDIA_MODES = ( SUPPORT_MEDIA_MODES = (
SUPPORT_PLAY_MEDIA MediaPlayerEntityFeature.PLAY_MEDIA
| SUPPORT_PAUSE | MediaPlayerEntityFeature.PAUSE
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_VOLUME_SET | MediaPlayerEntityFeature.VOLUME_SET
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
) )
SCAN_INTERVAL = timedelta(seconds=10) SCAN_INTERVAL = timedelta(seconds=10)
@ -167,7 +158,8 @@ class DenonDevice(MediaPlayerEntity):
self._supported_features_base = SUPPORT_DENON self._supported_features_base = SUPPORT_DENON
self._supported_features_base |= ( 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 self._available = True

View file

@ -9,9 +9,9 @@ from devolo_home_control_api.homecontrol import HomeControl
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ATTR_TEMPERATURE, ATTR_TEMPERATURE,
HVAC_MODE_HEAT, HVAC_MODE_HEAT,
SUPPORT_TARGET_TEMPERATURE,
TEMP_CELSIUS, TEMP_CELSIUS,
ClimateEntity, ClimateEntity,
ClimateEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PRECISION_HALVES, PRECISION_TENTHS 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_min_temp = self._multi_level_switch_property.min
self._attr_max_temp = self._multi_level_switch_property.max self._attr_max_temp = self._multi_level_switch_property.max
self._attr_precision = PRECISION_TENTHS 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_target_temperature_step = PRECISION_HALVES
self._attr_temperature_unit = TEMP_CELSIUS self._attr_temperature_unit = TEMP_CELSIUS

View file

@ -7,11 +7,9 @@ from devolo_home_control_api.devices.zwave import Zwave
from devolo_home_control_api.homecontrol import HomeControl from devolo_home_control_api.homecontrol import HomeControl
from homeassistant.components.cover import ( from homeassistant.components.cover import (
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -57,7 +55,9 @@ class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
self._attr_device_class = CoverDeviceClass.BLIND self._attr_device_class = CoverDeviceClass.BLIND
self._attr_supported_features = ( self._attr_supported_features = (
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.SET_POSITION
) )
@property @property

View file

@ -8,20 +8,13 @@ from directv import DIRECTV
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MediaPlayerDeviceClass, MediaPlayerDeviceClass,
MediaPlayerEntity, MediaPlayerEntity,
MediaPlayerEntityFeature,
) )
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL, MEDIA_TYPE_CHANNEL,
MEDIA_TYPE_MOVIE, MEDIA_TYPE_MOVIE,
MEDIA_TYPE_MUSIC, MEDIA_TYPE_MUSIC,
MEDIA_TYPE_TVSHOW, 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.config_entries import ConfigEntry
from homeassistant.const import STATE_OFF, STATE_PAUSED, STATE_PLAYING 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] KNOWN_MEDIA_TYPES = [MEDIA_TYPE_MOVIE, MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW]
SUPPORT_DTV = ( SUPPORT_DTV = (
SUPPORT_PAUSE MediaPlayerEntityFeature.PAUSE
| SUPPORT_TURN_ON | MediaPlayerEntityFeature.TURN_ON
| SUPPORT_TURN_OFF | MediaPlayerEntityFeature.TURN_OFF
| SUPPORT_PLAY_MEDIA | MediaPlayerEntityFeature.PLAY_MEDIA
| SUPPORT_STOP | MediaPlayerEntityFeature.STOP
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
) )
SUPPORT_DTV_CLIENT = ( SUPPORT_DTV_CLIENT = (
SUPPORT_PAUSE MediaPlayerEntityFeature.PAUSE
| SUPPORT_PLAY_MEDIA | MediaPlayerEntityFeature.PLAY_MEDIA
| SUPPORT_STOP | MediaPlayerEntityFeature.STOP
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
) )

View file

@ -21,6 +21,7 @@ from homeassistant.components import media_source, ssdp
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
BrowseMedia, BrowseMedia,
MediaPlayerEntity, MediaPlayerEntity,
MediaPlayerEntityFeature,
async_process_play_media_url, async_process_play_media_url,
) )
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
@ -28,19 +29,6 @@ from homeassistant.components.media_player.const import (
REPEAT_MODE_ALL, REPEAT_MODE_ALL,
REPEAT_MODE_OFF, REPEAT_MODE_OFF,
REPEAT_MODE_ONE, 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 ( from homeassistant.const import (
CONF_DEVICE_ID, CONF_DEVICE_ID,
@ -503,32 +491,35 @@ class DlnaDmrEntity(MediaPlayerEntity):
supported_features = 0 supported_features = 0
if self._device.has_volume_level: if self._device.has_volume_level:
supported_features |= SUPPORT_VOLUME_SET supported_features |= MediaPlayerEntityFeature.VOLUME_SET
if self._device.has_volume_mute: if self._device.has_volume_mute:
supported_features |= SUPPORT_VOLUME_MUTE supported_features |= MediaPlayerEntityFeature.VOLUME_MUTE
if self._device.can_play: if self._device.can_play:
supported_features |= SUPPORT_PLAY supported_features |= MediaPlayerEntityFeature.PLAY
if self._device.can_pause: if self._device.can_pause:
supported_features |= SUPPORT_PAUSE supported_features |= MediaPlayerEntityFeature.PAUSE
if self._device.can_stop: if self._device.can_stop:
supported_features |= SUPPORT_STOP supported_features |= MediaPlayerEntityFeature.STOP
if self._device.can_previous: if self._device.can_previous:
supported_features |= SUPPORT_PREVIOUS_TRACK supported_features |= MediaPlayerEntityFeature.PREVIOUS_TRACK
if self._device.can_next: if self._device.can_next:
supported_features |= SUPPORT_NEXT_TRACK supported_features |= MediaPlayerEntityFeature.NEXT_TRACK
if self._device.has_play_media: 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: if self._device.can_seek_rel_time:
supported_features |= SUPPORT_SEEK supported_features |= MediaPlayerEntityFeature.SEEK
play_modes = self._device.valid_play_modes play_modes = self._device.valid_play_modes
if play_modes & {PlayMode.RANDOM, PlayMode.SHUFFLE}: 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}: if play_modes & {PlayMode.REPEAT_ONE, PlayMode.REPEAT_ALL}:
supported_features |= SUPPORT_REPEAT_SET supported_features |= MediaPlayerEntityFeature.REPEAT_SET
if self._device.has_presets: if self._device.has_presets:
supported_features |= SUPPORT_SELECT_SOUND_MODE supported_features |= MediaPlayerEntityFeature.SELECT_SOUND_MODE
return supported_features return supported_features

View file

@ -8,7 +8,7 @@ import logging
import aiohttp import aiohttp
import async_timeout 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.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -96,7 +96,9 @@ class DoorBirdCamera(DoorBirdEntity, Camera):
self._stream_url = stream_url self._stream_url = stream_url
self._attr_name = name self._attr_name = name
self._last_image: bytes | None = None 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._interval = interval
self._last_update = datetime.datetime.min self._last_update = datetime.datetime.min
self._attr_unique_id = f"{self._mac_addr}_{camera_id}" self._attr_unique_id = f"{self._mac_addr}_{camera_id}"

View file

@ -9,14 +9,7 @@ import voluptuous as vol
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA, PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
MediaPlayerEntity, MediaPlayerEntity,
) MediaPlayerEntityFeature,
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE,
SUPPORT_PLAY,
SUPPORT_PREVIOUS_TRACK,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
) )
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -46,12 +39,12 @@ PLATFORM_SCHEMA: Final = PARENT_PLATFORM_SCHEMA.extend(
) )
DUNEHD_PLAYER_SUPPORT: Final[int] = ( DUNEHD_PLAYER_SUPPORT: Final[int] = (
SUPPORT_PAUSE MediaPlayerEntityFeature.PAUSE
| SUPPORT_TURN_ON | MediaPlayerEntityFeature.TURN_ON
| SUPPORT_TURN_OFF | MediaPlayerEntityFeature.TURN_OFF
| SUPPORT_PREVIOUS_TRACK | MediaPlayerEntityFeature.PREVIOUS_TRACK
| SUPPORT_NEXT_TRACK | MediaPlayerEntityFeature.NEXT_TRACK
| SUPPORT_PLAY | MediaPlayerEntityFeature.PLAY
) )