From d3d6870c0427d2ff9c71b0d98aab8d478a657b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 24 Feb 2024 14:39:53 +0100 Subject: [PATCH] Add Airzone Cloud Air Quality zone sensors (#106571) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * airzone-cloud: add Air Quality sensors Signed-off-by: Álvaro Fernández Rojas * tests: airzone_cloud: add missing AQI test Signed-off-by: Álvaro Fernández Rojas --------- Signed-off-by: Álvaro Fernández Rojas --- .../components/airzone_cloud/sensor.py | 28 +++++++++++++++++++ tests/components/airzone_cloud/test_sensor.py | 24 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/homeassistant/components/airzone_cloud/sensor.py b/homeassistant/components/airzone_cloud/sensor.py index f45fd248cd5..965ac24a64f 100644 --- a/homeassistant/components/airzone_cloud/sensor.py +++ b/homeassistant/components/airzone_cloud/sensor.py @@ -5,6 +5,10 @@ from typing import Any, Final from aioairzone_cloud.const import ( AZD_AIDOOS, + AZD_AQ_INDEX, + AZD_AQ_PM_1, + AZD_AQ_PM_2P5, + AZD_AQ_PM_10, AZD_HUMIDITY, AZD_TEMP, AZD_WEBSERVERS, @@ -20,6 +24,7 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( + CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, EntityCategory, @@ -58,6 +63,29 @@ WEBSERVER_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( ) ZONE_SENSOR_TYPES: Final[tuple[SensorEntityDescription, ...]] = ( + SensorEntityDescription( + device_class=SensorDeviceClass.AQI, + key=AZD_AQ_INDEX, + state_class=SensorStateClass.MEASUREMENT, + ), + SensorEntityDescription( + device_class=SensorDeviceClass.PM1, + key=AZD_AQ_PM_1, + native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + state_class=SensorStateClass.MEASUREMENT, + ), + SensorEntityDescription( + device_class=SensorDeviceClass.PM25, + key=AZD_AQ_PM_2P5, + native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + state_class=SensorStateClass.MEASUREMENT, + ), + SensorEntityDescription( + device_class=SensorDeviceClass.PM10, + key=AZD_AQ_PM_10, + native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + state_class=SensorStateClass.MEASUREMENT, + ), SensorEntityDescription( device_class=SensorDeviceClass.TEMPERATURE, key=AZD_TEMP, diff --git a/tests/components/airzone_cloud/test_sensor.py b/tests/components/airzone_cloud/test_sensor.py index b370e75c9aa..5000f1cabea 100644 --- a/tests/components/airzone_cloud/test_sensor.py +++ b/tests/components/airzone_cloud/test_sensor.py @@ -27,12 +27,36 @@ async def test_airzone_create_sensors( assert state.state == "-77" # Zones + state = hass.states.get("sensor.dormitorio_air_quality_index") + assert state.state == "1" + + state = hass.states.get("sensor.dormitorio_pm1") + assert state.state == "3" + + state = hass.states.get("sensor.dormitorio_pm2_5") + assert state.state == "4" + + state = hass.states.get("sensor.dormitorio_pm10") + assert state.state == "3" + state = hass.states.get("sensor.dormitorio_temperature") assert state.state == "25.0" state = hass.states.get("sensor.dormitorio_humidity") assert state.state == "24" + state = hass.states.get("sensor.dormitorio_air_quality_index") + assert state.state == "1" + + state = hass.states.get("sensor.salon_pm1") + assert state.state == "3" + + state = hass.states.get("sensor.salon_pm2_5") + assert state.state == "4" + + state = hass.states.get("sensor.salon_pm10") + assert state.state == "3" + state = hass.states.get("sensor.salon_temperature") assert state.state == "20.0"