Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Base classes shared among Ecobee entities."""
2 
3 from __future__ import annotations
4 
5 import logging
6 from typing import Any
7 
8 from homeassistant.helpers.device_registry import DeviceInfo
9 from homeassistant.helpers.entity import Entity
10 
11 from . import EcobeeData
12 from .const import DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER
13 
14 _LOGGER = logging.getLogger(__name__)
15 
16 
18  """Base methods for Ecobee entities."""
19 
20  def __init__(self, data: EcobeeData, thermostat_index: int) -> None:
21  """Initiate base methods for Ecobee entities."""
22  self.datadata = data
23  self.thermostat_indexthermostat_index = thermostat_index
24  thermostat = self.thermostatthermostat
25  self.base_unique_idbase_unique_id = thermostat["identifier"]
26  self._attr_device_info_attr_device_info = DeviceInfo(
27  identifiers={(DOMAIN, thermostat["identifier"])},
28  manufacturer=MANUFACTURER,
29  model=ECOBEE_MODEL_TO_NAME.get(thermostat["modelNumber"]),
30  name=thermostat["name"],
31  )
32 
33  @property
34  def thermostat(self) -> dict[str, Any]:
35  """Return the thermostat data for the entity."""
36  return self.datadata.ecobee.get_thermostat(self.thermostat_indexthermostat_index)
37 
38  @property
39  def available(self) -> bool:
40  """Return if device is available."""
41  return self.thermostatthermostat["runtime"]["connected"]
None __init__(self, EcobeeData data, int thermostat_index)
Definition: entity.py:20