1 """Support for Freebox devices (Freebox v6 and Freebox mini 4K)."""
3 from __future__
import annotations
5 from collections.abc
import Awaitable, Callable
6 from dataclasses
import dataclass
11 ButtonEntityDescription,
18 from .const
import DOMAIN
19 from .router
import FreeboxRouter
22 @dataclass(frozen=True, kw_only=True)
24 """Class describing Freebox button entities."""
26 async_press: Callable[[FreeboxRouter], Awaitable]
29 BUTTON_DESCRIPTIONS: tuple[FreeboxButtonEntityDescription, ...] = (
32 name=
"Reboot Freebox",
33 device_class=ButtonDeviceClass.RESTART,
34 entity_category=EntityCategory.CONFIG,
35 async_press=
lambda router: router.reboot(),
38 key=
"mark_calls_as_read",
39 name=
"Mark calls as read",
40 entity_category=EntityCategory.DIAGNOSTIC,
41 async_press=
lambda router: router.call.mark_calls_log_as_read(),
47 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
49 """Set up the buttons."""
50 router: FreeboxRouter = hass.data[DOMAIN][entry.unique_id]
52 FreeboxButton(router, description)
for description
in BUTTON_DESCRIPTIONS
58 """Representation of a Freebox button."""
60 entity_description: FreeboxButtonEntityDescription
63 self, router: FreeboxRouter, description: FreeboxButtonEntityDescription
65 """Initialize a Freebox button."""
72 """Press the button."""