1 """Support for OpenTherm Gateway buttons."""
3 from collections.abc
import Awaitable, Callable
4 from dataclasses
import dataclass
6 import pyotgw.vars
as gw_vars
11 ButtonEntityDescription,
18 from .
import OpenThermGatewayHub
19 from .const
import DATA_GATEWAYS, DATA_OPENTHERM_GW, GATEWAY_DEVICE_DESCRIPTION
20 from .entity
import OpenThermEntity, OpenThermEntityDescription
23 @dataclass(frozen=True, kw_only=True)
25 ButtonEntityDescription, OpenThermEntityDescription
27 """Describes an opentherm_gw button entity."""
29 action: Callable[[OpenThermGatewayHub], Awaitable]
32 BUTTON_DESCRIPTIONS: tuple[OpenThermButtonEntityDescription, ...] = (
35 device_class=ButtonDeviceClass.RESTART,
36 device_description=GATEWAY_DEVICE_DESCRIPTION,
37 action=
lambda hub: hub.gateway.set_mode(gw_vars.OTGW_MODE_RESET),
44 config_entry: ConfigEntry,
45 async_add_entities: AddEntitiesCallback,
47 """Set up the OpenTherm Gateway buttons."""
48 gw_hub = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]]
51 OpenThermButton(gw_hub, description)
for description
in BUTTON_DESCRIPTIONS
56 """Representation of an OpenTherm button."""
58 _attr_entity_category = EntityCategory.CONFIG
59 entity_description: OpenThermButtonEntityDescription
62 """Perform button action."""