1 """Support for LinkPlay buttons."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from dataclasses
import dataclass
10 from linkplay.bridge
import LinkPlayBridge
15 ButtonEntityDescription,
21 from .
import LinkPlayConfigEntry
22 from .entity
import LinkPlayBaseEntity, exception_wrap
24 _LOGGER = logging.getLogger(__name__)
27 @dataclass(frozen=True, kw_only=True)
29 """Class describing LinkPlay button entities."""
31 remote_function: Callable[[LinkPlayBridge], Coroutine[Any, Any,
None]]
34 BUTTON_TYPES: tuple[LinkPlayButtonEntityDescription, ...] = (
37 translation_key=
"timesync",
38 remote_function=
lambda linkplay_bridge: linkplay_bridge.device.timesync(),
39 entity_category=EntityCategory.CONFIG,
43 device_class=ButtonDeviceClass.RESTART,
44 remote_function=
lambda linkplay_bridge: linkplay_bridge.device.reboot(),
45 entity_category=EntityCategory.CONFIG,
52 config_entry: LinkPlayConfigEntry,
53 async_add_entities: AddEntitiesCallback,
55 """Set up the LinkPlay buttons from config entry."""
60 for description
in BUTTON_TYPES
65 """Representation of LinkPlay button."""
67 entity_description: LinkPlayButtonEntityDescription
71 bridge: LinkPlayBridge,
72 description: LinkPlayButtonEntityDescription,
74 """Initialize LinkPlay button."""
81 """Press the button."""