Home Assistant Unofficial Reference 2024.12.1
button.py
Go to the documentation of this file.
1 """Support for Phone Modem button."""
2 
3 from __future__ import annotations
4 
5 from phone_modem import PhoneModem
6 
7 from homeassistant.components.button import ButtonEntity
8 from homeassistant.config_entries import ConfigEntry
9 from homeassistant.const import CONF_DEVICE
10 from homeassistant.core import HomeAssistant
11 from homeassistant.helpers.device_registry import DeviceInfo
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 
14 from .const import DATA_KEY_API, DOMAIN
15 
16 
18  hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
19 ) -> None:
20  """Set up the Modem Caller ID sensor."""
21  api = hass.data[DOMAIN][entry.entry_id][DATA_KEY_API]
23  [
25  api,
26  entry.data[CONF_DEVICE],
27  entry.entry_id,
28  )
29  ]
30  )
31 
32 
34  """Implementation of USB modem caller ID button."""
35 
36  _attr_translation_key = "phone_modem_reject"
37  _attr_has_entity_name = True
38 
39  def __init__(self, api: PhoneModem, device: str, server_unique_id: str) -> None:
40  """Initialize the button."""
41  self.devicedevice = device
42  self.apiapi = api
43  self._attr_unique_id_attr_unique_id = server_unique_id
44  self._attr_device_info_attr_device_info = DeviceInfo(identifiers={(DOMAIN, server_unique_id)})
45 
46  async def async_press(self) -> None:
47  """Press the button."""
48  await self.apiapi.reject_call(self.devicedevice)
None __init__(self, PhoneModem api, str device, str server_unique_id)
Definition: button.py:39
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: button.py:19