Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new deCONZ Particulate Matter endpoint #104276

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/deconz/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"iot_class": "local_push",
"loggers": ["pydeconz"],
"quality_scale": "platinum",
"requirements": ["pydeconz==113"],
"requirements": ["pydeconz==114"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics",
Expand Down
13 changes: 13 additions & 0 deletions homeassistant/components/deconz/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -83,6 +84,7 @@
Humidity,
LightLevel,
Moisture,
ParticulateMatter,
Power,
Pressure,
Temperature,
Expand Down Expand Up @@ -213,6 +215,17 @@ class DeconzSensorDescription(Generic[T], SensorEntityDescription):
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,
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ pydaikin==2.11.1
pydanfossair==0.1.0

# homeassistant.components.deconz
pydeconz==113
pydeconz==114

# homeassistant.components.delijn
pydelijn==1.1.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ pycsspeechtts==1.0.8
pydaikin==2.11.1

# homeassistant.components.deconz
pydeconz==113
pydeconz==114

# homeassistant.components.dexcom
pydexcom==0.2.3
Expand Down
49 changes: 49 additions & 0 deletions tests/components/deconz/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,55 @@ async def test_no_sensors(
"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": {
Expand Down