Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Provides the Lupusec entity for Home Assistant."""
2 
3 import lupupy
4 
5 from homeassistant.helpers.device_registry import DeviceInfo
6 from homeassistant.helpers.entity import Entity
7 
8 from .const import DOMAIN, TYPE_TRANSLATION
9 
10 
12  """Representation of a Lupusec device."""
13 
14  _attr_has_entity_name = True
15 
16  def __init__(self, device: lupupy.devices.LupusecDevice) -> None:
17  """Initialize a sensor for Lupusec device."""
18  self._device_device = device
19  self._attr_unique_id_attr_unique_id = device.device_id
20 
21  def update(self):
22  """Update automation state."""
23  self._device_device.refresh()
24 
25 
27  """Lupusec Sensor base entity."""
28 
29  def __init__(self, device: lupupy.devices.LupusecDevice, entry_id: str) -> None:
30  """Initialize the LupusecBaseSensor."""
31  super().__init__(device)
32 
33  self._attr_device_info_attr_device_info = DeviceInfo(
34  identifiers={(DOMAIN, device.device_id)},
35  name=device.name,
36  manufacturer="Lupus Electronics",
37  serial_number=device.device_id,
38  model=TYPE_TRANSLATION.get(device.type, device.type),
39  via_device=(DOMAIN, entry_id),
40  )
41 
42  def get_type_name(self) -> str:
43  """Return the type of the sensor."""
44  return TYPE_TRANSLATION.get(self._device_device.type, self._device_device.type)
None __init__(self, lupupy.devices.LupusecDevice device, str entry_id)
Definition: entity.py:29
None __init__(self, lupupy.devices.LupusecDevice device)
Definition: entity.py:16