Rename Particulate matter sensors to PM (#91384)

pull/91539/head
Franck Nijhof 2023-04-14 09:43:15 +02:00 committed by GitHub
parent fc8c5f1bbd
commit ce16d8eeac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 67 additions and 105 deletions

View File

@ -74,7 +74,7 @@
"name": "[%key:component::sensor::entity_component::pm10::name%]"
},
"pm10_index": {
"name": "Particulate matter 10 μm index",
"name": "PM10 index",
"state": {
"very_bad": "[%key:component::gios::entity::sensor::aqi::state::very_bad%]",
"bad": "[%key:component::gios::entity::sensor::aqi::state::bad%]",
@ -88,7 +88,7 @@
"name": "[%key:component::sensor::entity_component::pm25::name%]"
},
"pm25_index": {
"name": "Particulate matter 2.5 μm index",
"name": "PM2.5 index",
"state": {
"very_bad": "[%key:component::gios::entity::sensor::aqi::state::very_bad%]",
"bad": "[%key:component::gios::entity::sensor::aqi::state::bad%]",

View File

@ -89,13 +89,13 @@
}
},
"pmsx003_pm1": {
"name": "PMSx003 particulate matter 1 μm"
"name": "PMSx003 PM1"
},
"pmsx003_pm10": {
"name": "PMSx003 particulate matter 10 μm"
"name": "PMSx003 PM10"
},
"pmsx003_pm25": {
"name": "PMSx003 particulate matter 2.5 μm"
"name": "PMSx003 PM2.5"
},
"sds011_caqi": {
"name": "SDS011 common air quality index"
@ -111,10 +111,10 @@
}
},
"sds011_pm10": {
"name": "SDS011 particulate matter 10 μm"
"name": "SDS011 PM10"
},
"sds011_pm25": {
"name": "SDS011 particulate matter 2.5 μm"
"name": "SDS011 PM2.5"
},
"sht3x_humidity": {
"name": "SHT3X humidity"
@ -136,16 +136,16 @@
}
},
"sps30_pm1": {
"name": "SPS30 particulate matter 1 μm"
"name": "SPS30 PM1"
},
"sps30_pm10": {
"name": "SPS30 particulate matter 10 μm"
"name": "SPS30 PM10"
},
"sps30_pm25": {
"name": "SPS30 particulate matter 2.5 μm"
"name": "SPS30 PM2.5"
},
"sps30_pm4": {
"name": "SPS30 Particulate matter 4 μm"
"name": "SPS30 PM4"
},
"dht22_humidity": {
"name": "DHT22 humidity"

View File

@ -197,13 +197,13 @@
"name": "Ozone"
},
"pm1": {
"name": "Particulate matter 1 μm"
"name": "PM1"
},
"pm10": {
"name": "Particulate matter 10 μm"
"name": "PM10"
},
"pm25": {
"name": "Particulate matter 2.5 μm"
"name": "PM2.5"
},
"power_factor": {
"name": "Power factor"

View File

@ -25,7 +25,7 @@ async def test_async_setup_entry(
"""Test a successful setup entry."""
await init_integration(hass, aioclient_mock)
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state is not None
assert state.state != STATE_UNAVAILABLE
assert state.state == "4.37"

View File

@ -63,7 +63,7 @@ async def test_sensor(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker)
assert entry.unique_id == "123-456-humidity"
assert entry.options["sensor"] == {"suggested_display_precision": 1}
state = hass.states.get("sensor.home_particulate_matter_1_mm")
state = hass.states.get("sensor.home_pm1")
assert state
assert state.state == "2.83"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -74,12 +74,12 @@ async def test_sensor(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker)
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM1
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_particulate_matter_1_mm")
entry = registry.async_get("sensor.home_pm1")
assert entry
assert entry.unique_id == "123-456-pm1"
assert entry.options["sensor"] == {"suggested_display_precision": 0}
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == "4.37"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -90,12 +90,12 @@ async def test_sensor(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker)
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_particulate_matter_2_5_mm")
entry = registry.async_get("sensor.home_pm2_5")
assert entry
assert entry.unique_id == "123-456-pm25"
assert entry.options["sensor"] == {"suggested_display_precision": 0}
state = hass.states.get("sensor.home_particulate_matter_10_mm")
state = hass.states.get("sensor.home_pm10")
assert state
assert state.state == "6.06"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -106,7 +106,7 @@ async def test_sensor(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker)
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_particulate_matter_10_mm")
entry = registry.async_get("sensor.home_pm10")
assert entry
assert entry.unique_id == "123-456-pm10"
assert entry.options["sensor"] == {"suggested_display_precision": 0}

View File

@ -18,7 +18,7 @@ async def test_async_setup_entry(hass: HomeAssistant) -> None:
"""Test a successful setup entry."""
await init_integration(hass)
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state is not None
assert state.state != STATE_UNAVAILABLE
assert state.state == "4"

View File

@ -131,7 +131,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
assert entry
assert entry.unique_id == "123-o3-index"
state = hass.states.get("sensor.home_particulate_matter_10_mm")
state = hass.states.get("sensor.home_pm10")
assert state
assert state.state == "16.8344"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -142,11 +142,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get("sensor.home_particulate_matter_10_mm")
entry = registry.async_get("sensor.home_pm10")
assert entry
assert entry.unique_id == "123-pm10"
state = hass.states.get("sensor.home_particulate_matter_10_mm_index")
state = hass.states.get("sensor.home_pm10_index")
assert state
assert state.state == "good"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -160,11 +160,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
"very_good",
]
entry = registry.async_get("sensor.home_particulate_matter_10_mm_index")
entry = registry.async_get("sensor.home_pm10_index")
assert entry
assert entry.unique_id == "123-pm10-index"
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == "4"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -175,11 +175,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get("sensor.home_particulate_matter_2_5_mm")
entry = registry.async_get("sensor.home_pm2_5")
assert entry
assert entry.unique_id == "123-pm25"
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == "good"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -193,7 +193,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
"very_good",
]
entry = registry.async_get("sensor.home_particulate_matter_2_5_mm_index")
entry = registry.async_get("sensor.home_pm2_5_index")
assert entry
assert entry.unique_id == "123-pm25-index"
@ -257,11 +257,11 @@ async def test_availability(hass: HomeAssistant) -> None:
await init_integration(hass)
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == "4"
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == "good"
@ -277,11 +277,11 @@ async def test_availability(hass: HomeAssistant) -> None:
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == STATE_UNAVAILABLE
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == STATE_UNAVAILABLE
@ -300,7 +300,7 @@ async def test_availability(hass: HomeAssistant) -> None:
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == "4"
@ -310,7 +310,7 @@ async def test_availability(hass: HomeAssistant) -> None:
assert state.state == STATE_UNAVAILABLE
# Indexes are empty so the state should be unavailable
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == STATE_UNAVAILABLE
@ -324,11 +324,11 @@ async def test_availability(hass: HomeAssistant) -> None:
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
state = hass.states.get("sensor.home_particulate_matter_2_5_mm")
state = hass.states.get("sensor.home_pm2_5")
assert state
assert state.state == "4"
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == "good"
@ -349,11 +349,11 @@ async def test_invalid_indexes(hass: HomeAssistant) -> None:
assert state
assert state.state == STATE_UNAVAILABLE
state = hass.states.get("sensor.home_particulate_matter_10_mm_index")
state = hass.states.get("sensor.home_pm10_index")
assert state
assert state.state == STATE_UNAVAILABLE
state = hass.states.get("sensor.home_particulate_matter_2_5_mm_index")
state = hass.states.get("sensor.home_pm2_5_index")
assert state
assert state.state == STATE_UNAVAILABLE
@ -373,12 +373,12 @@ async def test_unique_id_migration(hass: HomeAssistant) -> None:
PLATFORM,
DOMAIN,
"123-pm2.5",
suggested_object_id="home_particulate_matter_2_5_mm",
suggested_object_id="home_pm2_5",
disabled_by=None,
)
await init_integration(hass)
entry = registry.async_get("sensor.home_particulate_matter_2_5_mm")
entry = registry.async_get("sensor.home_pm2_5")
assert entry
assert entry.unique_id == "123-pm25"

View File

@ -87,18 +87,15 @@ async def test_luftdaten_sensors(
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPressure.PA
assert ATTR_ICON not in state.attributes
entry = entity_registry.async_get("sensor.sensor_12345_particulate_matter_10_mm")
entry = entity_registry.async_get("sensor.sensor_12345_pm10")
assert entry
assert entry.device_id
assert entry.unique_id == "12345_P1"
state = hass.states.get("sensor.sensor_12345_particulate_matter_10_mm")
state = hass.states.get("sensor.sensor_12345_pm10")
assert state
assert state.state == "8.5"
assert (
state.attributes.get(ATTR_FRIENDLY_NAME)
== "Sensor 12345 Particulate matter 10 μm"
)
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 PM10"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert (
@ -107,18 +104,15 @@ async def test_luftdaten_sensors(
)
assert ATTR_ICON not in state.attributes
entry = entity_registry.async_get("sensor.sensor_12345_particulate_matter_2_5_mm")
entry = entity_registry.async_get("sensor.sensor_12345_pm2_5")
assert entry
assert entry.device_id
assert entry.unique_id == "12345_P2"
state = hass.states.get("sensor.sensor_12345_particulate_matter_2_5_mm")
state = hass.states.get("sensor.sensor_12345_pm2_5")
assert state
assert state.state == "4.07"
assert (
state.attributes.get(ATTR_FRIENDLY_NAME)
== "Sensor 12345 Particulate matter 2.5 μm"
)
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Sensor 12345 PM2.5"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
assert (

View File

@ -19,9 +19,7 @@ async def test_async_setup_entry(hass: HomeAssistant) -> None:
"""Test a successful setup entry."""
await init_integration(hass)
state = hass.states.get(
"sensor.nettigo_air_monitor_sds011_particulate_matter_2_5_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_sds011_pm2_5")
assert state is not None
assert state.state != STATE_UNAVAILABLE
assert state.state == "11.0"

View File

@ -265,9 +265,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-pms_caqi"
state = hass.states.get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_10_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_pmsx003_pm10")
assert state
assert state.state == "10.0"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10
@ -277,15 +275,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_10_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_pmsx003_pm10")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-pms_p1"
state = hass.states.get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_2_5_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_pmsx003_pm2_5")
assert state
assert state.state == "11.0"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25
@ -295,15 +289,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_2_5_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_pmsx003_pm2_5")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-pms_p2"
state = hass.states.get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_1_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_pmsx003_pm1")
assert state
assert state.state == "6.0"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM1
@ -313,15 +303,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_pmsx003_particulate_matter_1_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_pmsx003_pm1")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-pms_p0"
state = hass.states.get(
"sensor.nettigo_air_monitor_sds011_particulate_matter_10_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_sds011_pm10")
assert state
assert state.state == "18.6"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10
@ -331,9 +317,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_sds011_particulate_matter_10_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sds011_pm10")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sds011_p1"
@ -372,9 +356,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sds011_caqi_level"
assert entry.translation_key == "sds011_caqi_level"
state = hass.states.get(
"sensor.nettigo_air_monitor_sds011_particulate_matter_2_5_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_sds011_pm2_5")
assert state
assert state.state == "11.0"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25
@ -384,9 +366,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_sds011_particulate_matter_2_5_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sds011_pm2_5")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sds011_p2"
@ -423,7 +403,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sps30_caqi_level"
assert entry.translation_key == "sps30_caqi_level"
state = hass.states.get("sensor.nettigo_air_monitor_sps30_particulate_matter_1_mm")
state = hass.states.get("sensor.nettigo_air_monitor_sps30_pm1")
assert state
assert state.state == "31.2"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM1
@ -433,13 +413,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_sps30_particulate_matter_1_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sps30_pm1")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sps30_p0"
state = hass.states.get("sensor.nettigo_air_monitor_sps30_particulate_matter_10_mm")
state = hass.states.get("sensor.nettigo_air_monitor_sps30_pm10")
assert state
assert state.state == "21.2"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM10
@ -449,15 +427,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_sps30_particulate_matter_10_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sps30_pm10")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sps30_p1"
state = hass.states.get(
"sensor.nettigo_air_monitor_sps30_particulate_matter_2_5_mm"
)
state = hass.states.get("sensor.nettigo_air_monitor_sps30_pm2_5")
assert state
assert state.state == "34.3"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM25
@ -467,13 +441,11 @@ async def test_sensor(hass: HomeAssistant) -> None:
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
)
entry = registry.async_get(
"sensor.nettigo_air_monitor_sps30_particulate_matter_2_5_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sps30_pm2_5")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sps30_p2"
state = hass.states.get("sensor.nettigo_air_monitor_sps30_particulate_matter_4_mm")
state = hass.states.get("sensor.nettigo_air_monitor_sps30_pm4")
assert state
assert state.state == "24.7"
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.MEASUREMENT
@ -483,9 +455,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
)
assert state.attributes.get(ATTR_ICON) == "mdi:molecule"
entry = registry.async_get(
"sensor.nettigo_air_monitor_sps30_particulate_matter_4_mm"
)
entry = registry.async_get("sensor.nettigo_air_monitor_sps30_pm4")
assert entry
assert entry.unique_id == "aa:bb:cc:dd:ee:ff-sps30_p4"