diff --git a/homeassistant/components/waqi/sensor.py b/homeassistant/components/waqi/sensor.py index ecc29006c5d..d94a2e19f67 100644 --- a/homeassistant/components/waqi/sensor.py +++ b/homeassistant/components/waqi/sensor.py @@ -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", diff --git a/homeassistant/components/waqi/strings.json b/homeassistant/components/waqi/strings.json index 54013f3ca2c..de287318508 100644 --- a/homeassistant/components/waqi/strings.json +++ b/homeassistant/components/waqi/strings.json @@ -74,6 +74,9 @@ "pm25": { "name": "[%key:component::sensor::entity_component::pm25::name%]" }, + "neph": { + "name": "Visbility using nephelometry" + }, "dominant_pollutant": { "name": "Dominant pollutant", "state": { diff --git a/tests/components/waqi/fixtures/air_quality_sensor.json b/tests/components/waqi/fixtures/air_quality_sensor.json index fbc153e4e28..885ecd8dfa2 100644 --- a/tests/components/waqi/fixtures/air_quality_sensor.json +++ b/tests/components/waqi/fixtures/air_quality_sensor.json @@ -23,6 +23,9 @@ "h": { "v": 80 }, + "neph": { + "v": 80 + }, "co": { "v": 2.3 }, diff --git a/tests/components/waqi/snapshots/test_sensor.ambr b/tests/components/waqi/snapshots/test_sensor.ambr index 3d4d7f30bbd..029b36b3c16 100644 --- a/tests/components/waqi/snapshots/test_sensor.ambr +++ b/tests/components/waqi/snapshots/test_sensor.ambr @@ -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': , + }), + 'context': , + 'entity_id': 'sensor.de_jongweg_utrecht_visbility_using_nephelometry', + 'last_changed': , + 'last_updated': , + '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', diff --git a/tests/components/waqi/test_sensor.py b/tests/components/waqi/test_sensor.py index 3d708e6c26d..ebe0c87736d 100644 --- a/tests/components/waqi/test_sensor.py +++ b/tests/components/waqi/test_sensor.py @@ -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: