mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
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>
This commit is contained in:
parent
282d6af2a2
commit
6ea234ed57
@ -24,6 +24,7 @@ from homeassistant.components.climate import (
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import HoneywellData
|
from . import HoneywellData
|
||||||
@ -97,6 +98,8 @@ async def async_setup_entry(
|
|||||||
class HoneywellUSThermostat(ClimateEntity):
|
class HoneywellUSThermostat(ClimateEntity):
|
||||||
"""Representation of a Honeywell US Thermostat."""
|
"""Representation of a Honeywell US Thermostat."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data: HoneywellData,
|
data: HoneywellData,
|
||||||
@ -112,7 +115,13 @@ class HoneywellUSThermostat(ClimateEntity):
|
|||||||
self._away = False
|
self._away = False
|
||||||
|
|
||||||
self._attr_unique_id = device.deviceid
|
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
|
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||||
if device.temperature_unit == "C":
|
if device.temperature_unit == "C":
|
||||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.components.sensor import (
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE, UnitOfTemperature
|
from homeassistant.const import PERCENTAGE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ class HoneywellSensorEntityDescription(
|
|||||||
SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
|
||||||
HoneywellSensorEntityDescription(
|
HoneywellSensorEntityDescription(
|
||||||
key=TEMPERATURE_STATUS_KEY,
|
key=TEMPERATURE_STATUS_KEY,
|
||||||
name="Temperature",
|
name="Outdoor temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda device: device.outdoor_temperature,
|
value_fn=lambda device: device.outdoor_temperature,
|
||||||
@ -55,7 +56,7 @@ SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
HoneywellSensorEntityDescription(
|
HoneywellSensorEntityDescription(
|
||||||
key=HUMIDITY_STATUS_KEY,
|
key=HUMIDITY_STATUS_KEY,
|
||||||
name="Humidity",
|
name="Outdoor humidity",
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda device: device.outdoor_humidity,
|
value_fn=lambda device: device.outdoor_humidity,
|
||||||
@ -85,15 +86,21 @@ class HoneywellSensor(SensorEntity):
|
|||||||
"""Representation of a Honeywell US Outdoor Temperature Sensor."""
|
"""Representation of a Honeywell US Outdoor Temperature Sensor."""
|
||||||
|
|
||||||
entity_description: HoneywellSensorEntityDescription
|
entity_description: HoneywellSensorEntityDescription
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, device, description):
|
def __init__(self, device, description):
|
||||||
"""Initialize the outdoor temperature sensor."""
|
"""Initialize the outdoor temperature sensor."""
|
||||||
self._device = device
|
self._device = device
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{device.deviceid}_{description.key}"
|
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_native_unit_of_measurement = description.unit_fn(device)
|
||||||
|
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, device.deviceid)},
|
||||||
|
name=device.name,
|
||||||
|
manufacturer="Honeywell",
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state."""
|
"""Return the state."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user