mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 19:40:11 +00:00
Matter sensors for air quality measurements (#108173)
* Matter sensors for air quality measurements Add sensors for CO2, PM1, PM2.5, PM10 and TVOC * Add initial tests for matter air quality sensor * Remove VOC data as requires unit extraction from cluster
This commit is contained in:
@@ -76,6 +76,16 @@ async def eve_energy_plug_node_fixture(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="air_quality_sensor_node")
|
||||
async def air_quality_sensor_node_fixture(
|
||||
hass: HomeAssistant, matter_client: MagicMock
|
||||
) -> MatterNode:
|
||||
"""Fixture for an air quality sensor (LightFi AQ1) node."""
|
||||
return await setup_integration_with_node_fixture(
|
||||
hass, "air-quality-sensor", matter_client
|
||||
)
|
||||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_sensor_null_value(
|
||||
@@ -288,3 +298,60 @@ async def test_eve_energy_sensors(
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
assert state.state == "5.0"
|
||||
|
||||
|
||||
# This tests needs to be adjusted to remove lingering tasks
|
||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||
async def test_air_quality_sensor(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
air_quality_sensor_node: MatterNode,
|
||||
) -> None:
|
||||
"""Test air quality sensor."""
|
||||
# Carbon Dioxide
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_carbon_dioxide")
|
||||
assert state
|
||||
assert state.state == "678.0"
|
||||
|
||||
set_node_attribute(air_quality_sensor_node, 1, 1037, 0, 789)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_carbon_dioxide")
|
||||
assert state
|
||||
assert state.state == "789.0"
|
||||
|
||||
# PM1
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm1")
|
||||
assert state
|
||||
assert state.state == "3.0"
|
||||
|
||||
set_node_attribute(air_quality_sensor_node, 1, 1068, 0, 50)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm1")
|
||||
assert state
|
||||
assert state.state == "50.0"
|
||||
|
||||
# PM2.5
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm2_5")
|
||||
assert state
|
||||
assert state.state == "3.0"
|
||||
|
||||
set_node_attribute(air_quality_sensor_node, 1, 1066, 0, 50)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm2_5")
|
||||
assert state
|
||||
assert state.state == "50.0"
|
||||
|
||||
# PM10
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm10")
|
||||
assert state
|
||||
assert state.state == "3.0"
|
||||
|
||||
set_node_attribute(air_quality_sensor_node, 1, 1069, 0, 50)
|
||||
await trigger_subscription_callback(hass, matter_client)
|
||||
|
||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm10")
|
||||
assert state
|
||||
assert state.state == "50.0"
|
||||
|
||||
Reference in New Issue
Block a user