Use more human-readable sensor names in Airly (#86893)

* Use more human-readable sensor names

* Use abbreviations for long names
This commit is contained in:
Maciej Bieniek 2023-01-30 14:29:06 +01:00 committed by GitHub
parent 21d1c647c5
commit 5f57648578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -80,7 +80,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
AirlySensorEntityDescription( AirlySensorEntityDescription(
key=ATTR_API_PM1, key=ATTR_API_PM1,
device_class=SensorDeviceClass.PM1, device_class=SensorDeviceClass.PM1,
name=ATTR_API_PM1, name="PM1.0",
native_precision=0, native_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -135,7 +135,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
), ),
AirlySensorEntityDescription( AirlySensorEntityDescription(
key=ATTR_API_CO, key=ATTR_API_CO,
name=ATTR_API_CO, name="Carbon monoxide",
native_precision=0, native_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -147,7 +147,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
AirlySensorEntityDescription( AirlySensorEntityDescription(
key=ATTR_API_NO2, key=ATTR_API_NO2,
device_class=SensorDeviceClass.NITROGEN_DIOXIDE, device_class=SensorDeviceClass.NITROGEN_DIOXIDE,
name=ATTR_API_NO2, name="Nitrogen dioxide",
native_precision=0, native_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -159,7 +159,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
AirlySensorEntityDescription( AirlySensorEntityDescription(
key=ATTR_API_SO2, key=ATTR_API_SO2,
device_class=SensorDeviceClass.SULPHUR_DIOXIDE, device_class=SensorDeviceClass.SULPHUR_DIOXIDE,
name=ATTR_API_SO2, name="Sulphur dioxide",
native_precision=0, native_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -171,7 +171,7 @@ SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
AirlySensorEntityDescription( AirlySensorEntityDescription(
key=ATTR_API_O3, key=ATTR_API_O3,
device_class=SensorDeviceClass.OZONE, device_class=SensorDeviceClass.OZONE,
name=ATTR_API_O3, name="Ozone",
native_precision=0, native_precision=0,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View File

@ -59,7 +59,7 @@ async def test_sensor(hass, aioclient_mock):
assert entry assert entry
assert entry.unique_id == "123-456-humidity" assert entry.unique_id == "123-456-humidity"
state = hass.states.get("sensor.home_pm1") state = hass.states.get("sensor.home_pm1_0")
assert state assert state
assert state.state == "3" assert state.state == "3"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -70,7 +70,7 @@ async def test_sensor(hass, aioclient_mock):
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM1 assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PM1
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_pm1") entry = registry.async_get("sensor.home_pm1_0")
assert entry assert entry
assert entry.unique_id == "123-456-pm1" assert entry.unique_id == "123-456-pm1"
@ -104,7 +104,7 @@ async def test_sensor(hass, aioclient_mock):
assert entry assert entry
assert entry.unique_id == "123-456-pm10" assert entry.unique_id == "123-456-pm10"
state = hass.states.get("sensor.home_co") state = hass.states.get("sensor.home_carbon_monoxide")
assert state assert state
assert state.state == "162" assert state.state == "162"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -114,11 +114,11 @@ async def test_sensor(hass, aioclient_mock):
) )
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_co") entry = registry.async_get("sensor.home_carbon_monoxide")
assert entry assert entry
assert entry.unique_id == "123-456-co" assert entry.unique_id == "123-456-co"
state = hass.states.get("sensor.home_no2") state = hass.states.get("sensor.home_nitrogen_dioxide")
assert state assert state
assert state.state == "16" assert state.state == "16"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -129,11 +129,11 @@ async def test_sensor(hass, aioclient_mock):
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.NITROGEN_DIOXIDE assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.NITROGEN_DIOXIDE
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_no2") entry = registry.async_get("sensor.home_nitrogen_dioxide")
assert entry assert entry
assert entry.unique_id == "123-456-no2" assert entry.unique_id == "123-456-no2"
state = hass.states.get("sensor.home_o3") state = hass.states.get("sensor.home_ozone")
assert state assert state
assert state.state == "42" assert state.state == "42"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -144,11 +144,11 @@ async def test_sensor(hass, aioclient_mock):
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.OZONE assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.OZONE
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_o3") entry = registry.async_get("sensor.home_ozone")
assert entry assert entry
assert entry.unique_id == "123-456-o3" assert entry.unique_id == "123-456-o3"
state = hass.states.get("sensor.home_so2") state = hass.states.get("sensor.home_sulphur_dioxide")
assert state assert state
assert state.state == "14" assert state.state == "14"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
@ -159,7 +159,7 @@ async def test_sensor(hass, aioclient_mock):
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SULPHUR_DIOXIDE assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SULPHUR_DIOXIDE
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
entry = registry.async_get("sensor.home_so2") entry = registry.async_get("sensor.home_sulphur_dioxide")
assert entry assert entry
assert entry.unique_id == "123-456-so2" assert entry.unique_id == "123-456-so2"