Move static shorthand devolo attributes outside of constructor (#99234)
Co-authored-by: Guido Schmitz <Shutgun@users.noreply.github.com>
This commit is contained in:
parent
8d3828ae54
commit
f545389549
5 changed files with 27 additions and 33 deletions
|
@ -50,6 +50,13 @@ async def async_setup_entry(
|
|||
class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntity):
|
||||
"""Representation of a climate/thermostat device within devolo Home Control."""
|
||||
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
_attr_target_temperature_step = PRECISION_HALVES
|
||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
_attr_precision = PRECISION_TENTHS
|
||||
_attr_hvac_mode = HVACMode.HEAT
|
||||
_attr_hvac_modes = [HVACMode.HEAT]
|
||||
|
||||
def __init__(
|
||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||
) -> None:
|
||||
|
@ -60,14 +67,8 @@ class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntit
|
|||
element_uid=element_uid,
|
||||
)
|
||||
|
||||
self._attr_hvac_mode = HVACMode.HEAT
|
||||
self._attr_hvac_modes = [HVACMode.HEAT]
|
||||
self._attr_min_temp = self._multi_level_switch_property.min
|
||||
self._attr_max_temp = self._multi_level_switch_property.max
|
||||
self._attr_precision = PRECISION_TENTHS
|
||||
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
self._attr_target_temperature_step = PRECISION_HALVES
|
||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
|
|
|
@ -3,9 +3,6 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from devolo_home_control_api.devices.zwave import Zwave
|
||||
from devolo_home_control_api.homecontrol import HomeControl
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
|
@ -43,22 +40,12 @@ async def async_setup_entry(
|
|||
class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
|
||||
"""Representation of a cover device within devolo Home Control."""
|
||||
|
||||
def __init__(
|
||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||
) -> None:
|
||||
"""Initialize a climate entity within devolo Home Control."""
|
||||
super().__init__(
|
||||
homecontrol=homecontrol,
|
||||
device_instance=device_instance,
|
||||
element_uid=element_uid,
|
||||
)
|
||||
|
||||
self._attr_device_class = CoverDeviceClass.BLIND
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
_attr_supported_features = (
|
||||
CoverEntityFeature.OPEN
|
||||
| CoverEntityFeature.CLOSE
|
||||
| CoverEntityFeature.SET_POSITION
|
||||
)
|
||||
_attr_device_class = CoverDeviceClass.BLIND
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> int:
|
||||
|
|
|
@ -39,6 +39,8 @@ async def async_setup_entry(
|
|||
class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
||||
"""Representation of a light within devolo Home Control."""
|
||||
|
||||
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||
|
||||
def __init__(
|
||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||
) -> None:
|
||||
|
@ -49,7 +51,6 @@ class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
|||
element_uid=element_uid,
|
||||
)
|
||||
|
||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
||||
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||
self._binary_switch_property = device_instance.binary_switch_property.get(
|
||||
element_uid.replace("Dimmer", "BinarySwitch")
|
||||
|
|
|
@ -123,6 +123,12 @@ class DevoloGenericMultiLevelDeviceEntity(DevoloMultiLevelDeviceEntity):
|
|||
class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity):
|
||||
"""Representation of a battery entity within devolo Home Control."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
_attr_name = "Battery level"
|
||||
_attr_device_class = SensorDeviceClass.BATTERY
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
def __init__(
|
||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||
) -> None:
|
||||
|
@ -134,11 +140,6 @@ class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity):
|
|||
element_uid=element_uid,
|
||||
)
|
||||
|
||||
self._attr_device_class = DEVICE_CLASS_MAPPING.get("battery")
|
||||
self._attr_state_class = STATE_CLASS_MAPPING.get("battery")
|
||||
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
self._attr_native_unit_of_measurement = PERCENTAGE
|
||||
self._attr_name = "Battery level"
|
||||
self._value = device_instance.battery_level
|
||||
|
||||
|
||||
|
@ -175,7 +176,11 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity):
|
|||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the unique ID of the entity."""
|
||||
"""Return the unique ID of the entity.
|
||||
|
||||
As both sensor types share the same element_uid we need to extend original
|
||||
self._attr_unique_id to be really unique.
|
||||
"""
|
||||
return f"{self._attr_unique_id}_{self._sensor_type}"
|
||||
|
||||
def _sync(self, message: tuple) -> None:
|
||||
|
|
|
@ -46,7 +46,7 @@ class DevoloSwitch(DevoloDeviceEntity, SwitchEntity):
|
|||
def __init__(
|
||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||
) -> None:
|
||||
"""Initialize an devolo Switch."""
|
||||
"""Initialize a devolo Switch."""
|
||||
super().__init__(
|
||||
homecontrol=homecontrol,
|
||||
device_instance=device_instance,
|
||||
|
|
Loading…
Add table
Reference in a new issue