1 """Support for the Hive climate devices."""
3 from datetime
import timedelta
7 from apyhiveapi
import Hive
8 import voluptuous
as vol
24 from .
import refresh_system
28 SERVICE_BOOST_HEATING_OFF,
29 SERVICE_BOOST_HEATING_ON,
31 from .entity
import HiveEntity
33 HIVE_TO_HASS_STATE = {
34 "SCHEDULE": HVACMode.AUTO,
35 "MANUAL": HVACMode.HEAT,
39 HASS_TO_HIVE_STATE = {
40 HVACMode.AUTO:
"SCHEDULE",
41 HVACMode.HEAT:
"MANUAL",
45 HIVE_TO_HASS_HVAC_ACTION = {
46 "UNKNOWN": HVACAction.OFF,
47 False: HVACAction.IDLE,
48 True: HVACAction.HEATING,
52 "C": UnitOfTemperature.CELSIUS,
53 "F": UnitOfTemperature.FAHRENHEIT,
57 _LOGGER = logging.getLogger()
61 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
63 """Set up Hive thermostat based on a config entry."""
65 hive = hass.data[DOMAIN][entry.entry_id]
66 devices = hive.session.deviceList.get(
"climate")
70 platform = entity_platform.async_get_current_platform()
72 platform.async_register_entity_service(
73 SERVICE_BOOST_HEATING_ON,
75 vol.Required(ATTR_TIME_PERIOD): vol.All(
77 cv.positive_timedelta,
78 lambda td: td.total_seconds() // 60,
80 vol.Optional(ATTR_TEMPERATURE, default=
"25.0"): vol.Coerce(float),
82 "async_heating_boost_on",
85 platform.async_register_entity_service(
86 SERVICE_BOOST_HEATING_OFF,
88 "async_heating_boost_off",
93 """Hive Climate Device."""
95 _attr_hvac_modes = [HVACMode.AUTO, HVACMode.HEAT, HVACMode.OFF]
96 _attr_preset_modes = [PRESET_BOOST, PRESET_NONE]
97 _attr_supported_features = (
98 ClimateEntityFeature.TARGET_TEMPERATURE
99 | ClimateEntityFeature.PRESET_MODE
100 | ClimateEntityFeature.TURN_OFF
101 | ClimateEntityFeature.TURN_ON
103 _enable_turn_on_off_backwards_compatibility =
False
105 def __init__(self, hive: Hive, hive_device: dict[str, Any]) ->
None:
106 """Initialize the Climate device."""
113 """Set new target hvac mode."""
114 new_mode = HASS_TO_HIVE_STATE[hvac_mode]
119 """Set new target temperature."""
120 new_temperature = kwargs.get(ATTR_TEMPERATURE)
121 if new_temperature
is not None:
122 await self.
hivehive.heating.setTargetTemperature(self.
devicedevicedevice, new_temperature)
126 """Set new preset mode."""
129 elif preset_mode == PRESET_BOOST:
131 temperature = curtemp + 0.5
132 await self.
hivehive.heating.setBoostOn(self.
devicedevicedevice, 30, temperature)
136 """Handle boost heating service call."""
137 await self.
hivehive.heating.setBoostOn(self.
devicedevicedevice, time_period, temperature)
141 """Handle boost heating service call."""
145 """Update all Node data from Hive."""
155 "current_temperature"
float|None current_temperature(self)
str|None preset_mode(self)
None async_set_temperature(self, **Any kwargs)
def async_heating_boost_on(self, time_period, temperature)
None __init__(self, Hive hive, dict[str, Any] hive_device)
None async_heating_boost_off(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
_attr_current_temperature
None async_set_preset_mode(self, str preset_mode)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)