1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Add Nephelometry sensor to waqi (#102298)

This commit is contained in:
Joost Lekkerkerker 2023-10-22 23:50:40 +02:00 committed by GitHub
parent 04b883a8e9
commit a97e34f28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 1 deletions

View File

@ -240,6 +240,14 @@ SENSORS: list[WAQISensorEntityDescription] = [
value_fn=lambda aq: aq.extended_air_quality.pm25,
available_fn=lambda aq: aq.extended_air_quality.pm25 is not None,
),
WAQISensorEntityDescription(
key="neph",
translation_key="neph",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda aq: aq.extended_air_quality.nephelometry,
available_fn=lambda aq: aq.extended_air_quality.nephelometry is not None,
entity_registry_enabled_default=False,
),
WAQISensorEntityDescription(
key="dominant_pollutant",
translation_key="dominant_pollutant",

View File

@ -74,6 +74,9 @@
"pm25": {
"name": "[%key:component::sensor::entity_component::pm25::name%]"
},
"neph": {
"name": "Visbility using nephelometry"
},
"dominant_pollutant": {
"name": "Dominant pollutant",
"state": {

View File

@ -23,6 +23,9 @@
"h": {
"v": 80
},
"neph": {
"v": 80
},
"co": {
"v": 2.3
},

View File

@ -41,6 +41,20 @@
})
# ---
# name: test_sensor.10
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meetnet Luchtkwaliteit and World Air Quality Index Project',
'friendly_name': 'de Jongweg, Utrecht Visbility using nephelometry',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'context': <ANY>,
'entity_id': 'sensor.de_jongweg_utrecht_visbility_using_nephelometry',
'last_changed': <ANY>,
'last_updated': <ANY>,
'state': '80',
})
# ---
# name: test_sensor.11
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meetnet Luchtkwaliteit and World Air Quality Index Project',

View File

@ -3,6 +3,7 @@ import json
from unittest.mock import patch
from aiowaqi import WAQIAirQuality, WAQIError, WAQISearchResult
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
@ -115,12 +116,13 @@ async def test_sensor_id_migration(
entities = er.async_entries_for_config_entry(
entity_registry, mock_config_entry.entry_id
)
assert len(entities) == 11
assert len(entities) == 12
assert hass.states.get("sensor.waqi_4584")
assert hass.states.get("sensor.de_jongweg_utrecht_air_quality_index") is None
assert entities[0].unique_id == "4584_air_quality"
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, snapshot: SnapshotAssertion
) -> None: