Home Assistant Unofficial Reference 2024.12.1
button.py
Go to the documentation of this file.
1 """Support for Velbus Buttons."""
2 
3 from __future__ import annotations
4 
5 from velbusaio.channels import (
6  Button as VelbusaioButton,
7  ButtonCounter as VelbusaioButtonCounter,
8 )
9 
10 from homeassistant.components.button import ButtonEntity
11 from homeassistant.config_entries import ConfigEntry
12 from homeassistant.const import EntityCategory
13 from homeassistant.core import HomeAssistant
14 from homeassistant.helpers.entity_platform import AddEntitiesCallback
15 
16 from .const import DOMAIN
17 from .entity import VelbusEntity, api_call
18 
19 
21  hass: HomeAssistant,
22  entry: ConfigEntry,
23  async_add_entities: AddEntitiesCallback,
24 ) -> None:
25  """Set up Velbus switch based on config_entry."""
26  await hass.data[DOMAIN][entry.entry_id]["tsk"]
27  cntrl = hass.data[DOMAIN][entry.entry_id]["cntrl"]
28  async_add_entities(VelbusButton(channel) for channel in cntrl.get_all("button"))
29 
30 
32  """Representation of a Velbus Binary Sensor."""
33 
34  _channel: VelbusaioButton | VelbusaioButtonCounter
35  _attr_entity_registry_enabled_default = False
36  _attr_entity_category = EntityCategory.CONFIG
37 
38  @api_call
39  async def async_press(self) -> None:
40  """Handle the button press."""
41  await self._channel_channel.press()
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: button.py:24