Use EntityFeature enum in components (i**) (#69409)
parent
75eec850c1
commit
e6d8aa34fa
|
@ -1,8 +1,7 @@
|
|||
"""Interfaces with iAlarm control panels."""
|
||||
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
AlarmControlPanelEntity,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -24,6 +23,11 @@ async def async_setup_entry(
|
|||
class IAlarmPanel(CoordinatorEntity, AlarmControlPanelEntity):
|
||||
"""Representation of an iAlarm device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info for this device."""
|
||||
|
@ -48,11 +52,6 @@ class IAlarmPanel(CoordinatorEntity, AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
return self.coordinator.state
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
"""Send disarm command."""
|
||||
self.coordinator.ialarm.disarm()
|
||||
|
|
|
@ -11,13 +11,8 @@ from iaqualink.const import (
|
|||
)
|
||||
from iaqualink.device import AqualinkHeater, AqualinkPump, AqualinkSensor, AqualinkState
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
DOMAIN,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import DOMAIN, HVAC_MODE_HEAT, HVAC_MODE_OFF
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -47,16 +42,13 @@ async def async_setup_entry(
|
|||
class HassAqualinkThermostat(AqualinkEntity, ClimateEntity):
|
||||
"""Representation of a thermostat."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the thermostat."""
|
||||
return self.dev.label.split(" ")[0]
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> list[str]:
|
||||
"""Return the list of supported HVAC modes."""
|
||||
|
|
|
@ -7,8 +7,8 @@ from homeassistant.components.light import (
|
|||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_ONOFF,
|
||||
DOMAIN,
|
||||
SUPPORT_EFFECT,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -102,6 +102,6 @@ class HassAqualinkLight(AqualinkEntity, LightEntity):
|
|||
def supported_features(self) -> int:
|
||||
"""Return the list of features supported by the light."""
|
||||
if self.dev.is_color:
|
||||
return SUPPORT_EFFECT
|
||||
return LightEntityFeature.EFFECT
|
||||
|
||||
return 0
|
||||
|
|
|
@ -11,11 +11,7 @@ from homeassistant.components.alarm_control_panel import (
|
|||
FORMAT_TEXT,
|
||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||
AlarmControlPanelEntity,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
AlarmControlPanelEntityFeature,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -132,6 +128,12 @@ def setup_platform(
|
|||
class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
||||
"""Representation of an alarm control panel controlled through IFTTT."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||
)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name,
|
||||
|
@ -164,11 +166,6 @@ class IFTTTAlarmPanel(AlarmControlPanelEntity):
|
|||
"""Return the state of the device."""
|
||||
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 assumed_state(self):
|
||||
"""Notify that this platform return an assumed state."""
|
||||
|
|
|
@ -15,8 +15,8 @@ from homeassistant.components.light import (
|
|||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
PLATFORM_SCHEMA,
|
||||
SUPPORT_EFFECT,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -54,7 +54,7 @@ class IGloLamp(LightEntity):
|
|||
"""Representation of an iGlo light."""
|
||||
|
||||
_attr_supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}
|
||||
_attr_supported_features = SUPPORT_EFFECT
|
||||
_attr_supported_features = LightEntityFeature.EFFECT
|
||||
|
||||
def __init__(self, name, host, port):
|
||||
"""Initialize the light."""
|
||||
|
|
|
@ -3,11 +3,12 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN, ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_HEAT,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
from homeassistant.components.climate import (
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate.const import HVAC_MODE_HEAT
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -37,6 +38,8 @@ async def async_setup_platform(
|
|||
class InComfortClimate(IncomfortChild, ClimateEntity):
|
||||
"""Representation of an InComfort/InTouch climate device."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def __init__(self, client, heater, room) -> None:
|
||||
"""Initialize the climate device."""
|
||||
super().__init__()
|
||||
|
@ -78,11 +81,6 @@ class InComfortClimate(IncomfortChild, ClimateEntity):
|
|||
"""Return the temperature we try to reach."""
|
||||
return self._room.setpoint
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def min_temp(self) -> float:
|
||||
"""Return max valid temperature that can be set."""
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from pyinsteon.constants import ThermostatMode
|
||||
from pyinsteon.operating_flag import CELSIUS
|
||||
|
||||
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,
|
||||
|
@ -19,10 +19,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_HEAT_COOL,
|
||||
HVAC_MODE_OFF,
|
||||
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, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
@ -56,12 +52,6 @@ HVAC_MODES = {
|
|||
3: HVAC_MODE_HEAT_COOL,
|
||||
}
|
||||
FAN_MODES = {4: HVAC_MODE_AUTO, 8: HVAC_MODE_FAN_ONLY}
|
||||
SUPPORTED_FEATURES = (
|
||||
SUPPORT_FAN_MODE
|
||||
| SUPPORT_TARGET_HUMIDITY
|
||||
| SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -90,10 +80,12 @@ async def async_setup_entry(
|
|||
class InsteonClimateEntity(InsteonEntity, ClimateEntity):
|
||||
"""A Class for an Insteon climate entity."""
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the supported features for this entity."""
|
||||
return SUPPORTED_FEATURES
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.TARGET_HUMIDITY
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
|
|
|
@ -4,10 +4,8 @@ import math
|
|||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -18,8 +16,6 @@ from .const import SIGNAL_ADD_ENTITIES
|
|||
from .insteon_entity import InsteonEntity
|
||||
from .utils import async_add_insteon_entities
|
||||
|
||||
SUPPORTED_FEATURES = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
@ -43,6 +39,12 @@ async def async_setup_entry(
|
|||
class InsteonCoverEntity(InsteonEntity, CoverEntity):
|
||||
"""A Class for an Insteon cover entity."""
|
||||
|
||||
_attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
|
||||
@property
|
||||
def current_cover_position(self):
|
||||
"""Return the current cover position."""
|
||||
|
@ -52,11 +54,6 @@ class InsteonCoverEntity(InsteonEntity, CoverEntity):
|
|||
pos = 0
|
||||
return int(math.ceil(pos * 100 / 255))
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the supported features for this entity."""
|
||||
return SUPPORTED_FEATURES
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
"""Return the boolean response if the node is on."""
|
||||
|
|
|
@ -5,8 +5,8 @@ import math
|
|||
|
||||
from homeassistant.components.fan import (
|
||||
DOMAIN as FAN_DOMAIN,
|
||||
SUPPORT_SET_SPEED,
|
||||
FanEntity,
|
||||
FanEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -46,6 +46,8 @@ async def async_setup_entry(
|
|||
class InsteonFanEntity(InsteonEntity, FanEntity):
|
||||
"""An INSTEON fan entity."""
|
||||
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
@property
|
||||
def percentage(self) -> int | None:
|
||||
"""Return the current speed percentage."""
|
||||
|
@ -53,11 +55,6 @@ class InsteonFanEntity(InsteonEntity, FanEntity):
|
|||
return None
|
||||
return ranged_value_to_percentage(SPEED_RANGE, self._insteon_device_group.value)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_SET_SPEED
|
||||
|
||||
@property
|
||||
def speed_count(self) -> int:
|
||||
"""Flag supported features."""
|
||||
|
|
|
@ -8,7 +8,11 @@ from typing import NamedTuple
|
|||
from pyintesishome import IHAuthenticationError, IHConnectionError, IntesisHome
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
|
||||
from homeassistant.components.climate import (
|
||||
PLATFORM_SCHEMA,
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
)
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_HVAC_MODE,
|
||||
HVAC_MODE_COOL,
|
||||
|
@ -20,10 +24,6 @@ from homeassistant.components.climate.const import (
|
|||
PRESET_BOOST,
|
||||
PRESET_COMFORT,
|
||||
PRESET_ECO,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_SWING_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SWING_BOTH,
|
||||
SWING_HORIZONTAL,
|
||||
SWING_OFF,
|
||||
|
@ -175,13 +175,13 @@ class IntesisAC(ClimateEntity):
|
|||
self._hvane = None
|
||||
self._power = False
|
||||
self._fan_speed = None
|
||||
self._support = 0
|
||||
self._attr_supported_features = 0
|
||||
self._power_consumption_heat = None
|
||||
self._power_consumption_cool = None
|
||||
|
||||
# Setpoint support
|
||||
if controller.has_setpoint_control(ih_device_id):
|
||||
self._support |= SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
# Setup swing list
|
||||
if controller.has_vertical_swing(ih_device_id):
|
||||
|
@ -191,16 +191,16 @@ class IntesisAC(ClimateEntity):
|
|||
if SWING_HORIZONTAL in self._swing_list and SWING_VERTICAL in self._swing_list:
|
||||
self._swing_list.append(SWING_BOTH)
|
||||
if len(self._swing_list) > 1:
|
||||
self._support |= SUPPORT_SWING_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
|
||||
|
||||
# Setup fan speeds
|
||||
self._fan_modes = controller.get_fan_speed_list(ih_device_id)
|
||||
if self._fan_modes:
|
||||
self._support |= SUPPORT_FAN_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||
|
||||
# Preset support
|
||||
if ih_device.get("climate_working_mode"):
|
||||
self._support |= SUPPORT_PRESET_MODE
|
||||
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
# Setup HVAC modes
|
||||
if modes := controller.get_mode_list(ih_device_id):
|
||||
|
@ -476,8 +476,3 @@ class IntesisAC(ClimateEntity):
|
|||
def target_temperature(self):
|
||||
"""Return the current setpoint temperature if unit is on."""
|
||||
return self._target_temp
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return self._support
|
||||
|
|
|
@ -15,7 +15,7 @@ from pyisy.constants import (
|
|||
)
|
||||
from pyisy.nodes import Node
|
||||
|
||||
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,
|
||||
|
@ -26,9 +26,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -59,10 +56,6 @@ from .const import (
|
|||
from .entity import ISYNodeEntity
|
||||
from .helpers import convert_isy_value_to_hass, migrate_old_unique_ids
|
||||
|
||||
ISY_SUPPORTED_FEATURES = (
|
||||
SUPPORT_FAN_MODE | SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
|
@ -81,6 +74,12 @@ async def async_setup_entry(
|
|||
class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
||||
"""Representation of an ISY994 thermostat entity."""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.FAN_MODE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
def __init__(self, node: Node) -> None:
|
||||
"""Initialize the ISY Thermostat entity."""
|
||||
super().__init__(node)
|
||||
|
@ -95,11 +94,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
|
|||
self._target_temp_low = 0
|
||||
self._target_temp_high = 0
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return ISY_SUPPORTED_FEATURES
|
||||
|
||||
@property
|
||||
def precision(self) -> float:
|
||||
"""Return the precision of the system."""
|
||||
|
|
|
@ -8,10 +8,8 @@ from pyisy.constants import ISY_VALUE_UNKNOWN
|
|||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
DOMAIN as COVER,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -48,6 +46,12 @@ async def async_setup_entry(
|
|||
class ISYCoverEntity(ISYNodeEntity, CoverEntity):
|
||||
"""Representation of an ISY994 cover device."""
|
||||
|
||||
_attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> int | None:
|
||||
"""Return the current cover position."""
|
||||
|
@ -64,11 +68,6 @@ class ISYCoverEntity(ISYNodeEntity, CoverEntity):
|
|||
return None
|
||||
return bool(self._node.status == 0)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
||||
|
||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||
"""Send the open cover command to the ISY994 cover device."""
|
||||
val = 100 if self._node.uom == UOM_BARRIER else None
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any
|
|||
|
||||
from pyisy.constants import ISY_VALUE_UNKNOWN, PROTO_INSTEON
|
||||
|
||||
from homeassistant.components.fan import DOMAIN as FAN, SUPPORT_SET_SPEED, FanEntity
|
||||
from homeassistant.components.fan import DOMAIN as FAN, FanEntity, FanEntityFeature
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -43,6 +43,8 @@ async def async_setup_entry(
|
|||
class ISYFanEntity(ISYNodeEntity, FanEntity):
|
||||
"""Representation of an ISY994 fan device."""
|
||||
|
||||
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
|
||||
@property
|
||||
def percentage(self) -> int | None:
|
||||
"""Return the current speed percentage."""
|
||||
|
@ -87,11 +89,6 @@ class ISYFanEntity(ISYNodeEntity, FanEntity):
|
|||
"""Send the turn off command to the ISY994 fan device."""
|
||||
await self._node.turn_off()
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_SET_SPEED
|
||||
|
||||
|
||||
class ISYFanProgramEntity(ISYProgramEntity, FanEntity):
|
||||
"""Representation of an ISY994 fan program."""
|
||||
|
|
|
@ -4,21 +4,14 @@ from __future__ import annotations
|
|||
import requests
|
||||
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_MUSIC,
|
||||
MEDIA_TYPE_PLAYLIST,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
SUPPORT_PLAY_MEDIA,
|
||||
SUPPORT_PREVIOUS_TRACK,
|
||||
SUPPORT_SEEK,
|
||||
SUPPORT_SHUFFLE_SET,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
SUPPORT_VOLUME_MUTE,
|
||||
SUPPORT_VOLUME_SET,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -42,20 +35,6 @@ DEFAULT_SSL = False
|
|||
DEFAULT_TIMEOUT = 10
|
||||
DOMAIN = "itunes"
|
||||
|
||||
SUPPORT_ITUNES = (
|
||||
SUPPORT_PAUSE
|
||||
| SUPPORT_VOLUME_SET
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_PREVIOUS_TRACK
|
||||
| SUPPORT_NEXT_TRACK
|
||||
| SUPPORT_SEEK
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_TURN_OFF
|
||||
| SUPPORT_SHUFFLE_SET
|
||||
)
|
||||
|
||||
SUPPORT_AIRPLAY = SUPPORT_VOLUME_SET | SUPPORT_TURN_ON | SUPPORT_TURN_OFF
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
|
@ -214,6 +193,19 @@ def setup_platform(
|
|||
class ItunesDevice(MediaPlayerEntity):
|
||||
"""Representation of an iTunes API instance."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.PAUSE
|
||||
| MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.VOLUME_MUTE
|
||||
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||
| MediaPlayerEntityFeature.SEEK
|
||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
||||
| MediaPlayerEntityFeature.PLAY
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
| MediaPlayerEntityFeature.SHUFFLE_SET
|
||||
)
|
||||
|
||||
def __init__(self, name, host, port, use_ssl, add_entities):
|
||||
"""Initialize the iTunes device."""
|
||||
self._name = name
|
||||
|
@ -362,11 +354,6 @@ class ItunesDevice(MediaPlayerEntity):
|
|||
"""Boolean if shuffle is enabled."""
|
||||
return self.shuffled
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_ITUNES
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
response = self.client.set_volume(int(volume * 100))
|
||||
|
@ -417,6 +404,12 @@ class ItunesDevice(MediaPlayerEntity):
|
|||
class AirPlayDevice(MediaPlayerEntity):
|
||||
"""Representation an AirPlay device via an iTunes API instance."""
|
||||
|
||||
_attr_supported_features = (
|
||||
MediaPlayerEntityFeature.VOLUME_SET
|
||||
| MediaPlayerEntityFeature.TURN_ON
|
||||
| MediaPlayerEntityFeature.TURN_OFF
|
||||
)
|
||||
|
||||
def __init__(self, device_id, client):
|
||||
"""Initialize the AirPlay device."""
|
||||
self._id = device_id
|
||||
|
@ -491,11 +484,6 @@ class AirPlayDevice(MediaPlayerEntity):
|
|||
"""Flag of media content that is supported."""
|
||||
return MEDIA_TYPE_MUSIC
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag media player features that are supported."""
|
||||
return SUPPORT_AIRPLAY
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
volume = int(volume * 100)
|
||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
|||
from pizone import Controller, Zone
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
FAN_AUTO,
|
||||
FAN_HIGH,
|
||||
|
@ -21,9 +21,6 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_OFF,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
|
@ -139,14 +136,14 @@ class ControllerDevice(ClimateEntity):
|
|||
"""Initialise ControllerDevice."""
|
||||
self._controller = controller
|
||||
|
||||
self._supported_features = SUPPORT_FAN_MODE
|
||||
self._supported_features = ClimateEntityFeature.FAN_MODE
|
||||
|
||||
# If mode RAS, or mode master with CtrlZone 13 then can set master temperature,
|
||||
# otherwise the unit determines which zone to use as target. See interface manual p. 8
|
||||
if (
|
||||
controller.ras_mode == "master" and controller.zone_ctrl == 13
|
||||
) or controller.ras_mode == "RAS":
|
||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE
|
||||
self._supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
self._state_to_pizone = {
|
||||
HVAC_MODE_COOL: Controller.Mode.COOL,
|
||||
|
@ -156,7 +153,7 @@ class ControllerDevice(ClimateEntity):
|
|||
HVAC_MODE_DRY: Controller.Mode.DRY,
|
||||
}
|
||||
if controller.free_air_enabled:
|
||||
self._supported_features |= SUPPORT_PRESET_MODE
|
||||
self._supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||
|
||||
self._fan_to_pizone = {}
|
||||
for fan in controller.fan_modes:
|
||||
|
@ -300,7 +297,7 @@ class ControllerDevice(ClimateEntity):
|
|||
),
|
||||
"control_zone": self._controller.zone_ctrl,
|
||||
"control_zone_name": self.control_zone_name,
|
||||
# Feature SUPPORT_TARGET_TEMPERATURE controls both displaying target temp & setting it
|
||||
# Feature ClimateEntityFeature.TARGET_TEMPERATURE controls both displaying target temp & setting it
|
||||
# As the feature is turned off for zone control, report target temp as extra state attribute
|
||||
"control_zone_setpoint": show_temp(
|
||||
self.hass,
|
||||
|
@ -355,7 +352,7 @@ class ControllerDevice(ClimateEntity):
|
|||
@property
|
||||
def control_zone_name(self):
|
||||
"""Return the zone that currently controls the AC unit (if target temp not set by controller)."""
|
||||
if self._supported_features & SUPPORT_TARGET_TEMPERATURE:
|
||||
if self._supported_features & ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
return None
|
||||
zone_ctrl = self._controller.zone_ctrl
|
||||
zone = next((z for z in self.zones.values() if z.zone_index == zone_ctrl), None)
|
||||
|
@ -366,7 +363,7 @@ class ControllerDevice(ClimateEntity):
|
|||
@property
|
||||
def control_zone_setpoint(self) -> float | None:
|
||||
"""Return the temperature setpoint of the zone that currently controls the AC unit (if target temp not set by controller)."""
|
||||
if self._supported_features & SUPPORT_TARGET_TEMPERATURE:
|
||||
if self._supported_features & ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
return None
|
||||
zone_ctrl = self._controller.zone_ctrl
|
||||
zone = next((z for z in self.zones.values() if z.zone_index == zone_ctrl), None)
|
||||
|
@ -378,7 +375,7 @@ class ControllerDevice(ClimateEntity):
|
|||
@_return_on_connection_error()
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature we try to reach (either from control zone or master unit)."""
|
||||
if self._supported_features & SUPPORT_TARGET_TEMPERATURE:
|
||||
if self._supported_features & ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
return self._controller.temp_setpoint
|
||||
return self.control_zone_setpoint
|
||||
|
||||
|
@ -425,7 +422,7 @@ class ControllerDevice(ClimateEntity):
|
|||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
"""Set new target temperature."""
|
||||
if not self.supported_features & SUPPORT_TARGET_TEMPERATURE:
|
||||
if not self.supported_features & ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
self.async_schedule_update_ha_state(True)
|
||||
return
|
||||
if (temp := kwargs.get(ATTR_TEMPERATURE)) is not None:
|
||||
|
@ -480,7 +477,7 @@ class ZoneDevice(ClimateEntity):
|
|||
HVAC_MODE_FAN_ONLY: Zone.Mode.OPEN,
|
||||
HVAC_MODE_HEAT_COOL: Zone.Mode.AUTO,
|
||||
}
|
||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE
|
||||
self._supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(IZONE, controller.unique_id, zone.index)},
|
||||
|
@ -551,7 +548,7 @@ class ZoneDevice(ClimateEntity):
|
|||
"""Return the list of supported features."""
|
||||
if self._zone.mode == Zone.Mode.AUTO:
|
||||
return self._supported_features
|
||||
return self._supported_features & ~SUPPORT_TARGET_TEMPERATURE
|
||||
return self._supported_features & ~ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
|
|
Loading…
Reference in New Issue