1 """Switches on Zigbee Home Automation networks."""
3 from __future__
import annotations
16 from .entity
import ZHAEntity
17 from .helpers
import (
19 async_add_entities
as zha_async_add_entities,
20 convert_zha_error_to_ha_error,
24 _LOGGER = logging.getLogger(__name__)
29 config_entry: ConfigEntry,
30 async_add_entities: AddEntitiesCallback,
32 """Set up the Zigbee Home Automation switch from config entry."""
34 entities_to_create = zha_data.platforms[Platform.SWITCH]
40 zha_async_add_entities, async_add_entities, Switch, entities_to_create
43 config_entry.async_on_unload(unsub)
51 """Return if the switch is on based on the statemachine."""
52 return self.entity_data.entity.is_on
54 @convert_zha_error_to_ha_error
56 """Turn the entity on."""
57 await self.entity_data.entity.async_turn_on()
60 @convert_zha_error_to_ha_error
62 """Turn the entity off."""
63 await self.entity_data.entity.async_turn_off()
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None async_write_ha_state(self)
HAZHAData get_zha_data(HomeAssistant hass)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)