mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Use EntityFeature enum in components (h**) (#69403)
This commit is contained in:
parent
38cfa83e23
commit
999e2f3bf0
@ -4,13 +4,10 @@ from __future__ import annotations
|
||||
import hkavr
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -21,14 +18,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
DEFAULT_NAME = "Harman Kardon AVR"
|
||||
DEFAULT_PORT = 10025
|
||||
|
||||
SUPPORT_HARMAN_KARDON_AVR = (
|
||||
SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
@ -58,6 +47,14 @@ def setup_platform(
|
||||
class HkAvrDevice(MediaPlayerEntity):
|
||||
"""Representation of a Harman Kardon AVR / JBL AVR TV."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
|
||||
def __init__(self, avr):
|
||||
"""Initialize a new HarmanKardonAVR."""
|
||||
self._avr = avr
|
||||
@ -109,11 +106,6 @@ class HkAvrDevice(MediaPlayerEntity):
|
||||
"""Available sources."""
|
||||
return self._source_list
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_HARMAN_KARDON_AVR
|
||||
|
||||
def turn_on(self):
|
||||
"""Turn the AVR on."""
|
||||
self._avr.power_on()
|
||||
|
@ -4,7 +4,6 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import remote
|
||||
from homeassistant.components.remote import (
|
||||
ATTR_ACTIVITY,
|
||||
ATTR_DELAY_SECS,
|
||||
@ -12,7 +11,8 @@ from homeassistant.components.remote import (
|
||||
ATTR_HOLD_SECS,
|
||||
ATTR_NUM_REPEATS,
|
||||
DEFAULT_DELAY_SECS,
|
||||
SUPPORT_ACTIVITY,
|
||||
RemoteEntity,
|
||||
RemoteEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -77,9 +77,11 @@ async def async_setup_entry(
|
||||
)
|
||||
|
||||
|
||||
class HarmonyRemote(HarmonyEntity, remote.RemoteEntity, RestoreEntity):
|
||||
class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity):
|
||||
"""Remote representation used to control a Harmony device."""
|
||||
|
||||
_attr_supported_features = RemoteEntityFeature.ACTIVITY
|
||||
|
||||
def __init__(self, data, activity, delay_secs, out_path):
|
||||
"""Initialize HarmonyRemote class."""
|
||||
super().__init__(data=data)
|
||||
@ -94,7 +96,6 @@ class HarmonyRemote(HarmonyEntity, remote.RemoteEntity, RestoreEntity):
|
||||
self._attr_unique_id = data.unique_id
|
||||
self._attr_device_info = self._data.device_info(DOMAIN)
|
||||
self._attr_name = data.name
|
||||
self._attr_supported_features = SUPPORT_ACTIVITY
|
||||
|
||||
async def _async_update_options(self, data):
|
||||
"""Change options when the options flow does."""
|
||||
|
@ -24,19 +24,11 @@ from pycec.const import (
|
||||
TYPE_TUNER,
|
||||
)
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
DOMAIN as MP_DOMAIN,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_IDLE,
|
||||
STATE_OFF,
|
||||
@ -185,27 +177,27 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity):
|
||||
"""Flag media player features that are supported."""
|
||||
if self.type_id == TYPE_RECORDER or self.type == TYPE_PLAYBACK:
|
||||
return (
|
||||
SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
)
|
||||
if self.type == TYPE_TUNER:
|
||||
return (
|
||||
SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_STOP
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
)
|
||||
if self.type_id == TYPE_AUDIO:
|
||||
return (
|
||||
SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
)
|
||||
return SUPPORT_TURN_ON | SUPPORT_TURN_OFF
|
||||
return MediaPlayerEntityFeature.TURN_ON | MediaPlayerEntityFeature.TURN_OFF
|
||||
|
@ -11,8 +11,8 @@ from homeassistant.components.climate import (
|
||||
HVAC_MODE_OFF,
|
||||
PLATFORM_SCHEMA,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_HOST,
|
||||
@ -76,6 +76,8 @@ def setup_platform(
|
||||
class HeatmiserV3Thermostat(ClimateEntity):
|
||||
"""Representation of a HeatmiserV3 thermostat."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def __init__(self, therm, device, uh1):
|
||||
"""Initialize the thermostat."""
|
||||
self.therm = therm(device[CONF_ID], "prt", uh1)
|
||||
@ -88,11 +90,6 @@ class HeatmiserV3Thermostat(ClimateEntity):
|
||||
self._hvac_mode = HVAC_MODE_HEAT
|
||||
self._temperature_unit = None
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the thermostat, if any."""
|
||||
|
@ -8,7 +8,10 @@ from operator import ior
|
||||
from pyheos import HeosError, const as heos_const
|
||||
|
||||
from homeassistant.components import media_source
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.browse_media import (
|
||||
async_process_play_media_url,
|
||||
)
|
||||
@ -18,20 +21,6 @@ from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
MEDIA_TYPE_PLAYLIST,
|
||||
MEDIA_TYPE_URL,
|
||||
SUPPORT_BROWSE_MEDIA,
|
||||
SUPPORT_CLEAR_PLAYLIST,
|
||||
SUPPORT_GROUPING,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
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 STATE_IDLE, STATE_PAUSED, STATE_PLAYING
|
||||
@ -54,15 +43,15 @@ from .const import (
|
||||
)
|
||||
|
||||
BASE_SUPPORTED_FEATURES = (
|
||||
SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_CLEAR_PLAYLIST
|
||||
| SUPPORT_SHUFFLE_SET
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_GROUPING
|
||||
| SUPPORT_BROWSE_MEDIA
|
||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.CLEAR_PLAYLIST
|
||||
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.GROUPING
|
||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
||||
)
|
||||
|
||||
PLAY_STATE_TO_STATE = {
|
||||
@ -72,11 +61,11 @@ PLAY_STATE_TO_STATE = {
|
||||
}
|
||||
|
||||
CONTROL_TO_SUPPORT = {
|
||||
heos_const.CONTROL_PLAY: SUPPORT_PLAY,
|
||||
heos_const.CONTROL_PAUSE: SUPPORT_PAUSE,
|
||||
heos_const.CONTROL_STOP: SUPPORT_STOP,
|
||||
heos_const.CONTROL_PLAY_PREVIOUS: SUPPORT_PREVIOUS_TRACK,
|
||||
heos_const.CONTROL_PLAY_NEXT: SUPPORT_NEXT_TRACK,
|
||||
heos_const.CONTROL_PLAY: MediaPlayerEntityFeature.PLAY,
|
||||
heos_const.CONTROL_PAUSE: MediaPlayerEntityFeature.PAUSE,
|
||||
heos_const.CONTROL_STOP: MediaPlayerEntityFeature.STOP,
|
||||
heos_const.CONTROL_PLAY_PREVIOUS: MediaPlayerEntityFeature.PREVIOUS_TRACK,
|
||||
heos_const.CONTROL_PLAY_NEXT: MediaPlayerEntityFeature.NEXT_TRACK,
|
||||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -115,7 +104,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
self._media_position_updated_at = None
|
||||
self._player = player
|
||||
self._signals = []
|
||||
self._supported_features = BASE_SUPPORTED_FEATURES
|
||||
self._attr_supported_features = BASE_SUPPORTED_FEATURES
|
||||
self._source_manager = None
|
||||
self._group_manager = None
|
||||
|
||||
@ -272,7 +261,9 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
"""Update supported features of the player."""
|
||||
controls = self._player.now_playing_media.supported_controls
|
||||
current_support = [CONTROL_TO_SUPPORT[control] for control in controls]
|
||||
self._supported_features = reduce(ior, current_support, BASE_SUPPORTED_FEATURES)
|
||||
self._attr_supported_features = reduce(
|
||||
ior, current_support, BASE_SUPPORTED_FEATURES
|
||||
)
|
||||
|
||||
if self._group_manager is None:
|
||||
self._group_manager = self.hass.data[HEOS_DOMAIN][DATA_GROUP_MANAGER]
|
||||
@ -419,11 +410,6 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
"""State of the player."""
|
||||
return PLAY_STATE_TO_STATE[self._player.state]
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag media player features that are supported."""
|
||||
return self._supported_features
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique ID."""
|
||||
|
@ -4,7 +4,7 @@ import logging
|
||||
from pyaehw4a1.aehw4a1 import AehW4a1
|
||||
import pyaehw4a1.exceptions
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
FAN_AUTO,
|
||||
FAN_HIGH,
|
||||
@ -19,10 +19,6 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
PRESET_SLEEP,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_SWING_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SWING_BOTH,
|
||||
SWING_HORIZONTAL,
|
||||
SWING_OFF,
|
||||
@ -40,13 +36,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import CONF_IP_ADDRESS, DOMAIN
|
||||
|
||||
SUPPORT_FLAGS = (
|
||||
SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_FAN_MODE
|
||||
| SUPPORT_SWING_MODE
|
||||
| SUPPORT_PRESET_MODE
|
||||
)
|
||||
|
||||
MIN_TEMP_C = 16
|
||||
MAX_TEMP_C = 32
|
||||
|
||||
@ -153,6 +142,13 @@ async def async_setup_entry(
|
||||
class ClimateAehW4a1(ClimateEntity):
|
||||
"""Representation of a Hisense AEH-W4A1 module for climate device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.SWING_MODE
|
||||
| ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the climate device."""
|
||||
self._unique_id = device
|
||||
@ -319,11 +315,6 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
"""Return the supported step of target temperature."""
|
||||
return 1
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
"""Set new target temperatures."""
|
||||
if self._on != "1":
|
||||
|
@ -1,10 +1,9 @@
|
||||
"""Support for the Hive alarm."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -46,6 +45,10 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
|
||||
"""Representation of a Hive alarm."""
|
||||
|
||||
_attr_icon = ICON
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
@ -81,11 +84,6 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
|
||||
return STATE_ALARM_TRIGGERED
|
||||
return HIVETOHA[self.device["status"]["mode"]]
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
await self.hive.alarm.setMode(self.device, "home")
|
||||
|
@ -4,7 +4,7 @@ import logging
|
||||
|
||||
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,
|
||||
@ -14,8 +14,6 @@ from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_OFF,
|
||||
PRESET_BOOST,
|
||||
PRESET_NONE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
@ -52,7 +50,6 @@ HIVE_TO_HASS_HVAC_ACTION = {
|
||||
|
||||
TEMP_UNIT = {"C": TEMP_CELSIUS, "F": TEMP_FAHRENHEIT}
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
||||
SUPPORT_PRESET = [PRESET_NONE, PRESET_BOOST]
|
||||
PARALLEL_UPDATES = 0
|
||||
@ -111,6 +108,10 @@ async def async_setup_entry(
|
||||
class HiveClimateEntity(HiveEntity, ClimateEntity):
|
||||
"""Hive Climate Device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
def __init__(self, hive_session, hive_device):
|
||||
"""Initialize the Climate device."""
|
||||
super().__init__(hive_session, hive_device)
|
||||
@ -134,11 +135,6 @@ class HiveClimateEntity(HiveEntity, ClimateEntity):
|
||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||
)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the Climate device."""
|
||||
|
@ -5,8 +5,8 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
STATE_ECO,
|
||||
SUPPORT_OPERATION_MODE,
|
||||
WaterHeaterEntity,
|
||||
WaterHeaterEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, TEMP_CELSIUS
|
||||
@ -24,7 +24,6 @@ from .const import (
|
||||
WATER_HEATER_MODES,
|
||||
)
|
||||
|
||||
SUPPORT_FLAGS_HEATER = SUPPORT_OPERATION_MODE
|
||||
HOTWATER_NAME = "Hot Water"
|
||||
PARALLEL_UPDATES = 0
|
||||
SCAN_INTERVAL = timedelta(seconds=15)
|
||||
@ -75,6 +74,8 @@ async def async_setup_entry(
|
||||
class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
|
||||
"""Hive Water Heater Device."""
|
||||
|
||||
_attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique ID of entity."""
|
||||
@ -92,11 +93,6 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
|
||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||
)
|
||||
|
||||
@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."""
|
||||
|
@ -6,7 +6,7 @@ from typing import Any
|
||||
|
||||
import somecomfort
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
@ -25,12 +25,6 @@ from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_OFF,
|
||||
PRESET_AWAY,
|
||||
PRESET_NONE,
|
||||
SUPPORT_AUX_HEAT,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_HUMIDITY,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
||||
@ -121,16 +115,16 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
self._attr_hvac_modes = list(self._hvac_mode_map)
|
||||
|
||||
self._attr_supported_features = (
|
||||
SUPPORT_PRESET_MODE
|
||||
| SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
ClimateEntityFeature.PRESET_MODE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
if device._data["canControlHumidification"]:
|
||||
self._attr_supported_features |= SUPPORT_TARGET_HUMIDITY
|
||||
self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
|
||||
|
||||
if device.raw_ui_data["SwitchEmergencyHeatAllowed"]:
|
||||
self._attr_supported_features |= SUPPORT_AUX_HEAT
|
||||
self._attr_supported_features |= ClimateEntityFeature.AUX_HEAT
|
||||
|
||||
if not device._data["hasFan"]:
|
||||
return
|
||||
@ -141,7 +135,7 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
|
||||
self._attr_fan_modes = list(self._fan_mode_map)
|
||||
|
||||
self._attr_supported_features |= SUPPORT_FAN_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
|
@ -9,17 +9,12 @@ from horimote.exceptions import AuthenticationError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import util
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_CHANNEL
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
@ -42,15 +37,6 @@ DEFAULT_PORT = 5900
|
||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(seconds=1)
|
||||
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
||||
|
||||
SUPPORT_HORIZON = (
|
||||
SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
@ -91,6 +77,16 @@ def setup_platform(
|
||||
class HorizonDevice(MediaPlayerEntity):
|
||||
"""Representation of a Horizon HD Recorder."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
)
|
||||
|
||||
def __init__(self, client, name, remote_keys):
|
||||
"""Initialize the remote."""
|
||||
self._client = client
|
||||
@ -108,11 +104,6 @@ class HorizonDevice(MediaPlayerEntity):
|
||||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_HORIZON
|
||||
|
||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||
def update(self):
|
||||
"""Update State using the media server running on the Horizon."""
|
||||
|
@ -14,12 +14,9 @@ import async_timeout
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_STOP,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -112,20 +109,19 @@ class PowerViewShade(ShadeEntity, CoverEntity):
|
||||
self._last_action_timestamp = 0
|
||||
self._scheduled_transition_update = None
|
||||
self._current_cover_position = MIN_POSITION
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
if self._device_info[DEVICE_MODEL] != LEGACY_DEVICE_MODEL:
|
||||
self._attr_supported_features |= CoverEntityFeature.STOP
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {STATE_ATTRIBUTE_ROOM_NAME: self._room_name}
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
||||
if self._device_info[DEVICE_MODEL] != LEGACY_DEVICE_MODEL:
|
||||
supported_features |= SUPPORT_STOP
|
||||
return supported_features
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
"""Return if the cover is closed."""
|
||||
|
@ -14,8 +14,8 @@ from homeassistant.components.light import (
|
||||
ATTR_EFFECT,
|
||||
ATTR_HS_COLOR,
|
||||
COLOR_MODE_HS,
|
||||
SUPPORT_EFFECT,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -126,7 +126,7 @@ class HyperionBaseLight(LightEntity):
|
||||
|
||||
_attr_color_mode = COLOR_MODE_HS
|
||||
_attr_supported_color_modes = {COLOR_MODE_HS}
|
||||
_attr_supported_features = SUPPORT_EFFECT
|
||||
_attr_supported_features = LightEntityFeature.EFFECT
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user