Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """The pi_hole component."""
2 
3 from __future__ import annotations
4 
5 from hole import Hole
6 
7 from homeassistant.helpers.device_registry import DeviceInfo
9  CoordinatorEntity,
10  DataUpdateCoordinator,
11 )
12 
13 from .const import DOMAIN
14 
15 
16 class PiHoleEntity(CoordinatorEntity[DataUpdateCoordinator[None]]):
17  """Representation of a Pi-hole entity."""
18 
19  def __init__(
20  self,
21  api: Hole,
22  coordinator: DataUpdateCoordinator[None],
23  name: str,
24  server_unique_id: str,
25  ) -> None:
26  """Initialize a Pi-hole entity."""
27  super().__init__(coordinator)
28  self.apiapi = api
29  self._name_name = name
30  self._server_unique_id_server_unique_id = server_unique_id
31 
32  @property
33  def device_info(self) -> DeviceInfo:
34  """Return the device information of the entity."""
35  if self.apiapi.tls:
36  config_url = f"https://{self.api.host}/{self.api.location}"
37  else:
38  config_url = f"http://{self.api.host}/{self.api.location}"
39 
40  return DeviceInfo(
41  identifiers={(DOMAIN, self._server_unique_id_server_unique_id)},
42  name=self._name_name,
43  manufacturer="Pi-hole",
44  configuration_url=config_url,
45  )
None __init__(self, Hole api, DataUpdateCoordinator[None] coordinator, str name, str server_unique_id)
Definition: entity.py:25