1 """Support for Switchbot bot."""
3 from __future__
import annotations
15 from .coordinator
import SwitchbotConfigEntry, SwitchbotDataUpdateCoordinator
16 from .entity
import SwitchbotSwitchedEntity
23 entry: SwitchbotConfigEntry,
24 async_add_entities: AddEntitiesCallback,
26 """Set up Switchbot based on a config entry."""
31 """Representation of a Switchbot switch."""
33 _attr_device_class = SwitchDeviceClass.SWITCH
34 _attr_translation_key =
"bot"
36 _device: switchbot.Switchbot
38 def __init__(self, coordinator: SwitchbotDataUpdateCoordinator) ->
None:
39 """Initialize the Switchbot."""
44 """Run when entity about to be added."""
53 """Return true if unable to access real state of entity."""
54 return not self.
_device_device.switch_mode()
58 """Return true if device is on."""
59 if not self.
_device_device.switch_mode():
65 """Return the state attributes."""
67 **super().extra_state_attributes,
68 "switch_mode": self.
_device_device.switch_mode(),
dict[str, Any] extra_state_attributes(self)
None __init__(self, SwitchbotDataUpdateCoordinator coordinator)
None async_added_to_hass(self)
State|None async_get_last_state(self)
None async_setup_entry(HomeAssistant hass, SwitchbotConfigEntry entry, AddEntitiesCallback async_add_entities)