1 """Support for Huum wifi-enabled sauna."""
3 from __future__
import annotations
8 from huum.const
import SaunaStatus
9 from huum.exceptions
import SafetyException
10 from huum.huum
import Huum
11 from huum.schemas
import HuumStatusResponse
25 from .const
import DOMAIN
27 _LOGGER = logging.getLogger(__name__)
33 async_add_entities: AddEntitiesCallback,
35 """Set up the Huum sauna with config flow."""
36 huum_handler = hass.data.setdefault(DOMAIN, {})[entry.entry_id]
42 """Representation of a heater."""
44 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
45 _attr_supported_features = (
46 ClimateEntityFeature.TARGET_TEMPERATURE
47 | ClimateEntityFeature.TURN_OFF
48 | ClimateEntityFeature.TURN_ON
50 _attr_target_temperature_step = PRECISION_WHOLE
51 _attr_temperature_unit = UnitOfTemperature.CELSIUS
54 _attr_has_entity_name =
True
57 _target_temperature: int |
None =
None
58 _status: HuumStatusResponse |
None =
None
59 _enable_turn_on_off_backwards_compatibility =
False
61 def __init__(self, huum_handler: Huum, unique_id: str) ->
None:
62 """Initialize the heater."""
65 identifiers={(DOMAIN, unique_id)},
74 """Return hvac operation ie. heat, cool mode."""
75 if self.
_status_status
and self.
_status_status.status == SaunaStatus.ONLINE_HEATING:
81 """Return nice icon for heater."""
84 return "mdi:radiator-off"
88 """Return the current temperature."""
89 if (status := self.
_status_status)
is not None:
90 return status.temperature
95 """Return the temperature we try to reach."""
100 if hvac_mode == HVACMode.HEAT:
102 elif hvac_mode == HVACMode.OFF:
106 """Set new target temperature."""
107 temperature = kwargs.get(ATTR_TEMPERATURE)
108 if temperature
is None:
113 await self.
_turn_on_turn_on(temperature)
116 """Get the latest status data.
118 We get the latest status first from the status endpoints of the sauna.
119 If that data does not include the temperature, that means that the sauna
120 is off, we then call the off command which will in turn return the temperature.
121 This is a workaround for getting the temperature as the Huum API does not
122 return the target temperature of a sauna that is off, even if it can have
123 a target temperature at that time.
129 async
def _turn_on(self, temperature: int) ->
None:
132 except (ValueError, SafetyException)
as err:
133 _LOGGER.error(
str(err))
float|None target_temperature(self)
HVACMode|None hvac_mode(self)
None _turn_on(self, int temperature)
int|None current_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
int target_temperature(self)
None async_set_temperature(self, **Any kwargs)
None __init__(self, Huum huum_handler, str unique_id)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)