1 """Fully Kiosk Browser button."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 from fullykiosk
import FullyKiosk
14 ButtonEntityDescription,
20 from .
import FullyKioskConfigEntry
21 from .coordinator
import FullyKioskDataUpdateCoordinator
22 from .entity
import FullyKioskEntity
25 @dataclass(frozen=True, kw_only=True)
27 """Fully Kiosk Browser button description."""
29 press_action: Callable[[FullyKiosk], Any]
32 BUTTONS: tuple[FullyButtonEntityDescription, ...] = (
35 translation_key=
"restart_browser",
36 device_class=ButtonDeviceClass.RESTART,
37 entity_category=EntityCategory.CONFIG,
38 press_action=
lambda fully: fully.restartApp(),
42 translation_key=
"restart_device",
43 device_class=ButtonDeviceClass.RESTART,
44 entity_category=EntityCategory.CONFIG,
45 press_action=
lambda fully: fully.rebootDevice(),
49 translation_key=
"to_foreground",
50 entity_category=EntityCategory.CONFIG,
51 press_action=
lambda fully: fully.toForeground(),
55 translation_key=
"to_background",
56 entity_category=EntityCategory.CONFIG,
57 press_action=
lambda fully: fully.toBackground(),
61 translation_key=
"load_start_url",
62 entity_category=EntityCategory.CONFIG,
63 press_action=
lambda fully: fully.loadStartUrl(),
70 config_entry: FullyKioskConfigEntry,
71 async_add_entities: AddEntitiesCallback,
73 """Set up the Fully Kiosk Browser button entities."""
74 coordinator = config_entry.runtime_data
82 """Representation of a Fully Kiosk Browser button."""
84 entity_description: FullyButtonEntityDescription
88 coordinator: FullyKioskDataUpdateCoordinator,
89 description: FullyButtonEntityDescription,
91 """Initialize the button."""
94 self.
_attr_unique_id_attr_unique_id = f
"{coordinator.data['deviceID']}-{description.key}"
97 """Set the value of the entity."""