1 """Support for SwitchBee scenario button."""
3 from switchbee.api.central_unit
import SwitchBeeError
4 from switchbee.device
import ApiStateCommand, DeviceType
12 from .const
import DOMAIN
13 from .coordinator
import SwitchBeeCoordinator
14 from .entity
import SwitchBeeEntity
18 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
20 """Set up Switchbee button."""
21 coordinator: SwitchBeeCoordinator = hass.data[DOMAIN][entry.entry_id]
24 for switchbee_device
in coordinator.data.values()
25 if switchbee_device.type == DeviceType.Scenario
30 """Representation of an Switchbee button."""
33 """Fire the scenario in the SwitchBee hub."""
35 await self.coordinator.api.set_state(self._device.id, ApiStateCommand.ON)
36 except SwitchBeeError
as exp:
38 f
"Failed to fire scenario {self.name}, {exp!s}"