Add DeviceInfo to Honeywell (#86179)

* Add DeviceInfo
Add has_entity_name

* has_entity_name to class attribute

* Update homeassistant/components/honeywell/sensor.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Update homeassistant/components/honeywell/sensor.py

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
pull/86712/head
mkmer 2023-01-26 07:28:36 -05:00 committed by GitHub
parent 282d6af2a2
commit 6ea234ed57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -24,6 +24,7 @@ from homeassistant.components.climate import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HoneywellData
@ -97,6 +98,8 @@ async def async_setup_entry(
class HoneywellUSThermostat(ClimateEntity):
"""Representation of a Honeywell US Thermostat."""
_attr_has_entity_name = True
def __init__(
self,
data: HoneywellData,
@ -112,7 +115,13 @@ class HoneywellUSThermostat(ClimateEntity):
self._away = False
self._attr_unique_id = device.deviceid
self._attr_name = device.name
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device.deviceid)},
name=device.name,
manufacturer="Honeywell",
)
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
if device.temperature_unit == "C":
self._attr_temperature_unit = UnitOfTemperature.CELSIUS

View File

@ -16,6 +16,7 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@ -47,7 +48,7 @@ class HoneywellSensorEntityDescription(
SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
HoneywellSensorEntityDescription(
key=TEMPERATURE_STATUS_KEY,
name="Temperature",
name="Outdoor temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda device: device.outdoor_temperature,
@ -55,7 +56,7 @@ SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
),
HoneywellSensorEntityDescription(
key=HUMIDITY_STATUS_KEY,
name="Humidity",
name="Outdoor humidity",
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda device: device.outdoor_humidity,
@ -85,15 +86,21 @@ class HoneywellSensor(SensorEntity):
"""Representation of a Honeywell US Outdoor Temperature Sensor."""
entity_description: HoneywellSensorEntityDescription
_attr_has_entity_name = True
def __init__(self, device, description):
"""Initialize the outdoor temperature sensor."""
self._device = device
self.entity_description = description
self._attr_unique_id = f"{device.deviceid}_{description.key}"
self._attr_name = f"{device.name} outdoor {description.device_class}"
self._attr_native_unit_of_measurement = description.unit_fn(device)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device.deviceid)},
name=device.name,
manufacturer="Honeywell",
)
@property
def native_value(self) -> StateType:
"""Return the state."""