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:
Jake Colman 2023-08-28 09:45:01 -04:00 committed by GitHub
parent a6788208fe
commit f1378bba8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 16 deletions

View file

@ -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