1 """Support for Duotecno climate devices."""
3 from __future__
import annotations
5 from typing
import Any, Final
7 from duotecno.controller
import PyDuotecno
8 from duotecno.unit
import SensUnit
20 from .const
import DOMAIN
21 from .entity
import DuotecnoEntity, api_call
28 HVACMODE_REVERSE: Final = {value: key
for key, value
in HVACMODE.items()}
30 PRESETMODES: Final = {
"sun": 0,
"half_sun": 1,
"moon": 2,
"half_moon": 3}
31 PRESETMODES_REVERSE: Final = {value: key
for key, value
in PRESETMODES.items()}
37 async_add_entities: AddEntitiesCallback,
39 """Set up Duotecno climate based on config_entry."""
40 cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
47 """Representation of a Duotecno climate entity."""
50 _attr_supported_features = (
51 ClimateEntityFeature.TARGET_TEMPERATURE
52 | ClimateEntityFeature.PRESET_MODE
53 | ClimateEntityFeature.TURN_OFF
54 | ClimateEntityFeature.TURN_ON
56 _attr_temperature_unit = UnitOfTemperature.CELSIUS
57 _attr_hvac_modes =
list(HVACMODE_REVERSE)
58 _attr_preset_modes =
list(PRESETMODES)
59 _attr_translation_key =
"duotecno"
60 _enable_turn_on_off_backwards_compatibility =
False
64 """Get the current temperature."""
65 return self.
_unit_unit.get_cur_temp()
69 """Get the target temperature."""
70 return self.
_unit_unit.get_target_temp()
74 """Get the current hvac_mode."""
79 """Get the preset mode."""
80 return PRESETMODES_REVERSE[self.
_unit_unit.get_preset()]
84 """Set new target temperatures."""
85 if (temp := kwargs.get(ATTR_TEMPERATURE))
is None:
87 await self.
_unit_unit.set_temp(temp)
91 """Set the preset mode."""
92 await self.
_unit_unit.set_preset(PRESETMODES[preset_mode])
96 """Duotecno does not support setting this, we can only display it."""
97 if hvac_mode == HVACMode.OFF:
None async_set_preset_mode(self, str preset_mode)
float|None target_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
float|None current_temperature(self)
None async_set_temperature(self, **Any kwargs)
str|float get_state(dict[str, float] data, str key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)