1 """Representation of ISY/IoX buttons."""
3 from __future__
import annotations
6 from pyisy.constants
import (
13 from pyisy.helpers
import EventListener, NodeProperty
14 from pyisy.networking
import NetworkCommand
15 from pyisy.nodes
import Node
24 from .const
import CONF_NETWORK, DOMAIN
25 from .models
import IsyData
30 config_entry: ConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up ISY/IoX button from config entry."""
34 isy_data: IsyData = hass.data[DOMAIN][config_entry.entry_id]
35 isy: ISY = isy_data.root
36 device_info = isy_data.devices
38 ISYNodeQueryButtonEntity
39 | ISYNodeBeepButtonEntity
40 | ISYNetworkResourceButtonEntity
45 unique_id=isy_data.uid_base(node),
46 device_info=device_info[CONF_NETWORK],
48 for node
in isy_data.net_resources
51 for node
in isy_data.root_nodes[Platform.BUTTON]:
56 unique_id=f
"{isy_data.uid_base(node)}_query",
57 entity_category=EntityCategory.DIAGNOSTIC,
58 device_info=device_info[node.address],
61 if node.protocol == PROTO_INSTEON:
66 unique_id=f
"{isy_data.uid_base(node)}_beep",
67 entity_category=EntityCategory.DIAGNOSTIC,
68 device_info=device_info[node.address],
77 unique_id=f
"{isy.uuid}_query",
78 device_info=
DeviceInfo(identifiers={(DOMAIN, isy.uuid)}),
79 entity_category=EntityCategory.DIAGNOSTIC,
87 """Representation of an ISY/IoX device button entity."""
89 _attr_should_poll =
False
90 _attr_has_entity_name =
True
94 node: Node | ISY | NetworkCommand,
97 device_info: DeviceInfo,
98 entity_category: EntityCategory |
None =
None,
100 """Initialize a query ISY device button entity."""
113 """Return entity availability."""
117 """Subscribe to the node change events."""
119 if not hasattr(self.
_node_node,
"status_events")
or not hasattr(self.
_node_node,
"isy"):
124 TAG_ADDRESS: self.
_node_node.address,
125 ATTR_ACTION: NC_NODE_ENABLED,
132 """Handle the update event from the ISY Node."""
139 """Representation of a device query button entity."""
142 """Press the button."""
143 await self.
_node_node.query()
147 """Representation of a device beep button entity."""
150 """Press the button."""
151 await self.
_node_node.beep()
155 """Representation of an ISY/IoX Network Resource button entity."""
157 _attr_has_entity_name =
False
160 """Press the button."""
None async_write_ha_state(self)
int run(RuntimeConfig runtime_config)