1 """Support for Honeywell switches."""
3 from __future__
import annotations
7 from aiosomecomfort
import SomeComfortError
8 from aiosomecomfort.device
import Device
as SomeComfortDevice
13 SwitchEntityDescription,
21 from .
import HoneywellData
22 from .const
import DOMAIN
24 EMERGENCY_HEAT_KEY =
"emergency_heat"
26 SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
28 key=EMERGENCY_HEAT_KEY,
29 translation_key=EMERGENCY_HEAT_KEY,
30 device_class=SwitchDeviceClass.SWITCH,
37 config_entry: ConfigEntry,
38 async_add_entities: AddEntitiesCallback,
40 """Set up the Honeywell switches."""
41 data: HoneywellData = hass.data[DOMAIN][config_entry.entry_id]
44 for device
in data.devices.values()
45 if device.raw_ui_data.get(
"SwitchEmergencyHeatAllowed")
46 for description
in SWITCH_TYPES
51 """Representation of a honeywell switch."""
53 _attr_has_entity_name =
True
57 honeywell_data: HoneywellData,
58 device: SomeComfortDevice,
59 description: SwitchEntityDescription,
61 """Initialize the switch."""
62 self.
_data_data = honeywell_data
67 identifiers={(DOMAIN, device.deviceid)},
69 manufacturer=
"Honeywell",
73 """Turn the switch on if heat mode is enabled."""
75 await self.
_device_device.set_system_mode(
"emheat")
76 except SomeComfortError
as err:
78 translation_domain=DOMAIN, translation_key=
"switch_failed_on"
82 """Turn the switch off if on."""
85 await self.
_device_device.set_system_mode(
"off")
87 except SomeComfortError
as err:
89 translation_domain=DOMAIN, translation_key=
"switch_failed_off"
94 """Return true if Emergency heat is enabled."""
95 return self.
_device_device.system_mode ==
"emheat"
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, HoneywellData honeywell_data, SomeComfortDevice device, SwitchEntityDescription description)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)