Use DeviceInfo Class E (#58230)

This commit is contained in:
Robert Hillis 2021-10-23 05:44:51 -04:00 committed by GitHub
parent 137d41d8b4
commit 12c067970a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 111 additions and 99 deletions

View file

@ -38,6 +38,7 @@ from homeassistant.const import (
)
from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.util.temperature import convert
from .const import _LOGGER, DOMAIN, ECOBEE_MODEL_TO_NAME, MANUFACTURER
@ -366,20 +367,21 @@ class Thermostat(ClimateEntity):
return self.thermostat["identifier"]
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return device information for this ecobee thermostat."""
model: str | None
try:
model = f"{ECOBEE_MODEL_TO_NAME[self.thermostat['modelNumber']]} Thermostat"
except KeyError:
# Ecobee model is not in our list
model = None
return {
"identifiers": {(DOMAIN, self.thermostat["identifier"])},
"name": self.name,
"manufacturer": MANUFACTURER,
"model": model,
}
return DeviceInfo(
identifiers={(DOMAIN, self.thermostat["identifier"])},
manufacturer=MANUFACTURER,
model=model,
name=self.name,
)
@property
def temperature_unit(self):