Add indoor sensors to Honeywell integration (#98609)
Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: G Johansson <goran.johansson@shiftit.se>
This commit is contained in:
parent
a6788208fe
commit
f1378bba8e
6 changed files with 70 additions and 16 deletions
|
@ -21,7 +21,12 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import HoneywellData
|
||||
from .const import DOMAIN, HUMIDITY_STATUS_KEY, TEMPERATURE_STATUS_KEY
|
||||
from .const import DOMAIN
|
||||
|
||||
OUTDOOR_TEMPERATURE_STATUS_KEY = "outdoor_temperature"
|
||||
OUTDOOR_HUMIDITY_STATUS_KEY = "outdoor_humidity"
|
||||
CURRENT_TEMPERATURE_STATUS_KEY = "current_temperature"
|
||||
CURRENT_HUMIDITY_STATUS_KEY = "current_humidity"
|
||||
|
||||
|
||||
def _get_temperature_sensor_unit(device: Device) -> str:
|
||||
|
@ -48,21 +53,35 @@ class HoneywellSensorEntityDescription(
|
|||
|
||||
SENSOR_TYPES: tuple[HoneywellSensorEntityDescription, ...] = (
|
||||
HoneywellSensorEntityDescription(
|
||||
key=TEMPERATURE_STATUS_KEY,
|
||||
translation_key="outdoor_temperature",
|
||||
key=OUTDOOR_TEMPERATURE_STATUS_KEY,
|
||||
translation_key=OUTDOOR_TEMPERATURE_STATUS_KEY,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda device: device.outdoor_temperature,
|
||||
unit_fn=_get_temperature_sensor_unit,
|
||||
),
|
||||
HoneywellSensorEntityDescription(
|
||||
key=HUMIDITY_STATUS_KEY,
|
||||
translation_key="outdoor_humidity",
|
||||
key=OUTDOOR_HUMIDITY_STATUS_KEY,
|
||||
translation_key=OUTDOOR_HUMIDITY_STATUS_KEY,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda device: device.outdoor_humidity,
|
||||
unit_fn=lambda device: PERCENTAGE,
|
||||
),
|
||||
HoneywellSensorEntityDescription(
|
||||
key=CURRENT_TEMPERATURE_STATUS_KEY,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda device: device.current_temperature,
|
||||
unit_fn=_get_temperature_sensor_unit,
|
||||
),
|
||||
HoneywellSensorEntityDescription(
|
||||
key=CURRENT_HUMIDITY_STATUS_KEY,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda device: device.current_humidity,
|
||||
unit_fn=lambda device: PERCENTAGE,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -89,7 +108,7 @@ class HoneywellSensor(SensorEntity):
|
|||
entity_description: HoneywellSensorEntityDescription
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, device, description):
|
||||
def __init__(self, device, description) -> None:
|
||||
"""Initialize the outdoor temperature sensor."""
|
||||
self._device = device
|
||||
self.entity_description = description
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue