1 """Support for Nexia switches."""
3 from __future__
import annotations
7 from nexia.const
import OPERATION_MODE_OFF
8 from nexia.thermostat
import NexiaThermostat
9 from nexia.zone
import NexiaThermostatZone
15 from .coordinator
import NexiaDataUpdateCoordinator
16 from .entity
import NexiaThermostatEntity, NexiaThermostatZoneEntity
17 from .types
import NexiaConfigEntry
22 config_entry: NexiaConfigEntry,
23 async_add_entities: AddEntitiesCallback,
25 """Set up switches for a Nexia device."""
26 coordinator = config_entry.runtime_data
27 nexia_home = coordinator.nexia_home
28 entities: list[NexiaHoldSwitch | NexiaEmergencyHeatSwitch] = []
29 for thermostat_id
in nexia_home.get_thermostat_ids():
30 thermostat: NexiaThermostat = nexia_home.get_thermostat_by_id(thermostat_id)
31 if thermostat.has_emergency_heat():
33 for zone_id
in thermostat.get_zone_ids():
34 zone: NexiaThermostatZone = thermostat.get_zone_by_id(zone_id)
41 """Provides Nexia hold switch support."""
43 _attr_translation_key =
"hold"
46 self, coordinator: NexiaDataUpdateCoordinator, zone: NexiaThermostatZone
48 """Initialize the hold mode switch."""
49 zone_id = zone.zone_id
50 super().
__init__(coordinator, zone, zone_id)
54 """Return if the zone is in hold mode."""
55 return self.
_zone_zone.is_in_permanent_hold()
58 """Enable permanent hold."""
59 if self.
_zone_zone.get_current_mode() == OPERATION_MODE_OFF:
60 await self.
_zone_zone.call_permanent_off()
62 await self.
_zone_zone.set_permanent_hold()
66 """Disable permanent hold."""
67 await self.
_zone_zone.call_return_to_schedule()
72 """Provides Nexia emergency heat switch support."""
74 _attr_translation_key =
"emergency_heat"
77 self, coordinator: NexiaDataUpdateCoordinator, thermostat: NexiaThermostat
79 """Initialize the emergency heat mode switch."""
83 unique_id=f
"{thermostat.thermostat_id}_emergency_heat",
88 """Return if the zone is in hold mode."""
89 return self.
_thermostat_thermostat.is_emergency_heat_active()
92 """Enable permanent hold."""
93 await self.
_thermostat_thermostat.set_emergency_heat(
True)
97 """Disable permanent hold."""
98 await self.
_thermostat_thermostat.set_emergency_heat(
False)
None _signal_thermostat_update(self)
None _signal_zone_update(self)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, NexiaDataUpdateCoordinator coordinator, NexiaThermostat thermostat)
None __init__(self, NexiaDataUpdateCoordinator coordinator, NexiaThermostatZone zone)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, NexiaConfigEntry config_entry, AddEntitiesCallback async_add_entities)