mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Add Nephelometry sensor to waqi (#102298)
This commit is contained in:
parent
04b883a8e9
commit
a97e34f28e
@ -240,6 +240,14 @@ SENSORS: list[WAQISensorEntityDescription] = [
|
|||||||
value_fn=lambda aq: aq.extended_air_quality.pm25,
|
value_fn=lambda aq: aq.extended_air_quality.pm25,
|
||||||
available_fn=lambda aq: aq.extended_air_quality.pm25 is not None,
|
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(
|
WAQISensorEntityDescription(
|
||||||
key="dominant_pollutant",
|
key="dominant_pollutant",
|
||||||
translation_key="dominant_pollutant",
|
translation_key="dominant_pollutant",
|
||||||
|
@ -74,6 +74,9 @@
|
|||||||
"pm25": {
|
"pm25": {
|
||||||
"name": "[%key:component::sensor::entity_component::pm25::name%]"
|
"name": "[%key:component::sensor::entity_component::pm25::name%]"
|
||||||
},
|
},
|
||||||
|
"neph": {
|
||||||
|
"name": "Visbility using nephelometry"
|
||||||
|
},
|
||||||
"dominant_pollutant": {
|
"dominant_pollutant": {
|
||||||
"name": "Dominant pollutant",
|
"name": "Dominant pollutant",
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
"h": {
|
"h": {
|
||||||
"v": 80
|
"v": 80
|
||||||
},
|
},
|
||||||
|
"neph": {
|
||||||
|
"v": 80
|
||||||
|
},
|
||||||
"co": {
|
"co": {
|
||||||
"v": 2.3
|
"v": 2.3
|
||||||
},
|
},
|
||||||
|
@ -41,6 +41,20 @@
|
|||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor.10
|
# 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({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meetnet Luchtkwaliteit and World Air Quality Index Project',
|
'attribution': 'RIVM - Rijksinstituut voor Volksgezondheid en Milieum, Landelijk Meetnet Luchtkwaliteit and World Air Quality Index Project',
|
||||||
|
@ -3,6 +3,7 @@ import json
|
|||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aiowaqi import WAQIAirQuality, WAQIError, WAQISearchResult
|
from aiowaqi import WAQIAirQuality, WAQIError, WAQISearchResult
|
||||||
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
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(
|
entities = er.async_entries_for_config_entry(
|
||||||
entity_registry, mock_config_entry.entry_id
|
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.waqi_4584")
|
||||||
assert hass.states.get("sensor.de_jongweg_utrecht_air_quality_index") is None
|
assert hass.states.get("sensor.de_jongweg_utrecht_air_quality_index") is None
|
||||||
assert entities[0].unique_id == "4584_air_quality"
|
assert entities[0].unique_id == "4584_air_quality"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||||
async def test_sensor(
|
async def test_sensor(
|
||||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, snapshot: SnapshotAssertion
|
hass: HomeAssistant, mock_config_entry: MockConfigEntry, snapshot: SnapshotAssertion
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user