Fix CO concentration unit in OpenWeatherMap (#146403)

This commit is contained in:
wittypluck 2025-06-09 19:55:09 +02:00 committed by GitHub
parent 98ea067285
commit 9ed6b591a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -10,7 +10,6 @@ from homeassistant.components.sensor import (
) )
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
PERCENTAGE, PERCENTAGE,
UV_INDEX, UV_INDEX,
@ -170,7 +169,7 @@ AIRPOLLUTION_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key=ATTR_API_AIRPOLLUTION_CO, key=ATTR_API_AIRPOLLUTION_CO,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
device_class=SensorDeviceClass.CO, device_class=SensorDeviceClass.CO,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -86,7 +86,7 @@
'supported_features': 0, 'supported_features': 0,
'translation_key': None, 'translation_key': None,
'unique_id': '12.34-56.78-co', 'unique_id': '12.34-56.78-co',
'unit_of_measurement': 'ppm', 'unit_of_measurement': 'µg/m³',
}) })
# --- # ---
# name: test_sensor_states[air_pollution][sensor.openweathermap_carbon_monoxide-state] # name: test_sensor_states[air_pollution][sensor.openweathermap_carbon_monoxide-state]
@ -96,7 +96,7 @@
'device_class': 'carbon_monoxide', 'device_class': 'carbon_monoxide',
'friendly_name': 'openweathermap Carbon monoxide', 'friendly_name': 'openweathermap Carbon monoxide',
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>, 'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': 'ppm', 'unit_of_measurement': 'µg/m³',
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'sensor.openweathermap_carbon_monoxide', 'entity_id': 'sensor.openweathermap_carbon_monoxide',