1 """Support for Balboa Spa Wifi adaptor."""
3 from __future__
import annotations
5 from enum
import IntEnum
8 from pybalboa
import SpaClient, SpaControl
9 from pybalboa.enums
import HeatMode, HeatState, TemperatureUnit
26 from .
import BalboaConfigEntry
27 from .const
import DOMAIN
28 from .entity
import BalboaEntity
30 HEAT_HVAC_MODE_MAP: dict[IntEnum, HVACMode] = {
31 HeatMode.READY: HVACMode.HEAT,
32 HeatMode.REST: HVACMode.OFF,
33 HeatMode.READY_IN_REST: HVACMode.AUTO,
35 HVAC_HEAT_MODE_MAP = {value: key
for key, value
in HEAT_HVAC_MODE_MAP.items()}
36 HEAT_STATE_HVAC_ACTION_MAP = {
37 HeatState.OFF: HVACAction.OFF,
38 HeatState.HEATING: HVACAction.HEATING,
39 HeatState.HEAT_WAITING: HVACAction.IDLE,
41 TEMPERATURE_UNIT_MAP = {
42 TemperatureUnit.CELSIUS: UnitOfTemperature.CELSIUS,
43 TemperatureUnit.FAHRENHEIT: UnitOfTemperature.FAHRENHEIT,
49 entry: BalboaConfigEntry,
50 async_add_entities: AddEntitiesCallback,
52 """Set up the spa climate entity."""
57 """Representation of a Balboa spa climate entity."""
59 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
60 _attr_supported_features = (
61 ClimateEntityFeature.TARGET_TEMPERATURE
62 | ClimateEntityFeature.PRESET_MODE
63 | ClimateEntityFeature.TURN_OFF
64 | ClimateEntityFeature.TURN_ON
66 _attr_translation_key = DOMAIN
68 _enable_turn_on_off_backwards_compatibility =
False
71 """Initialize the climate entity."""
73 self.
_attr_preset_modes_attr_preset_modes = [opt.name.lower()
for opt
in client.heat_mode.options]
75 self.
_blower_blower: SpaControl |
None =
None
76 if client.blowers
and (blower := client.blowers[0])
is not None:
79 self.
_fan_mode_map_fan_mode_map = {opt.name.lower(): opt
for opt
in blower.options}
84 """Return the current HVAC mode."""
85 return HEAT_HVAC_MODE_MAP.get(self.
_client_client.heat_mode.state)
89 """Return the current operation mode."""
90 return HEAT_STATE_HVAC_ACTION_MAP[self.
_client_client.heat_state]
94 """Return the fan setting."""
95 if (blower := self.
_blower_blower)
is not None:
96 return blower.state.name.lower()
101 """Return the precision of the system."""
102 if self.
hasshass.config.units.temperature_unit == UnitOfTemperature.CELSIUS:
103 return PRECISION_HALVES
104 return PRECISION_WHOLE
108 """Return the unit of measurement used by the platform."""
109 return TEMPERATURE_UNIT_MAP[self.
_client_client.temperature_unit]
113 """Return the current temperature."""
114 return self.
_client_client.temperature
118 """Return the target temperature we try to reach."""
119 return self.
_client_client.target_temperature
123 """Return the minimum temperature supported by the spa."""
124 return self.
_client_client.temperature_minimum
128 """Return the minimum temperature supported by the spa."""
129 return self.
_client_client.temperature_maximum
133 """Return current preset mode."""
134 return self.
_client_client.heat_mode.state.name.lower()
137 """Set a new target temperature."""
141 """Set new preset mode."""
142 await self.
_client_client.heat_mode.set_state(HeatMode[preset_mode.upper()])
145 """Set new fan mode."""
146 if (blower := self.
_blower_blower)
is not None:
147 await blower.set_state(self.
_fan_mode_map_fan_mode_map[fan_mode])
150 """Set new target hvac mode."""
151 await self.
_client_client.heat_mode.set_state(HVAC_HEAT_MODE_MAP[hvac_mode])
None __init__(self, SpaClient client)
str temperature_unit(self)
None async_set_preset_mode(self, str preset_mode)
float target_temperature(self)
None async_set_temperature(self, **Any kwargs)
tuple _attr_supported_features
float|None current_temperature(self)
None async_set_hvac_mode(self, HVACMode hvac_mode)
HVACAction hvac_action(self)
None async_set_fan_mode(self, str fan_mode)
None set_temperature(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, BalboaConfigEntry entry, AddEntitiesCallback async_add_entities)