1 """Switch platform for the Flipr's Hub."""
10 from .
import FliprConfigEntry
11 from .entity
import FliprEntity
13 _LOGGER = logging.getLogger(__name__)
15 SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
25 config_entry: FliprConfigEntry,
26 async_add_entities: AddEntitiesCallback,
28 """Set up switch for Flipr hub."""
29 coordinators = config_entry.runtime_data.hub_coordinators
33 for description
in SWITCH_TYPES
34 for coordinator
in coordinators
39 """Switch representing Hub state."""
43 """Return state of the switch."""
44 _LOGGER.debug(
"coordinator data = %s", self.coordinator.data)
45 return self.coordinator.data[
"state"]
48 """Turn off the switch."""
50 data = await self.
hasshasshass.async_add_executor_job(
51 self.coordinator.client.set_hub_state,
55 _LOGGER.debug(
"New hub infos are %s", data)
59 """Turn on the switch."""
61 data = await self.
hasshasshass.async_add_executor_job(
62 self.coordinator.client.set_hub_state,
66 _LOGGER.debug(
"New hub infos are %s", data)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_set_updated_data(self, _DataT data)
None async_setup_entry(HomeAssistant hass, FliprConfigEntry config_entry, AddEntitiesCallback async_add_entities)