1 """Support for StarLine switch."""
3 from __future__
import annotations
12 from .account
import StarlineAccount, StarlineDevice
13 from .const
import DOMAIN
14 from .entity
import StarlineEntity
16 SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
19 translation_key=
"engine",
23 translation_key=
"webasto",
27 translation_key=
"additional_channel",
31 translation_key=
"service_mode",
37 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
39 """Set up the StarLine switch."""
40 account: StarlineAccount = hass.data[DOMAIN][entry.entry_id]
43 for device
in account.api.devices.values()
44 if device.support_state
45 for description
in SWITCH_TYPES
46 if (switch :=
StarlineSwitch(account, device, description)).is_on
is not None
52 """Representation of a StarLine switch."""
54 _attr_assumed_state =
True
58 account: StarlineAccount,
59 device: StarlineDevice,
60 description: SwitchEntityDescription,
62 """Initialize the switch."""
63 super().
__init__(account, device, description.key)
68 """Return True if entity is available."""
69 return super().available
and self.
_device_device.online
73 """Return the state attributes of the switch."""
80 """Return True if entity is on."""
84 """Turn the entity on."""
88 """Turn the entity off."""
None turn_off(self, **Any kwargs)
None __init__(self, StarlineAccount account, StarlineDevice device, SwitchEntityDescription description)
def extra_state_attributes(self)
None turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)