Use EntityFeature enum in components (e**) (#69384)
This commit is contained in:
parent
9ab9fcfc56
commit
78045df227
17 changed files with 140 additions and 210 deletions
|
@ -5,7 +5,7 @@ import collections
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
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,
|
||||
|
@ -22,12 +22,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.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -169,11 +163,11 @@ SET_FAN_MIN_ON_TIME_SCHEMA = vol.Schema(
|
|||
|
||||
|
||||
SUPPORT_FLAGS = (
|
||||
SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_PRESET_MODE
|
||||
| SUPPORT_AUX_HEAT
|
||||
| SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
| SUPPORT_FAN_MODE
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.PRESET_MODE
|
||||
| ClimateEntityFeature.AUX_HEAT
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
)
|
||||
|
||||
|
||||
|
@ -361,7 +355,7 @@ class Thermostat(ClimateEntity):
|
|||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
if self.has_humidifier_control:
|
||||
return SUPPORT_FLAGS | SUPPORT_TARGET_HUMIDITY
|
||||
return SUPPORT_FLAGS | ClimateEntityFeature.TARGET_HUMIDITY
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
@property
|
||||
|
|
|
@ -3,12 +3,15 @@ from __future__ import annotations
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.humidifier import HumidifierDeviceClass, HumidifierEntity
|
||||
from homeassistant.components.humidifier import (
|
||||
HumidifierDeviceClass,
|
||||
HumidifierEntity,
|
||||
HumidifierEntityFeature,
|
||||
)
|
||||
from homeassistant.components.humidifier.const import (
|
||||
DEFAULT_MAX_HUMIDITY,
|
||||
DEFAULT_MIN_HUMIDITY,
|
||||
MODE_AUTO,
|
||||
SUPPORT_MODES,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -42,6 +45,8 @@ async def async_setup_entry(
|
|||
class EcobeeHumidifier(HumidifierEntity):
|
||||
"""A humidifier class for an ecobee thermostat with humidifier attached."""
|
||||
|
||||
_attr_supported_features = HumidifierEntityFeature.MODES
|
||||
|
||||
def __init__(self, data, thermostat_index):
|
||||
"""Initialize ecobee humidifier platform."""
|
||||
self.data = data
|
||||
|
@ -125,11 +130,6 @@ class EcobeeHumidifier(HumidifierEntity):
|
|||
"""Return the current mode, e.g., off, auto, manual."""
|
||||
return self.thermostat["settings"]["humidifierMode"]
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_MODES
|
||||
|
||||
@property
|
||||
def target_humidity(self) -> int:
|
||||
"""Return the desired humidity set point."""
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from pyeconet.equipment import EquipmentType
|
||||
from pyeconet.equipment.thermostat import ThermostatFanMode, ThermostatOperationMode
|
||||
|
||||
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,
|
||||
|
@ -15,11 +15,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_AUX_HEAT,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_HUMIDITY,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE
|
||||
|
@ -47,10 +42,10 @@ ECONET_FAN_STATE_TO_HA = {
|
|||
HA_FAN_STATE_TO_ECONET = {value: key for key, value in ECONET_FAN_STATE_TO_HA.items()}
|
||||
|
||||
SUPPORT_FLAGS_THERMOSTAT = (
|
||||
SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
| SUPPORT_FAN_MODE
|
||||
| SUPPORT_AUX_HEAT
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
| ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.AUX_HEAT
|
||||
)
|
||||
|
||||
|
||||
|
@ -90,7 +85,7 @@ class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
|||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
if self._econet.supports_humidifier:
|
||||
return SUPPORT_FLAGS_THERMOSTAT | SUPPORT_TARGET_HUMIDITY
|
||||
return SUPPORT_FLAGS_THERMOSTAT | ClimateEntityFeature.TARGET_HUMIDITY
|
||||
return SUPPORT_FLAGS_THERMOSTAT
|
||||
|
||||
@property
|
||||
|
|
|
@ -11,10 +11,8 @@ from homeassistant.components.water_heater import (
|
|||
STATE_HEAT_PUMP,
|
||||
STATE_HIGH_DEMAND,
|
||||
STATE_PERFORMANCE,
|
||||
SUPPORT_AWAY_MODE,
|
||||
SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
WaterHeaterEntity,
|
||||
WaterHeaterEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF
|
||||
|
@ -37,7 +35,10 @@ ECONET_STATE_TO_HA = {
|
|||
}
|
||||
HA_STATE_TO_ECONET = {value: key for key, value in ECONET_STATE_TO_HA.items()}
|
||||
|
||||
SUPPORT_FLAGS_HEATER = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
|
||||
SUPPORT_FLAGS_HEATER = (
|
||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
| WaterHeaterEntityFeature.OPERATION_MODE
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -108,11 +109,14 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity):
|
|||
"""Return the list of supported features."""
|
||||
if self.water_heater.modes:
|
||||
if self.water_heater.supports_away:
|
||||
return SUPPORT_FLAGS_HEATER | SUPPORT_AWAY_MODE
|
||||
return SUPPORT_FLAGS_HEATER | WaterHeaterEntityFeature.AWAY_MODE
|
||||
return SUPPORT_FLAGS_HEATER
|
||||
if self.water_heater.supports_away:
|
||||
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_AWAY_MODE
|
||||
return SUPPORT_TARGET_TEMPERATURE
|
||||
return (
|
||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
| WaterHeaterEntityFeature.AWAY_MODE
|
||||
)
|
||||
return WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
|
|
|
@ -5,19 +5,7 @@ import logging
|
|||
|
||||
import sucks
|
||||
|
||||
from homeassistant.components.vacuum import (
|
||||
SUPPORT_BATTERY,
|
||||
SUPPORT_CLEAN_SPOT,
|
||||
SUPPORT_FAN_SPEED,
|
||||
SUPPORT_LOCATE,
|
||||
SUPPORT_RETURN_HOME,
|
||||
SUPPORT_SEND_COMMAND,
|
||||
SUPPORT_STATUS,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
VacuumEntity,
|
||||
)
|
||||
from homeassistant.components.vacuum import VacuumEntity, VacuumEntityFeature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
|
@ -27,19 +15,6 @@ from . import ECOVACS_DEVICES
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_ECOVACS = (
|
||||
SUPPORT_BATTERY
|
||||
| SUPPORT_RETURN_HOME
|
||||
| SUPPORT_CLEAN_SPOT
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_LOCATE
|
||||
| SUPPORT_STATUS
|
||||
| SUPPORT_SEND_COMMAND
|
||||
| SUPPORT_FAN_SPEED
|
||||
)
|
||||
|
||||
ATTR_ERROR = "error"
|
||||
ATTR_COMPONENT_PREFIX = "component_"
|
||||
|
||||
|
@ -61,6 +36,19 @@ def setup_platform(
|
|||
class EcovacsVacuum(VacuumEntity):
|
||||
"""Ecovacs Vacuums such as Deebot."""
|
||||
|
||||
_attr_supported_features = (
|
||||
VacuumEntityFeature.BATTERY
|
||||
| VacuumEntityFeature.RETURN_HOME
|
||||
| VacuumEntityFeature.CLEAN_SPOT
|
||||
| VacuumEntityFeature.STOP
|
||||
| VacuumEntityFeature.TURN_OFF
|
||||
| VacuumEntityFeature.TURN_ON
|
||||
| VacuumEntityFeature.LOCATE
|
||||
| VacuumEntityFeature.STATUS
|
||||
| VacuumEntityFeature.SEND_COMMAND
|
||||
| VacuumEntityFeature.FAN_SPEED
|
||||
)
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the Ecovacs Vacuum."""
|
||||
self.device = device
|
||||
|
@ -123,11 +111,6 @@ class EcovacsVacuum(VacuumEntity):
|
|||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag vacuum cleaner robot features that are supported."""
|
||||
return SUPPORT_ECOVACS
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
"""Return the status of the vacuum cleaner."""
|
||||
|
|
|
@ -6,10 +6,7 @@ import logging
|
|||
import requests
|
||||
|
||||
import homeassistant.components.alarm_control_panel as alarm
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntityFeature
|
||||
from homeassistant.const import (
|
||||
STATE_ALARM_ARMED_AWAY,
|
||||
STATE_ALARM_ARMED_HOME,
|
||||
|
@ -66,6 +63,11 @@ def setup_platform(
|
|||
class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
||||
"""Representation of a Egardia alarm."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self, name, egardiasystem, rs_enabled=False, rs_codes=None, rs_port=52010
|
||||
):
|
||||
|
@ -93,11 +95,6 @@ class EgardiaAlarm(alarm.AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self._status
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Poll if no report server is enabled."""
|
||||
|
|
|
@ -9,11 +9,7 @@ from homeassistant.components.alarm_control_panel import (
|
|||
ATTR_CHANGED_BY,
|
||||
FORMAT_NUMBER,
|
||||
AlarmControlPanelEntity,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -107,6 +103,12 @@ async def async_setup_entry(
|
|||
class ElkArea(ElkAttachedEntity, AlarmControlPanelEntity, RestoreEntity):
|
||||
"""Representation of an Area / Partition within the ElkM1 alarm panel."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||
)
|
||||
|
||||
def __init__(self, element, elk, elk_data):
|
||||
"""Initialize Area as Alarm Control Panel."""
|
||||
super().__init__(element, elk, elk_data)
|
||||
|
@ -170,11 +172,6 @@ class ElkArea(ElkAttachedEntity, AlarmControlPanelEntity, RestoreEntity):
|
|||
"""Return the state of the element."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Attributes of the area."""
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from elkm1_lib.const import ThermostatFan, ThermostatMode, ThermostatSetting
|
||||
|
||||
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,
|
||||
|
@ -12,9 +12,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_FAN_ONLY,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_AUX_HEAT,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PRECISION_WHOLE, STATE_ON
|
||||
|
@ -51,16 +48,17 @@ async def async_setup_entry(
|
|||
class ElkThermostat(ElkEntity, ClimateEntity):
|
||||
"""Representation of an Elk-M1 Thermostat."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.AUX_HEAT
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
def __init__(self, element, elk, elk_data):
|
||||
"""Initialize climate entity."""
|
||||
super().__init__(element, elk, elk_data)
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FAN_MODE | SUPPORT_AUX_HEAT | SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Return the temperature unit."""
|
||||
|
|
|
@ -6,18 +6,16 @@ import logging
|
|||
from pyemby import EmbyServer
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
PLATFORM_SCHEMA,
|
||||
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_PREVIOUS_TRACK,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_STOP,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
|
@ -49,12 +47,12 @@ DEFAULT_SSL_PORT = 8920
|
|||
DEFAULT_SSL = False
|
||||
|
||||
SUPPORT_EMBY = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_PLAY
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.SEEK
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
|
|
@ -4,20 +4,11 @@ from __future__ import annotations
|
|||
from openwebif.api import CreateDevice
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_TVSHOW,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.const import MEDIA_TYPE_TVSHOW
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
|
@ -55,19 +46,6 @@ DEFAULT_DEEP_STANDBY = False
|
|||
DEFAULT_MAC_ADDRESS = ""
|
||||
DEFAULT_SOURCE_BOUQUET = ""
|
||||
|
||||
SUPPORTED_ENIGMA2 = (
|
||||
SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_STOP
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_PAUSE
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
|
@ -126,6 +104,19 @@ def setup_platform(
|
|||
class Enigma2Device(MediaPlayerEntity):
|
||||
"""Representation of an Enigma2 box."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.STOP
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
)
|
||||
|
||||
def __init__(self, name, device):
|
||||
"""Initialize the Enigma2 device."""
|
||||
self._name = name
|
||||
|
@ -153,11 +144,6 @@ class Enigma2Device(MediaPlayerEntity):
|
|||
"""Return True if the device is available."""
|
||||
return not self.e2_box.is_offline
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag of media commands that are supported."""
|
||||
return SUPPORTED_ENIGMA2
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn off media player."""
|
||||
self.e2_box.turn_off()
|
||||
|
|
|
@ -8,12 +8,7 @@ import voluptuous as vol
|
|||
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,
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
SUPPORT_ALARM_TRIGGER,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -108,6 +103,13 @@ async def async_setup_platform(
|
|||
class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
||||
"""Representation of an Envisalink-based alarm panel."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||
| AlarmControlPanelEntityFeature.TRIGGER
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self, hass, partition_number, alarm_name, code, panic_type, info, controller
|
||||
):
|
||||
|
@ -166,16 +168,6 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
|||
state = STATE_ALARM_DISARMED
|
||||
return state
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return (
|
||||
SUPPORT_ALARM_ARM_HOME
|
||||
| SUPPORT_ALARM_ARM_AWAY
|
||||
| SUPPORT_ALARM_ARM_NIGHT
|
||||
| SUPPORT_ALARM_TRIGGER
|
||||
)
|
||||
|
||||
async def async_alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
if code:
|
||||
|
|
|
@ -17,15 +17,17 @@ from pyephember.pyephember import (
|
|||
)
|
||||
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 (
|
||||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_AUX_HEAT,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
|
@ -94,9 +96,9 @@ class EphEmberThermostat(ClimateEntity):
|
|||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
if self._hot_water:
|
||||
return SUPPORT_AUX_HEAT
|
||||
return ClimateEntityFeature.AUX_HEAT
|
||||
|
||||
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_AUX_HEAT
|
||||
return ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.AUX_HEAT
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -28,15 +28,9 @@ from epson_projector.const import (
|
|||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_STEP,
|
||||
from homeassistant.components.media_player import (
|
||||
MediaPlayerEntity,
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
@ -51,16 +45,6 @@ from .const import ATTR_CMODE, DOMAIN, SERVICE_SELECT_CMODE
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_EPSON = (
|
||||
SUPPORT_TURN_ON
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_VOLUME_STEP
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
@ -89,6 +73,16 @@ async def async_setup_entry(
|
|||
class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Representation of Epson Projector Device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
)
|
||||
|
||||
def __init__(self, projector, name, unique_id, entry):
|
||||
"""Initialize entity to control Epson projector."""
|
||||
self._projector = projector
|
||||
|
@ -178,11 +172,6 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
|||
"""Return if projector is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_EPSON
|
||||
|
||||
async def async_turn_on(self):
|
||||
"""Turn on epson."""
|
||||
if self._state == STATE_OFF:
|
||||
|
|
|
@ -7,7 +7,11 @@ from bluepy.btle import BTLEException # pylint: disable=import-error
|
|||
import eq3bt as eq3 # pylint: disable=import-error
|
||||
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 (
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
|
@ -15,8 +19,6 @@ from homeassistant.components.climate.const import (
|
|||
PRESET_AWAY,
|
||||
PRESET_BOOST,
|
||||
PRESET_NONE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
|
@ -83,8 +85,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||
{vol.Required(CONF_DEVICES): vol.Schema({cv.string: DEVICE_SCHEMA})}
|
||||
)
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
|
@ -105,6 +105,10 @@ def setup_platform(
|
|||
class EQ3BTSmartThermostat(ClimateEntity):
|
||||
"""Representation of an eQ-3 Bluetooth Smart thermostat."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
def __init__(self, _mac, _name):
|
||||
"""Initialize the thermostat."""
|
||||
# We want to avoid name clash with this module.
|
||||
|
@ -112,11 +116,6 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
|||
self._mac = _mac
|
||||
self._thermostat = eq3.Thermostat(_mac)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if thermostat is available."""
|
||||
|
@ -196,7 +195,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
|||
def preset_mode(self):
|
||||
"""Return the current preset mode, e.g., home, away, temp.
|
||||
|
||||
Requires SUPPORT_PRESET_MODE.
|
||||
Requires ClimateEntityFeature.PRESET_MODE.
|
||||
"""
|
||||
return EQ_TO_HA_PRESET.get(self._thermostat.mode)
|
||||
|
||||
|
@ -204,7 +203,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
|||
def preset_modes(self):
|
||||
"""Return a list of available preset modes.
|
||||
|
||||
Requires SUPPORT_PRESET_MODE.
|
||||
Requires ClimateEntityFeature.PRESET_MODE.
|
||||
"""
|
||||
return list(HA_TO_EQ_PRESET)
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ from homeassistant.components.light import (
|
|||
ATTR_HS_COLOR,
|
||||
COLOR_MODE_HS,
|
||||
PLATFORM_SCHEMA,
|
||||
SUPPORT_EFFECT,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -76,7 +76,7 @@ class EverLightsLight(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, api, channel, status, effects):
|
||||
"""Initialize the light."""
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import Any, cast
|
|||
from async_timeout import timeout
|
||||
|
||||
from homeassistant.components import light
|
||||
from homeassistant.components.light import LightEntity, LightEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -28,10 +29,10 @@ async def async_setup_entry(
|
|||
async_add_entities([EvilGeniusLight(coordinator)])
|
||||
|
||||
|
||||
class EvilGeniusLight(EvilGeniusEntity, light.LightEntity):
|
||||
class EvilGeniusLight(EvilGeniusEntity, LightEntity):
|
||||
"""Evil Genius Labs light."""
|
||||
|
||||
_attr_supported_features = light.SUPPORT_EFFECT
|
||||
_attr_supported_features = LightEntityFeature.EFFECT
|
||||
_attr_supported_color_modes = {light.COLOR_MODE_RGB}
|
||||
_attr_color_mode = light.COLOR_MODE_RGB
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from pyezviz.exceptions import HTTPError, InvalidHost, PyEzvizError
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import ffmpeg
|
||||
from homeassistant.components.camera import SUPPORT_STREAM, Camera
|
||||
from homeassistant.components.camera import Camera, CameraEntityFeature
|
||||
from homeassistant.components.ffmpeg import get_ffmpeg_manager
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_IGNORE,
|
||||
|
@ -194,19 +194,14 @@ class EzvizCamera(EzvizEntity, Camera):
|
|||
self._ffmpeg = get_ffmpeg_manager(hass)
|
||||
self._attr_unique_id = serial
|
||||
self._attr_name = self.data["name"]
|
||||
if camera_password:
|
||||
self._attr_supported_features = CameraEntityFeature.STREAM
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return self.data["status"] != 2
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return supported features."""
|
||||
if self._password:
|
||||
return SUPPORT_STREAM
|
||||
return 0
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if on."""
|
||||
|
|
Loading…
Add table
Reference in a new issue