1 """Support for Overkiz (virtual) buttons."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from pyoverkiz.enums
import OverkizCommand
8 from pyoverkiz.types
import StateType
as OverkizStateType
16 from .
import HomeAssistantOverkizData
17 from .const
import DOMAIN, IGNORED_OVERKIZ_DEVICES
18 from .entity
import OverkizDescriptiveEntity
21 @dataclass(frozen=True)
23 """Class to describe an Overkiz button."""
25 press_args: OverkizStateType |
None =
None
28 BUTTON_DESCRIPTIONS: list[OverkizButtonDescription] = [
38 name=
"Start identify",
39 icon=
"mdi:human-greeting-variant",
40 entity_category=EntityCategory.DIAGNOSTIC,
41 entity_registry_enabled_default=
False,
46 icon=
"mdi:human-greeting-variant",
47 entity_category=EntityCategory.DIAGNOSTIC,
48 entity_registry_enabled_default=
False,
53 icon=
"mdi:human-greeting-variant",
54 entity_category=EntityCategory.DIAGNOSTIC,
60 key=
"fastBipSequence", name=
"Fast bip sequence", icon=
"mdi:bell-ring"
71 key=OverkizCommand.CYCLE,
77 SUPPORTED_COMMANDS = {
78 description.key: description
for description
in BUTTON_DESCRIPTIONS
85 async_add_entities: AddEntitiesCallback,
87 """Set up the Overkiz button from a config entry."""
88 data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
89 entities: list[ButtonEntity] = []
91 for device
in data.coordinator.data.values():
93 device.widget
in IGNORED_OVERKIZ_DEVICES
94 or device.ui_class
in IGNORED_OVERKIZ_DEVICES
104 for command
in device.definition.commands
105 if (description := SUPPORTED_COMMANDS.get(command.command_name))
112 """Representation of an Overkiz Button."""
114 entity_description: OverkizButtonDescription
117 """Handle the button press."""
119 await self.
executorexecutor.async_execute_command(