1 """Support for Ecobee binary sensors."""
3 from __future__
import annotations
6 BinarySensorDeviceClass,
14 from .const
import DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER
19 config_entry: ConfigEntry,
20 async_add_entities: AddEntitiesCallback,
22 """Set up ecobee binary (occupancy) sensors."""
23 data = hass.data[DOMAIN]
25 for index
in range(len(data.ecobee.thermostats)):
26 for sensor
in data.ecobee.get_remote_sensors(index):
27 for item
in sensor[
"capability"]:
28 if item[
"type"] !=
"occupancy":
37 """Representation of an Ecobee sensor."""
39 _attr_device_class = BinarySensorDeviceClass.OCCUPANCY
40 _attr_has_entity_name =
True
42 def __init__(self, data, sensor_name, sensor_index):
43 """Initialize the Ecobee sensor."""
50 """Return a unique identifier for this sensor."""
51 for sensor
in self.
datadata.ecobee.get_remote_sensors(self.
indexindex):
54 return f
"{sensor['code']}-{self.device_class}"
55 thermostat = self.
datadata.ecobee.get_thermostat(self.
indexindex)
56 return f
"{thermostat['identifier']}-{sensor['id']}-{self.device_class}"
61 """Return device information for this sensor."""
64 for sensor
in self.
datadata.ecobee.get_remote_sensors(self.
indexindex):
68 identifier = sensor[
"code"]
69 model =
"ecobee Room Sensor"
71 thermostat = self.
datadata.ecobee.get_thermostat(self.
indexindex)
72 identifier = thermostat[
"identifier"]
75 f
"{ECOBEE_MODEL_TO_NAME[thermostat['modelNumber']]} Thermostat"
82 if identifier
is not None:
84 identifiers={(DOMAIN, identifier)},
85 manufacturer=MANUFACTURER,
93 """Return true if device is available."""
94 thermostat = self.
datadata.ecobee.get_thermostat(self.
indexindex)
95 return thermostat[
"runtime"][
"connected"]
98 """Get the latest state of the sensor."""
100 for sensor
in self.
datadata.ecobee.get_remote_sensors(self.
indexindex):
103 for item
in sensor[
"capability"]:
104 if item[
"type"] !=
"occupancy":
DeviceInfo|None device_info(self)
def __init__(self, data, sensor_name, sensor_index)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
IssData update(pyiss.ISS iss)