Fix Pure AQI value sensor in Sensibo (#124151)
* fix Pure AQI value sensor in Sensibo * Fix tests * Make enumpull/124194/head
parent
02b26ac4e6
commit
50f9c1e5a4
|
@ -15,5 +15,5 @@
|
|||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pysensibo"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["pysensibo==1.0.36"]
|
||||
"requirements": ["pysensibo==1.1.0"]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ from dataclasses import dataclass
|
|||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from pysensibo.model import MotionSensor, SensiboDevice
|
||||
from pysensibo.model import MotionSensor, PureAQI, SensiboDevice
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
|
@ -97,11 +97,11 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = (
|
|||
PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="pm25",
|
||||
device_class=SensorDeviceClass.PM25,
|
||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.pm25,
|
||||
translation_key="pm25_pure",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
value_fn=lambda data: data.pm25_pure.name.lower() if data.pm25_pure else None,
|
||||
extra_fn=None,
|
||||
options=[aqi.name.lower() for aqi in PureAQI],
|
||||
),
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="pure_sensitivity",
|
||||
|
|
|
@ -110,6 +110,14 @@
|
|||
"s": "Sensitive"
|
||||
}
|
||||
},
|
||||
"pm25_pure": {
|
||||
"name": "Pure AQI",
|
||||
"state": {
|
||||
"good": "Good",
|
||||
"moderate": "Moderate",
|
||||
"bad": "Bad"
|
||||
}
|
||||
},
|
||||
"timer_time": {
|
||||
"name": "Timer end time"
|
||||
},
|
||||
|
|
|
@ -2169,7 +2169,7 @@ pysaj==0.0.16
|
|||
pyschlage==2024.8.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.0.36
|
||||
pysensibo==1.1.0
|
||||
|
||||
# homeassistant.components.serial
|
||||
pyserial-asyncio-fast==0.13
|
||||
|
|
|
@ -1732,7 +1732,7 @@ pysabnzbd==1.1.1
|
|||
pyschlage==2024.8.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.0.36
|
||||
pysensibo==1.1.0
|
||||
|
||||
# homeassistant.components.acer_projector
|
||||
# homeassistant.components.crownstone
|
||||
|
|
|
@ -91,7 +91,8 @@
|
|||
'motion_sensors': dict({
|
||||
}),
|
||||
'name': 'Kitchen',
|
||||
'pm25': 1,
|
||||
'pm25': None,
|
||||
'pm25_pure': 1,
|
||||
'pure_ac_integration': False,
|
||||
'pure_boost_enabled': False,
|
||||
'pure_conf': dict({
|
||||
|
@ -424,6 +425,7 @@
|
|||
}),
|
||||
'name': 'Hallway',
|
||||
'pm25': None,
|
||||
'pm25_pure': None,
|
||||
'pure_ac_integration': None,
|
||||
'pure_boost_enabled': None,
|
||||
'pure_conf': dict({
|
||||
|
@ -550,7 +552,8 @@
|
|||
'motion_sensors': dict({
|
||||
}),
|
||||
'name': 'Bedroom',
|
||||
'pm25': 1,
|
||||
'pm25': None,
|
||||
'pm25_pure': 1,
|
||||
'pure_ac_integration': False,
|
||||
'pure_boost_enabled': False,
|
||||
'pure_conf': dict({
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
# serializer version: 1
|
||||
# name: test_sensor
|
||||
ReadOnlyDict({
|
||||
'device_class': 'pm25',
|
||||
'friendly_name': 'Kitchen PM2.5',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Kitchen Pure AQI',
|
||||
'options': list([
|
||||
'good',
|
||||
'moderate',
|
||||
'bad',
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
# name: test_sensor.1
|
||||
|
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
from datetime import timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from pysensibo.model import SensiboData
|
||||
from pysensibo.model import PureAQI, SensiboData
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
|
@ -27,17 +27,17 @@ async def test_sensor(
|
|||
"""Test the Sensibo sensor."""
|
||||
|
||||
state1 = hass.states.get("sensor.hallway_motion_sensor_battery_voltage")
|
||||
state2 = hass.states.get("sensor.kitchen_pm2_5")
|
||||
state2 = hass.states.get("sensor.kitchen_pure_aqi")
|
||||
state3 = hass.states.get("sensor.kitchen_pure_sensitivity")
|
||||
state4 = hass.states.get("sensor.hallway_climate_react_low_temperature_threshold")
|
||||
assert state1.state == "3000"
|
||||
assert state2.state == "1"
|
||||
assert state2.state == "good"
|
||||
assert state3.state == "n"
|
||||
assert state4.state == "0.0"
|
||||
assert state2.attributes == snapshot
|
||||
assert state4.attributes == snapshot
|
||||
|
||||
monkeypatch.setattr(get_data.parsed["AAZZAAZZ"], "pm25", 2)
|
||||
monkeypatch.setattr(get_data.parsed["AAZZAAZZ"], "pm25_pure", PureAQI(2))
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.sensibo.coordinator.SensiboClient.async_get_devices_data",
|
||||
|
@ -49,5 +49,5 @@ async def test_sensor(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state1 = hass.states.get("sensor.kitchen_pm2_5")
|
||||
assert state1.state == "2"
|
||||
state1 = hass.states.get("sensor.kitchen_pure_aqi")
|
||||
assert state1.state == "moderate"
|
||||
|
|
Loading…
Reference in New Issue