mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add device registry support to ecobee integration (#27109)
* Add manufacturer const * Add device_info to binary sensor * Add device info to climate * Add device info to sensor * Add device info to weather * Add constant for device info * Fix log messages * Use guard clauses
This commit is contained in:
committed by
Martin Hjelmare
parent
f500367721
commit
98eaecf61d
@@ -4,7 +4,7 @@ from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
)
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER, _LOGGER
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
@@ -52,6 +52,44 @@ class EcobeeBinarySensor(BinarySensorDevice):
|
||||
return f"{sensor['code']}-{self.device_class}"
|
||||
return f"{sensor['id']}-{self.device_class}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return device information for this sensor."""
|
||||
identifier = None
|
||||
model = None
|
||||
for sensor in self.data.ecobee.get_remote_sensors(self.index):
|
||||
if sensor["name"] != self.sensor_name:
|
||||
continue
|
||||
if "code" in sensor:
|
||||
identifier = sensor["code"]
|
||||
model = "ecobee Room Sensor"
|
||||
else:
|
||||
thermostat = self.data.ecobee.get_thermostat(self.index)
|
||||
identifier = thermostat["identifier"]
|
||||
try:
|
||||
model = (
|
||||
f"{ECOBEE_MODEL_TO_NAME[thermostat['modelNumber']]} Thermostat"
|
||||
)
|
||||
except KeyError:
|
||||
_LOGGER.error(
|
||||
"Model number for ecobee thermostat %s not recognized. "
|
||||
"Please visit this link and provide the following information: "
|
||||
"https://github.com/home-assistant/home-assistant/issues/27172 "
|
||||
"Unrecognized model number: %s",
|
||||
thermostat["name"],
|
||||
thermostat["modelNumber"],
|
||||
)
|
||||
break
|
||||
|
||||
if identifier is not None and model is not None:
|
||||
return {
|
||||
"identifiers": {(DOMAIN, identifier)},
|
||||
"name": self.sensor_name,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": model,
|
||||
}
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the status of the sensor."""
|
||||
|
||||
Reference in New Issue
Block a user