mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Add Total Volatile Organic Compounds (tVOC) matter discovery schema (#116963)
This commit is contained in:
parent
46aa3ca97c
commit
fc5d58effd
@ -219,6 +219,19 @@ DISCOVERY_SCHEMAS = [
|
|||||||
clusters.CarbonDioxideConcentrationMeasurement.Attributes.MeasuredValue,
|
clusters.CarbonDioxideConcentrationMeasurement.Attributes.MeasuredValue,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MatterDiscoverySchema(
|
||||||
|
platform=Platform.SENSOR,
|
||||||
|
entity_description=MatterSensorEntityDescription(
|
||||||
|
key="TotalVolatileOrganicCompoundsSensor",
|
||||||
|
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
),
|
||||||
|
entity_class=MatterSensor,
|
||||||
|
required_attributes=(
|
||||||
|
clusters.TotalVolatileOrganicCompoundsConcentrationMeasurement.Attributes.MeasuredValue,
|
||||||
|
),
|
||||||
|
),
|
||||||
MatterDiscoverySchema(
|
MatterDiscoverySchema(
|
||||||
platform=Platform.SENSOR,
|
platform=Platform.SENSOR,
|
||||||
entity_description=MatterSensorEntityDescription(
|
entity_description=MatterSensorEntityDescription(
|
||||||
|
@ -84,6 +84,16 @@ async def air_quality_sensor_node_fixture(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name="air_purifier_node")
|
||||||
|
async def air_purifier_node_fixture(
|
||||||
|
hass: HomeAssistant, matter_client: MagicMock
|
||||||
|
) -> MatterNode:
|
||||||
|
"""Fixture for an air purifier node."""
|
||||||
|
return await setup_integration_with_node_fixture(
|
||||||
|
hass, "air-purifier", matter_client
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# This tests needs to be adjusted to remove lingering tasks
|
# This tests needs to be adjusted to remove lingering tasks
|
||||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
async def test_sensor_null_value(
|
async def test_sensor_null_value(
|
||||||
@ -333,3 +343,51 @@ async def test_air_quality_sensor(
|
|||||||
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm10")
|
state = hass.states.get("sensor.lightfi_aq1_air_quality_sensor_pm10")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "50.0"
|
assert state.state == "50.0"
|
||||||
|
|
||||||
|
|
||||||
|
# This tests needs to be adjusted to remove lingering tasks
|
||||||
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
|
async def test_air_purifier_sensor(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
matter_client: MagicMock,
|
||||||
|
air_purifier_node: MatterNode,
|
||||||
|
) -> None:
|
||||||
|
"""Test Air quality sensors are creayted for air purifier device."""
|
||||||
|
# Carbon Dioxide
|
||||||
|
state = hass.states.get("sensor.air_purifier_carbon_dioxide")
|
||||||
|
assert state
|
||||||
|
assert state.state == "2.0"
|
||||||
|
|
||||||
|
# PM1
|
||||||
|
state = hass.states.get("sensor.air_purifier_pm1")
|
||||||
|
assert state
|
||||||
|
assert state.state == "2.0"
|
||||||
|
|
||||||
|
# PM2.5
|
||||||
|
state = hass.states.get("sensor.air_purifier_pm2_5")
|
||||||
|
assert state
|
||||||
|
assert state.state == "2.0"
|
||||||
|
|
||||||
|
# PM10
|
||||||
|
state = hass.states.get("sensor.air_purifier_pm10")
|
||||||
|
assert state
|
||||||
|
assert state.state == "2.0"
|
||||||
|
|
||||||
|
# Temperature
|
||||||
|
state = hass.states.get("sensor.air_purifier_temperature")
|
||||||
|
assert state
|
||||||
|
assert state.state == "20.0"
|
||||||
|
|
||||||
|
# Humidity
|
||||||
|
state = hass.states.get("sensor.air_purifier_humidity")
|
||||||
|
assert state
|
||||||
|
assert state.state == "50.0"
|
||||||
|
|
||||||
|
# VOCS
|
||||||
|
state = hass.states.get("sensor.air_purifier_vocs")
|
||||||
|
assert state
|
||||||
|
assert state.state == "2.0"
|
||||||
|
assert state.attributes["state_class"] == "measurement"
|
||||||
|
assert state.attributes["unit_of_measurement"] == "ppm"
|
||||||
|
assert state.attributes["device_class"] == "volatile_organic_compounds_parts"
|
||||||
|
assert state.attributes["friendly_name"] == "Air Purifier VOCs"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user