Support new deCONZ Particulate Matter endpoint (#104276)

pull/92906/head^2
Robert Svensson 2023-11-24 11:39:13 +01:00 committed by GitHub
parent 3c72cd7612
commit b41b56e54c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 3 deletions

View File

@ -8,7 +8,7 @@
"iot_class": "local_push",
"loggers": ["pydeconz"],
"quality_scale": "platinum",
"requirements": ["pydeconz==113"],
"requirements": ["pydeconz==114"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics",

View File

@ -17,6 +17,7 @@ from pydeconz.models.sensor.generic_status import GenericStatus
from pydeconz.models.sensor.humidity import Humidity
from pydeconz.models.sensor.light_level import LightLevel
from pydeconz.models.sensor.moisture import Moisture
from pydeconz.models.sensor.particulate_matter import ParticulateMatter
from pydeconz.models.sensor.power import Power
from pydeconz.models.sensor.pressure import Pressure
from pydeconz.models.sensor.switch import Switch
@ -83,6 +84,7 @@ T = TypeVar(
Humidity,
LightLevel,
Moisture,
ParticulateMatter,
Power,
Pressure,
Temperature,
@ -213,6 +215,17 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
native_unit_of_measurement=PERCENTAGE,
suggested_display_precision=1,
),
DeconzSensorDescription[ParticulateMatter](
key="particulate_matter_pm2_5",
supported_fn=lambda device: device.measured_value is not None,
update_key="measured_value",
value_fn=lambda device: device.measured_value,
instance_check=ParticulateMatter,
name_suffix="PM25",
device_class=SensorDeviceClass.PM25,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
),
DeconzSensorDescription[Power](
key="power",
supported_fn=lambda device: device.power is not None,

View File

@ -1680,7 +1680,7 @@ pydaikin==2.11.1
pydanfossair==0.1.0
# homeassistant.components.deconz
pydeconz==113
pydeconz==114
# homeassistant.components.delijn
pydelijn==1.1.0

View File

@ -1272,7 +1272,7 @@ pycsspeechtts==1.0.8
pydaikin==2.11.1
# homeassistant.components.deconz
pydeconz==113
pydeconz==114
# homeassistant.components.dexcom
pydexcom==0.2.3

View File

@ -530,6 +530,55 @@ TEST_DATA = [
"next_state": "1.3",
},
),
( # Particulate matter -> pm2_5
{
"capabilities": {
"measured_value": {
"max": 999,
"min": 0,
"quantity": "density",
"substance": "PM2.5",
"unit": "ug/m^3",
}
},
"config": {"on": True, "reachable": True},
"ep": 1,
"etag": "2a67a4b5cbcc20532c0ee75e2abac0c3",
"lastannounced": None,
"lastseen": "2023-10-29T12:59Z",
"manufacturername": "IKEA of Sweden",
"modelid": "STARKVIND Air purifier table",
"name": "STARKVIND AirPurifier",
"productid": "E2006",
"state": {
"airquality": "excellent",
"lastupdated": "2023-10-29T12:59:27.976",
"measured_value": 1,
"pm2_5": 1,
},
"swversion": "1.1.001",
"type": "ZHAParticulateMatter",
"uniqueid": "xx:xx:xx:xx:xx:xx:xx:xx-01-042a",
},
{
"entity_count": 1,
"device_count": 3,
"entity_id": "sensor.starkvind_airpurifier_pm25",
"unique_id": "xx:xx:xx:xx:xx:xx:xx:xx-01-042a-particulate_matter_pm2_5",
"state": "1",
"entity_category": None,
"device_class": SensorDeviceClass.PM25,
"state_class": SensorStateClass.MEASUREMENT,
"attributes": {
"friendly_name": "STARKVIND AirPurifier PM25",
"device_class": SensorDeviceClass.PM25,
"state_class": SensorStateClass.MEASUREMENT,
"unit_of_measurement": CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
},
"websocket_event": {"state": {"measured_value": 2}},
"next_state": "2",
},
),
( # Power sensor
{
"config": {