Use EntityFeature enum in components (z**) (#69471)
* Use EntityFeature enum in zha * Use EntityFeature enum in zhong_hong * Use EntityFeature enum in ziggo_mediabox_xl * Use EntityFeature enum in zwave_js * Use EntityFeature enum in zwave_me
This commit is contained in:
parent
aaf64f728e
commit
fbea950eb0
10 changed files with 76 additions and 121 deletions
|
@ -5,11 +5,8 @@ from zigpy.zcl.clusters.security import IasAce
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import (
|
||||||
FORMAT_TEXT,
|
FORMAT_TEXT,
|
||||||
SUPPORT_ALARM_ARM_AWAY,
|
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
|
||||||
SUPPORT_ALARM_ARM_NIGHT,
|
|
||||||
SUPPORT_ALARM_TRIGGER,
|
|
||||||
AlarmControlPanelEntity,
|
AlarmControlPanelEntity,
|
||||||
|
AlarmControlPanelEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -79,6 +76,13 @@ async def async_setup_entry(
|
||||||
class ZHAAlarmControlPanel(ZhaEntity, AlarmControlPanelEntity):
|
class ZHAAlarmControlPanel(ZhaEntity, AlarmControlPanelEntity):
|
||||||
"""Entity for ZHA alarm control devices."""
|
"""Entity for ZHA alarm control devices."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
AlarmControlPanelEntityFeature.ARM_HOME
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||||
|
| AlarmControlPanelEntityFeature.ARM_NIGHT
|
||||||
|
| AlarmControlPanelEntityFeature.TRIGGER
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, unique_id, zha_device: ZhaDeviceType, channels, **kwargs):
|
def __init__(self, unique_id, zha_device: ZhaDeviceType, channels, **kwargs):
|
||||||
"""Initialize the ZHA alarm control device."""
|
"""Initialize the ZHA alarm control device."""
|
||||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||||
|
@ -148,16 +152,6 @@ class ZHAAlarmControlPanel(ZhaEntity, AlarmControlPanelEntity):
|
||||||
"""Send alarm trigger command."""
|
"""Send alarm trigger command."""
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_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
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
|
|
@ -12,7 +12,7 @@ from random import randint
|
||||||
|
|
||||||
from zigpy.zcl.clusters.hvac import Fan as F, Thermostat as T
|
from zigpy.zcl.clusters.hvac import Fan as F, Thermostat as T
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity
|
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
ATTR_HVAC_MODE,
|
ATTR_HVAC_MODE,
|
||||||
ATTR_TARGET_TEMP_HIGH,
|
ATTR_TARGET_TEMP_HIGH,
|
||||||
|
@ -35,10 +35,6 @@ from homeassistant.components.climate.const import (
|
||||||
PRESET_COMFORT,
|
PRESET_COMFORT,
|
||||||
PRESET_ECO,
|
PRESET_ECO,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
SUPPORT_FAN_MODE,
|
|
||||||
SUPPORT_PRESET_MODE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -155,7 +151,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
||||||
self._thrm = self.cluster_channels.get(CHANNEL_THERMOSTAT)
|
self._thrm = self.cluster_channels.get(CHANNEL_THERMOSTAT)
|
||||||
self._preset = PRESET_NONE
|
self._preset = PRESET_NONE
|
||||||
self._presets = []
|
self._presets = []
|
||||||
self._supported_flags = SUPPORT_TARGET_TEMPERATURE
|
self._supported_flags = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
self._fan = self.cluster_channels.get(CHANNEL_FAN)
|
self._fan = self.cluster_channels.get(CHANNEL_FAN)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -294,9 +290,9 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
||||||
"""Return the list of supported features."""
|
"""Return the list of supported features."""
|
||||||
features = self._supported_flags
|
features = self._supported_flags
|
||||||
if HVAC_MODE_HEAT_COOL in self.hvac_modes:
|
if HVAC_MODE_HEAT_COOL in self.hvac_modes:
|
||||||
features |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
features |= ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
if self._fan is not None:
|
if self._fan is not None:
|
||||||
self._supported_flags |= SUPPORT_FAN_MODE
|
self._supported_flags |= ClimateEntityFeature.FAN_MODE
|
||||||
return features
|
return features
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -513,7 +509,7 @@ class SinopeTechnologiesThermostat(Thermostat):
|
||||||
"""Initialize ZHA Thermostat instance."""
|
"""Initialize ZHA Thermostat instance."""
|
||||||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||||
self._presets = [PRESET_AWAY, PRESET_NONE]
|
self._presets = [PRESET_AWAY, PRESET_NONE]
|
||||||
self._supported_flags |= SUPPORT_PRESET_MODE
|
self._supported_flags |= ClimateEntityFeature.PRESET_MODE
|
||||||
self._manufacturer_ch = self.cluster_channels["sinope_manufacturer_specific"]
|
self._manufacturer_ch = self.cluster_channels["sinope_manufacturer_specific"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -624,7 +620,7 @@ class MoesThermostat(Thermostat):
|
||||||
PRESET_BOOST,
|
PRESET_BOOST,
|
||||||
PRESET_COMPLEX,
|
PRESET_COMPLEX,
|
||||||
]
|
]
|
||||||
self._supported_flags |= SUPPORT_PRESET_MODE
|
self._supported_flags |= ClimateEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self) -> tuple[str, ...]:
|
def hvac_modes(self) -> tuple[str, ...]:
|
||||||
|
@ -705,7 +701,7 @@ class BecaThermostat(Thermostat):
|
||||||
PRESET_BOOST,
|
PRESET_BOOST,
|
||||||
PRESET_TEMP_MANUAL,
|
PRESET_TEMP_MANUAL,
|
||||||
]
|
]
|
||||||
self._supported_flags |= SUPPORT_PRESET_MODE
|
self._supported_flags |= ClimateEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self) -> tuple[str, ...]:
|
def hvac_modes(self) -> tuple[str, ...]:
|
||||||
|
@ -804,7 +800,7 @@ class ZONNSMARTThermostat(Thermostat):
|
||||||
PRESET_SCHEDULE,
|
PRESET_SCHEDULE,
|
||||||
self.PRESET_FROST,
|
self.PRESET_FROST,
|
||||||
]
|
]
|
||||||
self._supported_flags |= SUPPORT_PRESET_MODE
|
self._supported_flags |= ClimateEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
async def async_attribute_updated(self, record):
|
async def async_attribute_updated(self, record):
|
||||||
"""Handle attribute update from device."""
|
"""Handle attribute update from device."""
|
||||||
|
|
|
@ -11,8 +11,8 @@ from zigpy.zcl.clusters import hvac
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
ATTR_PERCENTAGE,
|
ATTR_PERCENTAGE,
|
||||||
ATTR_PRESET_MODE,
|
ATTR_PRESET_MODE,
|
||||||
SUPPORT_SET_SPEED,
|
|
||||||
FanEntity,
|
FanEntity,
|
||||||
|
FanEntityFeature,
|
||||||
NotValidPresetModeError,
|
NotValidPresetModeError,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -76,16 +76,13 @@ async def async_setup_entry(
|
||||||
class BaseFan(FanEntity):
|
class BaseFan(FanEntity):
|
||||||
"""Base representation of a ZHA fan."""
|
"""Base representation of a ZHA fan."""
|
||||||
|
|
||||||
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self) -> list[str]:
|
def preset_modes(self) -> list[str]:
|
||||||
"""Return the available preset modes."""
|
"""Return the available preset modes."""
|
||||||
return PRESET_MODES
|
return PRESET_MODES
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_SET_SPEED
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_count(self) -> int:
|
def speed_count(self) -> int:
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
|
|
|
@ -7,7 +7,11 @@ import voluptuous as vol
|
||||||
from zhong_hong_hvac.hub import ZhongHongGateway
|
from zhong_hong_hvac.hub import ZhongHongGateway
|
||||||
from zhong_hong_hvac.hvac import HVAC as ZhongHongHVAC
|
from zhong_hong_hvac.hvac import HVAC as ZhongHongHVAC
|
||||||
|
|
||||||
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_HVAC_MODE,
|
ATTR_HVAC_MODE,
|
||||||
HVAC_MODE_COOL,
|
HVAC_MODE_COOL,
|
||||||
|
@ -15,8 +19,6 @@ from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_FAN_ONLY,
|
HVAC_MODE_FAN_ONLY,
|
||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
SUPPORT_FAN_MODE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_TEMPERATURE,
|
ATTR_TEMPERATURE,
|
||||||
|
@ -130,6 +132,10 @@ def setup_platform(
|
||||||
class ZhongHongClimate(ClimateEntity):
|
class ZhongHongClimate(ClimateEntity):
|
||||||
"""Representation of a ZhongHong controller support HVAC."""
|
"""Representation of a ZhongHong controller support HVAC."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, hub, addr_out, addr_in):
|
def __init__(self, hub, addr_out, addr_in):
|
||||||
"""Set up the ZhongHong climate devices."""
|
"""Set up the ZhongHong climate devices."""
|
||||||
|
|
||||||
|
@ -177,11 +183,6 @@ class ZhongHongClimate(ClimateEntity):
|
||||||
"""Return the unique ID of the HVAC."""
|
"""Return the unique ID of the HVAC."""
|
||||||
return f"zhong_hong_hvac_{self._device.addr_out}_{self._device.addr_in}"
|
return f"zhong_hong_hvac_{self._device.addr_out}_{self._device.addr_in}"
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_unit(self):
|
def temperature_unit(self):
|
||||||
"""Return the unit of measurement used by the platform."""
|
"""Return the unit of measurement used by the platform."""
|
||||||
|
|
|
@ -7,15 +7,10 @@ import socket
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from ziggo_mediabox_xl import ZiggoMediaboxXL
|
from ziggo_mediabox_xl import ZiggoMediaboxXL
|
||||||
|
|
||||||
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_TURN_OFF,
|
|
||||||
SUPPORT_TURN_ON,
|
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
|
@ -33,16 +28,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DATA_KNOWN_DEVICES = "ziggo_mediabox_xl_known_devices"
|
DATA_KNOWN_DEVICES = "ziggo_mediabox_xl_known_devices"
|
||||||
|
|
||||||
SUPPORT_ZIGGO = (
|
|
||||||
SUPPORT_TURN_ON
|
|
||||||
| SUPPORT_TURN_OFF
|
|
||||||
| SUPPORT_NEXT_TRACK
|
|
||||||
| SUPPORT_PAUSE
|
|
||||||
| SUPPORT_PREVIOUS_TRACK
|
|
||||||
| SUPPORT_SELECT_SOURCE
|
|
||||||
| SUPPORT_PLAY
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_NAME): cv.string}
|
{vol.Required(CONF_HOST): cv.string, vol.Optional(CONF_NAME): cv.string}
|
||||||
)
|
)
|
||||||
|
@ -104,6 +89,16 @@ def setup_platform(
|
||||||
class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
||||||
"""Representation of a Ziggo Mediabox XL Device."""
|
"""Representation of a Ziggo Mediabox XL Device."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
MediaPlayerEntityFeature.TURN_ON
|
||||||
|
| MediaPlayerEntityFeature.TURN_OFF
|
||||||
|
| MediaPlayerEntityFeature.NEXT_TRACK
|
||||||
|
| MediaPlayerEntityFeature.PAUSE
|
||||||
|
| MediaPlayerEntityFeature.PREVIOUS_TRACK
|
||||||
|
| MediaPlayerEntityFeature.SELECT_SOURCE
|
||||||
|
| MediaPlayerEntityFeature.PLAY
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, mediabox, host, name, available):
|
def __init__(self, mediabox, host, name, available):
|
||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
self._mediabox = mediabox
|
self._mediabox = mediabox
|
||||||
|
@ -158,11 +153,6 @@ class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
||||||
for c in sorted(self._mediabox.channels().keys())
|
for c in sorted(self._mediabox.channels().keys())
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag media player features that are supported."""
|
|
||||||
return SUPPORT_ZIGGO
|
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self):
|
||||||
"""Turn the media player on."""
|
"""Turn the media player on."""
|
||||||
self.send_keys(["POWER"])
|
self.send_keys(["POWER"])
|
||||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.components.climate import (
|
||||||
DEFAULT_MAX_TEMP,
|
DEFAULT_MAX_TEMP,
|
||||||
DEFAULT_MIN_TEMP,
|
DEFAULT_MIN_TEMP,
|
||||||
ClimateEntity,
|
ClimateEntity,
|
||||||
|
ClimateEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
ATTR_HVAC_MODE,
|
ATTR_HVAC_MODE,
|
||||||
|
@ -40,10 +41,6 @@ from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_HEAT_COOL,
|
HVAC_MODE_HEAT_COOL,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
SUPPORT_FAN_MODE,
|
|
||||||
SUPPORT_PRESET_MODE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -193,17 +190,19 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||||
check_all_endpoints=True,
|
check_all_endpoints=True,
|
||||||
)
|
)
|
||||||
self._set_modes_and_presets()
|
self._set_modes_and_presets()
|
||||||
self._supported_features = 0
|
self._attr_supported_features = 0
|
||||||
if len(self._hvac_presets) > 1:
|
if len(self._hvac_presets) > 1:
|
||||||
self._supported_features |= SUPPORT_PRESET_MODE
|
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
|
||||||
# If any setpoint value exists, we can assume temperature
|
# If any setpoint value exists, we can assume temperature
|
||||||
# can be set
|
# can be set
|
||||||
if any(self._setpoint_values.values()):
|
if any(self._setpoint_values.values()):
|
||||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE
|
self._attr_supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
if HVAC_MODE_HEAT_COOL in self.hvac_modes:
|
if HVAC_MODE_HEAT_COOL in self.hvac_modes:
|
||||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
self._attr_supported_features |= (
|
||||||
|
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||||
|
)
|
||||||
if self._fan_mode:
|
if self._fan_mode:
|
||||||
self._supported_features |= SUPPORT_FAN_MODE
|
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||||
|
|
||||||
def _setpoint_value(self, setpoint_type: ThermostatSetpointType) -> ZwaveValue:
|
def _setpoint_value(self, setpoint_type: ThermostatSetpointType) -> ZwaveValue:
|
||||||
"""Optionally return a ZwaveValue for a setpoint."""
|
"""Optionally return a ZwaveValue for a setpoint."""
|
||||||
|
@ -382,11 +381,6 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return self._supported_features
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_temp(self) -> float:
|
def min_temp(self) -> float:
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
|
|
|
@ -21,15 +21,9 @@ from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
ATTR_TILT_POSITION,
|
ATTR_TILT_POSITION,
|
||||||
DOMAIN as COVER_DOMAIN,
|
DOMAIN as COVER_DOMAIN,
|
||||||
SUPPORT_CLOSE,
|
|
||||||
SUPPORT_CLOSE_TILT,
|
|
||||||
SUPPORT_OPEN,
|
|
||||||
SUPPORT_OPEN_TILT,
|
|
||||||
SUPPORT_SET_POSITION,
|
|
||||||
SUPPORT_SET_TILT_POSITION,
|
|
||||||
SUPPORT_STOP,
|
|
||||||
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
|
||||||
|
@ -180,13 +174,13 @@ class ZWaveTiltCover(ZWaveCover):
|
||||||
"""Representation of a Z-Wave Cover device with tilt."""
|
"""Representation of a Z-Wave Cover device with tilt."""
|
||||||
|
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
SUPPORT_OPEN
|
CoverEntityFeature.OPEN
|
||||||
| SUPPORT_CLOSE
|
| CoverEntityFeature.CLOSE
|
||||||
| SUPPORT_STOP
|
| CoverEntityFeature.STOP
|
||||||
| SUPPORT_SET_POSITION
|
| CoverEntityFeature.SET_POSITION
|
||||||
| SUPPORT_OPEN_TILT
|
| CoverEntityFeature.OPEN_TILT
|
||||||
| SUPPORT_CLOSE_TILT
|
| CoverEntityFeature.CLOSE_TILT
|
||||||
| SUPPORT_SET_TILT_POSITION
|
| CoverEntityFeature.SET_TILT_POSITION
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -231,7 +225,7 @@ class ZWaveTiltCover(ZWaveCover):
|
||||||
class ZwaveMotorizedBarrier(ZWaveBaseEntity, CoverEntity):
|
class ZwaveMotorizedBarrier(ZWaveBaseEntity, CoverEntity):
|
||||||
"""Representation of a Z-Wave motorized barrier device."""
|
"""Representation of a Z-Wave motorized barrier device."""
|
||||||
|
|
||||||
_attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
|
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||||
_attr_device_class = CoverDeviceClass.GARAGE
|
_attr_device_class = CoverDeviceClass.GARAGE
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -14,9 +14,8 @@ from zwave_js_server.model.value import Value as ZwaveValue
|
||||||
|
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
DOMAIN as FAN_DOMAIN,
|
DOMAIN as FAN_DOMAIN,
|
||||||
SUPPORT_PRESET_MODE,
|
|
||||||
SUPPORT_SET_SPEED,
|
|
||||||
FanEntity,
|
FanEntity,
|
||||||
|
FanEntityFeature,
|
||||||
NotValidPresetModeError,
|
NotValidPresetModeError,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -74,6 +73,8 @@ async def async_setup_entry(
|
||||||
class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
||||||
"""Representation of a Z-Wave fan."""
|
"""Representation of a Z-Wave fan."""
|
||||||
|
|
||||||
|
_attr_supported_features = FanEntityFeature.SET_SPEED
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config_entry: ConfigEntry, client: ZwaveClient, info: ZwaveDiscoveryInfo
|
self, config_entry: ConfigEntry, client: ZwaveClient, info: ZwaveDiscoveryInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -139,11 +140,6 @@ class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
||||||
"""Return the number of speeds the fan supports."""
|
"""Return the number of speeds the fan supports."""
|
||||||
return int_states_in_range(DEFAULT_SPEED_RANGE)
|
return int_states_in_range(DEFAULT_SPEED_RANGE)
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
return SUPPORT_SET_SPEED
|
|
||||||
|
|
||||||
|
|
||||||
class ValueMappingZwaveFan(ZwaveFan):
|
class ValueMappingZwaveFan(ZwaveFan):
|
||||||
"""A Zwave fan with a value mapping data (e.g., 1-24 is low)."""
|
"""A Zwave fan with a value mapping data (e.g., 1-24 is low)."""
|
||||||
|
@ -239,9 +235,9 @@ class ValueMappingZwaveFan(ZwaveFan):
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
flags = SUPPORT_SET_SPEED
|
flags: int = FanEntityFeature.SET_SPEED
|
||||||
if self.has_fan_value_mapping and self.fan_value_mapping.presets:
|
if self.has_fan_value_mapping and self.fan_value_mapping.presets:
|
||||||
flags |= SUPPORT_PRESET_MODE
|
flags |= FanEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
|
@ -376,7 +372,7 @@ class ZwaveThermostatFan(ZWaveBaseEntity, FanEntity):
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_PRESET_MODE
|
return FanEntityFeature.PRESET_MODE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_state(self) -> str | None:
|
def fan_state(self) -> str | None:
|
||||||
|
|
|
@ -3,11 +3,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from zwave_me_ws import ZWaveMeData
|
from zwave_me_ws import ZWaveMeData
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity
|
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import HVAC_MODE_HEAT
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE
|
from homeassistant.const import ATTR_TEMPERATURE
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
@ -51,6 +48,8 @@ async def async_setup_entry(
|
||||||
class ZWaveMeClimate(ZWaveMeEntity, ClimateEntity):
|
class ZWaveMeClimate(ZWaveMeEntity, ClimateEntity):
|
||||||
"""Representation of a ZWaveMe sensor."""
|
"""Representation of a ZWaveMe sensor."""
|
||||||
|
|
||||||
|
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
|
|
||||||
def set_temperature(self, **kwargs) -> None:
|
def set_temperature(self, **kwargs) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||||
|
@ -90,11 +89,6 @@ class ZWaveMeClimate(ZWaveMeEntity, ClimateEntity):
|
||||||
"""Return the current mode."""
|
"""Return the current mode."""
|
||||||
return HVAC_MODE_HEAT
|
return HVAC_MODE_HEAT
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the supported features."""
|
|
||||||
return SUPPORT_TARGET_TEMPERATURE
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_step(self) -> float:
|
def target_temperature_step(self) -> float:
|
||||||
"""Return the supported step of target temperature."""
|
"""Return the supported step of target temperature."""
|
||||||
|
|
|
@ -5,10 +5,8 @@ from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
SUPPORT_CLOSE,
|
|
||||||
SUPPORT_OPEN,
|
|
||||||
SUPPORT_SET_POSITION,
|
|
||||||
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
|
||||||
|
@ -49,6 +47,12 @@ async def async_setup_entry(
|
||||||
class ZWaveMeCover(ZWaveMeEntity, CoverEntity):
|
class ZWaveMeCover(ZWaveMeEntity, CoverEntity):
|
||||||
"""Representation of a ZWaveMe Multilevel Cover."""
|
"""Representation of a ZWaveMe Multilevel Cover."""
|
||||||
|
|
||||||
|
_attr_supported_features = (
|
||||||
|
CoverEntityFeature.OPEN
|
||||||
|
| CoverEntityFeature.CLOSE
|
||||||
|
| CoverEntityFeature.SET_POSITION
|
||||||
|
)
|
||||||
|
|
||||||
def close_cover(self, **kwargs):
|
def close_cover(self, **kwargs):
|
||||||
"""Close cover."""
|
"""Close cover."""
|
||||||
self.controller.zwave_api.send_command(self.device.id, "exact?level=0")
|
self.controller.zwave_api.send_command(self.device.id, "exact?level=0")
|
||||||
|
@ -71,8 +75,3 @@ class ZWaveMeCover(ZWaveMeEntity, CoverEntity):
|
||||||
None is unknown, 0 is closed, 100 is fully open.
|
None is unknown, 0 is closed, 100 is fully open.
|
||||||
"""
|
"""
|
||||||
return self.device.level
|
return self.device.level
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the supported features."""
|
|
||||||
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue