mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
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
@ -50,6 +50,13 @@ async def async_setup_entry(
|
|||||||
class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntity):
|
class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntity):
|
||||||
"""Representation of a climate/thermostat device within devolo Home Control."""
|
"""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__(
|
def __init__(
|
||||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -60,14 +67,8 @@ class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntit
|
|||||||
element_uid=element_uid,
|
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_min_temp = self._multi_level_switch_property.min
|
||||||
self._attr_max_temp = self._multi_level_switch_property.max
|
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
|
@property
|
||||||
def current_temperature(self) -> float | None:
|
def current_temperature(self) -> float | None:
|
||||||
|
@ -3,9 +3,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
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 (
|
from homeassistant.components.cover import (
|
||||||
CoverDeviceClass,
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
@ -43,22 +40,12 @@ async def async_setup_entry(
|
|||||||
class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
|
class DevoloCoverDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, CoverEntity):
|
||||||
"""Representation of a cover device within devolo Home Control."""
|
"""Representation of a cover device within devolo Home Control."""
|
||||||
|
|
||||||
def __init__(
|
_attr_supported_features = (
|
||||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
CoverEntityFeature.OPEN
|
||||||
) -> None:
|
| CoverEntityFeature.CLOSE
|
||||||
"""Initialize a climate entity within devolo Home Control."""
|
| CoverEntityFeature.SET_POSITION
|
||||||
super().__init__(
|
)
|
||||||
homecontrol=homecontrol,
|
_attr_device_class = CoverDeviceClass.BLIND
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int:
|
def current_cover_position(self) -> int:
|
||||||
|
@ -39,6 +39,8 @@ async def async_setup_entry(
|
|||||||
class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
||||||
"""Representation of a light within devolo Home Control."""
|
"""Representation of a light within devolo Home Control."""
|
||||||
|
|
||||||
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -49,7 +51,6 @@ class DevoloLightDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, LightEntity):
|
|||||||
element_uid=element_uid,
|
element_uid=element_uid,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
|
||||||
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
self._binary_switch_property = device_instance.binary_switch_property.get(
|
self._binary_switch_property = device_instance.binary_switch_property.get(
|
||||||
element_uid.replace("Dimmer", "BinarySwitch")
|
element_uid.replace("Dimmer", "BinarySwitch")
|
||||||
|
@ -123,6 +123,12 @@ class DevoloGenericMultiLevelDeviceEntity(DevoloMultiLevelDeviceEntity):
|
|||||||
class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity):
|
class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity):
|
||||||
"""Representation of a battery entity within devolo Home Control."""
|
"""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__(
|
def __init__(
|
||||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -134,11 +140,6 @@ class DevoloBatteryEntity(DevoloMultiLevelDeviceEntity):
|
|||||||
element_uid=element_uid,
|
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
|
self._value = device_instance.battery_level
|
||||||
|
|
||||||
|
|
||||||
@ -175,7 +176,11 @@ class DevoloConsumptionEntity(DevoloMultiLevelDeviceEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
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}"
|
return f"{self._attr_unique_id}_{self._sensor_type}"
|
||||||
|
|
||||||
def _sync(self, message: tuple) -> None:
|
def _sync(self, message: tuple) -> None:
|
||||||
|
@ -46,7 +46,7 @@ class DevoloSwitch(DevoloDeviceEntity, SwitchEntity):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize an devolo Switch."""
|
"""Initialize a devolo Switch."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
homecontrol=homecontrol,
|
homecontrol=homecontrol,
|
||||||
device_instance=device_instance,
|
device_instance=device_instance,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user