Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base entity class for WeatherFlow Cloud integration."""
2 
3 from weatherflow4py.models.rest.unified import WeatherFlowDataREST
4 
5 from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
6 from homeassistant.helpers.update_coordinator import CoordinatorEntity
7 
8 from .const import ATTR_ATTRIBUTION, DOMAIN, MANUFACTURER
9 from .coordinator import WeatherFlowCloudDataUpdateCoordinator
10 
11 
12 class WeatherFlowCloudEntity(CoordinatorEntity[WeatherFlowCloudDataUpdateCoordinator]):
13  """Base entity class to use for everything."""
14 
15  _attr_attribution = ATTR_ATTRIBUTION
16  _attr_has_entity_name = True
17 
18  def __init__(
19  self,
20  coordinator: WeatherFlowCloudDataUpdateCoordinator,
21  station_id: int,
22  ) -> None:
23  """Class initializer."""
24  super().__init__(coordinator)
25  self.station_idstation_id = station_id
26 
27  self._attr_device_info_attr_device_info = DeviceInfo(
28  name=self.stationstation.station.name,
29  entry_type=DeviceEntryType.SERVICE,
30  identifiers={(DOMAIN, str(station_id))},
31  manufacturer=MANUFACTURER,
32  configuration_url=f"https://tempestwx.com/station/{station_id}/grid",
33  )
34 
35  @property
36  def station(self) -> WeatherFlowDataREST:
37  """Individual Station data."""
38  return self.coordinator.data[self.station_idstation_id]
None __init__(self, WeatherFlowCloudDataUpdateCoordinator coordinator, int station_id)
Definition: entity.py:22