Home Assistant Unofficial Reference 2024.12.1
button.py
Go to the documentation of this file.
1 """Support for HomematicIP Cloud button devices."""
2 
3 from __future__ import annotations
4 
5 from homematicip.aio.device import AsyncWallMountedGarageDoorController
6 
7 from homeassistant.components.button import ButtonEntity
8 from homeassistant.config_entries import ConfigEntry
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.entity_platform import AddEntitiesCallback
11 
12 from .const import DOMAIN
13 from .entity import HomematicipGenericEntity
14 from .hap import HomematicipHAP
15 
16 
18  hass: HomeAssistant,
19  config_entry: ConfigEntry,
20  async_add_entities: AddEntitiesCallback,
21 ) -> None:
22  """Set up the HomematicIP button from a config entry."""
23  hap = hass.data[DOMAIN][config_entry.unique_id]
24 
27  for device in hap.home.devices
28  if isinstance(device, AsyncWallMountedGarageDoorController)
29  )
30 
31 
33  """Representation of the HomematicIP Wall mounted Garage Door Controller."""
34 
35  def __init__(self, hap: HomematicipHAP, device) -> None:
36  """Initialize a wall mounted garage door controller."""
37  super().__init__(hap, device)
38  self._attr_icon_attr_icon = "mdi:arrow-up-down"
39 
40  async def async_press(self) -> None:
41  """Handle the button press."""
42  await self._device_device.send_start_impulse()
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: button.py:21