Home Assistant Unofficial Reference 2024.12.1
button.py
Go to the documentation of this file.
1 """Support for Nanoleaf buttons."""
2 
3 from homeassistant.components.button import ButtonDeviceClass, ButtonEntity
4 from homeassistant.const import EntityCategory
5 from homeassistant.core import HomeAssistant
6 from homeassistant.helpers.entity_platform import AddEntitiesCallback
7 
8 from . import NanoleafConfigEntry
9 from .coordinator import NanoleafCoordinator
10 from .entity import NanoleafEntity
11 
12 
14  hass: HomeAssistant,
15  entry: NanoleafConfigEntry,
16  async_add_entities: AddEntitiesCallback,
17 ) -> None:
18  """Set up the Nanoleaf button."""
19  async_add_entities([NanoleafIdentifyButton(entry.runtime_data)])
20 
21 
23  """Representation of a Nanoleaf identify button."""
24 
25  _attr_entity_category = EntityCategory.CONFIG
26  _attr_device_class = ButtonDeviceClass.IDENTIFY
27 
28  def __init__(self, coordinator: NanoleafCoordinator) -> None:
29  """Initialize the Nanoleaf button."""
30  super().__init__(coordinator)
31  self._attr_unique_id_attr_unique_id = f"{self._nanoleaf.serial_no}_identify"
32 
33  async def async_press(self) -> None:
34  """Identify the Nanoleaf."""
35  await self._nanoleaf_nanoleaf.identify()
None __init__(self, NanoleafCoordinator coordinator)
Definition: button.py:28
None async_setup_entry(HomeAssistant hass, NanoleafConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: button.py:17