Use entity class attributes for Adax (#54501)
* Adax attributes Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net> * Adax attributes Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net> * Update homeassistant/components/adax/climate.py Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * style Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net> Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
parent
49a69d5ba0
commit
e55868b17f
1 changed files with 8 additions and 34 deletions
|
@ -49,20 +49,19 @@ async def async_setup_entry(
|
||||||
class AdaxDevice(ClimateEntity):
|
class AdaxDevice(ClimateEntity):
|
||||||
"""Representation of a heater."""
|
"""Representation of a heater."""
|
||||||
|
|
||||||
|
_attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
||||||
|
_attr_max_temp = 35
|
||||||
|
_attr_min_temp = 5
|
||||||
|
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||||
|
_attr_target_temperature_step = PRECISION_WHOLE
|
||||||
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
def __init__(self, heater_data: dict[str, Any], adax_data_handler: Adax) -> None:
|
def __init__(self, heater_data: dict[str, Any], adax_data_handler: Adax) -> None:
|
||||||
"""Initialize the heater."""
|
"""Initialize the heater."""
|
||||||
self._heater_data = heater_data
|
self._heater_data = heater_data
|
||||||
self._adax_data_handler = adax_data_handler
|
self._adax_data_handler = adax_data_handler
|
||||||
|
|
||||||
@property
|
self._attr_unique_id = f"{heater_data['homeId']}_{heater_data['id']}"
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Return the list of supported features."""
|
|
||||||
return SUPPORT_TARGET_TEMPERATURE
|
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return a unique ID."""
|
|
||||||
return f"{self._heater_data['homeId']}_{self._heater_data['id']}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
@ -83,11 +82,6 @@ class AdaxDevice(ClimateEntity):
|
||||||
return "mdi:radiator"
|
return "mdi:radiator"
|
||||||
return "mdi:radiator-off"
|
return "mdi:radiator-off"
|
||||||
|
|
||||||
@property
|
|
||||||
def hvac_modes(self) -> list[str]:
|
|
||||||
"""Return the list of available hvac operation modes."""
|
|
||||||
return [HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set hvac mode."""
|
"""Set hvac mode."""
|
||||||
if hvac_mode == HVAC_MODE_HEAT:
|
if hvac_mode == HVAC_MODE_HEAT:
|
||||||
|
@ -105,21 +99,6 @@ class AdaxDevice(ClimateEntity):
|
||||||
return
|
return
|
||||||
await self._adax_data_handler.update()
|
await self._adax_data_handler.update()
|
||||||
|
|
||||||
@property
|
|
||||||
def temperature_unit(self) -> str:
|
|
||||||
"""Return the unit of measurement which this device uses."""
|
|
||||||
return TEMP_CELSIUS
|
|
||||||
|
|
||||||
@property
|
|
||||||
def min_temp(self) -> int:
|
|
||||||
"""Return the minimum temperature."""
|
|
||||||
return 5
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_temp(self) -> int:
|
|
||||||
"""Return the maximum temperature."""
|
|
||||||
return 35
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> float | None:
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
|
@ -130,11 +109,6 @@ class AdaxDevice(ClimateEntity):
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
return self._heater_data.get("targetTemperature")
|
return self._heater_data.get("targetTemperature")
|
||||||
|
|
||||||
@property
|
|
||||||
def target_temperature_step(self) -> int:
|
|
||||||
"""Return the supported step of target temperature."""
|
|
||||||
return PRECISION_WHOLE
|
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue