1 """Support for Magic home button."""
3 from __future__
import annotations
5 from flux_led.aio
import AIOWifiLedBulb
6 from flux_led.protocol
import RemoteConfig
8 from homeassistant
import config_entries
12 ButtonEntityDescription,
18 from .const
import DOMAIN
19 from .coordinator
import FluxLedUpdateCoordinator
20 from .entity
import FluxBaseEntity
22 _RESTART_KEY =
"restart"
23 _UNPAIR_REMOTES_KEY =
"unpair_remotes"
27 device_class=ButtonDeviceClass.RESTART,
30 key=_UNPAIR_REMOTES_KEY,
31 translation_key=
"unpair_remotes",
38 async_add_entities: AddEntitiesCallback,
40 """Set up Magic Home button based on a config entry."""
41 coordinator: FluxLedUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
42 device = coordinator.device
43 entities: list[FluxButton] = [
44 FluxButton(coordinator.device, entry, RESTART_BUTTON_DESCRIPTION)
46 if device.paired_remotes
is not None:
48 FluxButton(coordinator.device, entry, UNPAIR_REMOTES_DESCRIPTION)
55 """Representation of a Flux button."""
57 _attr_entity_category = EntityCategory.CONFIG
61 device: AIOWifiLedBulb,
63 description: ButtonEntityDescription,
65 """Initialize the button."""
68 base_unique_id = entry.unique_id
or entry.entry_id
72 """Send out a command."""
74 await self._device.async_reboot()
76 await self._device.async_unpair_remotes()
77 await self._device.async_config_remotes(RemoteConfig.OPEN)