mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Use EntityFeature in homematic (#69405)
* Use EntityFeature in homematic * Use EntityFeature in homematicip_cloud
This commit is contained in:
parent
ef14ae85c8
commit
a661e06e25
@ -1,7 +1,7 @@
|
||||
"""Support for Homematic thermostats."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
||||
from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_AUTO,
|
||||
HVAC_MODE_HEAT,
|
||||
@ -10,8 +10,6 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_COMFORT,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -34,8 +32,6 @@ HM_PRESET_MAP = {
|
||||
HM_CONTROL_MODE = "CONTROL_MODE"
|
||||
HMIP_CONTROL_MODE = "SET_POINT_MODE"
|
||||
|
||||
SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
@ -58,10 +54,9 @@ def setup_platform(
|
||||
class HMThermostat(HMDevice, ClimateEntity):
|
||||
"""Representation of a Homematic thermostat."""
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_FLAGS
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||
)
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
|
@ -10,9 +10,8 @@ from homeassistant.components.light import (
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
SUPPORT_EFFECT,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -85,9 +84,9 @@ class HMLight(HMDevice, LightEntity):
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
features = SUPPORT_TRANSITION
|
||||
features = LightEntityFeature.TRANSITION
|
||||
if "PROGRAM" in self._hmdevice.WRITENODE:
|
||||
features |= SUPPORT_EFFECT
|
||||
features |= LightEntityFeature.EFFECT
|
||||
return features
|
||||
|
||||
@property
|
||||
@ -109,14 +108,14 @@ class HMLight(HMDevice, LightEntity):
|
||||
@property
|
||||
def effect_list(self):
|
||||
"""Return the list of supported effects."""
|
||||
if not self.supported_features & SUPPORT_EFFECT:
|
||||
if not self.supported_features & LightEntityFeature.EFFECT:
|
||||
return None
|
||||
return self._hmdevice.get_effect_list()
|
||||
|
||||
@property
|
||||
def effect(self):
|
||||
"""Return the current color change program of the light."""
|
||||
if not self.supported_features & SUPPORT_EFFECT:
|
||||
if not self.supported_features & LightEntityFeature.EFFECT:
|
||||
return None
|
||||
return self._hmdevice.get_effect()
|
||||
|
||||
@ -164,5 +163,5 @@ class HMLight(HMDevice, LightEntity):
|
||||
|
||||
if COLOR_MODE_HS in self.supported_color_modes:
|
||||
self._data.update({"COLOR": None})
|
||||
if self.supported_features & SUPPORT_EFFECT:
|
||||
if self.supported_features & LightEntityFeature.EFFECT:
|
||||
self._data.update({"PROGRAM": None})
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Support for Homematic locks."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
|
||||
from homeassistant.components.lock import LockEntity, LockEntityFeature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
@ -30,6 +30,8 @@ def setup_platform(
|
||||
class HMLock(HMDevice, LockEntity):
|
||||
"""Representation of a Homematic lock aka KeyMatic."""
|
||||
|
||||
_attr_supported_features = LockEntityFeature.OPEN
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
"""Return true if the lock is locked."""
|
||||
@ -51,8 +53,3 @@ class HMLock(HMDevice, LockEntity):
|
||||
"""Generate the data dictionary (self._data) from metadata."""
|
||||
self._state = "STATE"
|
||||
self._data.update({self._state: None})
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_OPEN
|
||||
|
@ -5,10 +5,9 @@ import logging
|
||||
|
||||
from homematicip.functionalHomes import SecurityAndAlarmHome
|
||||
|
||||
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.const import (
|
||||
@ -42,6 +41,11 @@ async def async_setup_entry(
|
||||
class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity):
|
||||
"""Representation of the HomematicIP alarm control panel."""
|
||||
|
||||
_attr_supported_features = (
|
||||
AlarmControlPanelEntityFeature.ARM_HOME
|
||||
| AlarmControlPanelEntityFeature.ARM_AWAY
|
||||
)
|
||||
|
||||
def __init__(self, hap: HomematicipHAP) -> None:
|
||||
"""Initialize the alarm control panel."""
|
||||
self._home: AsyncHome = hap.home
|
||||
@ -79,11 +83,6 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity):
|
||||
def _security_and_alarm(self) -> SecurityAndAlarmHome:
|
||||
return self._home.get_functionalHome(SecurityAndAlarmHome)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY
|
||||
|
||||
async def async_alarm_disarm(self, code=None) -> None:
|
||||
"""Send disarm command."""
|
||||
await self._home.set_security_zones_activation(False, False)
|
||||
|
@ -9,7 +9,7 @@ from homematicip.base.enums import AbsenceType
|
||||
from homematicip.device import Switch
|
||||
from homematicip.functionalHomes import IndoorClimateHome
|
||||
|
||||
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,
|
||||
@ -21,8 +21,6 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_BOOST,
|
||||
PRESET_ECO,
|
||||
PRESET_NONE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
@ -68,6 +66,10 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
||||
Cool mode is only available for floor heating systems, if basically enabled in the hmip app.
|
||||
"""
|
||||
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
)
|
||||
|
||||
def __init__(self, hap: HomematicipHAP, device: AsyncHeatingGroup) -> None:
|
||||
"""Initialize heating group."""
|
||||
device.modelType = "HmIP-Heating-Group"
|
||||
@ -92,11 +94,6 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
||||
"""Return the unit of measurement."""
|
||||
return TEMP_CELSIUS
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float:
|
||||
"""Return the temperature we try to reach."""
|
||||
|
@ -23,8 +23,8 @@ from homeassistant.components.light import (
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_HS,
|
||||
COLOR_MODE_ONOFF,
|
||||
SUPPORT_TRANSITION,
|
||||
LightEntity,
|
||||
LightEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -154,6 +154,7 @@ class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity):
|
||||
|
||||
_attr_color_mode = COLOR_MODE_HS
|
||||
_attr_supported_color_modes = {COLOR_MODE_HS}
|
||||
_attr_supported_features = LightEntityFeature.TRANSITION
|
||||
|
||||
def __init__(self, hap: HomematicipHAP, device, channel: int) -> None:
|
||||
"""Initialize the notification light entity."""
|
||||
@ -209,11 +210,6 @@ class HomematicipNotificationLight(HomematicipGenericEntity, LightEntity):
|
||||
|
||||
return state_attr
|
||||
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_TRANSITION
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique ID."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user