From 0954e4cd736f490d6e3693c1b29b6b87488d656d Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Fri, 9 Feb 2024 23:28:11 +0100 Subject: [PATCH] Add icon translations to GIOS (#110131) Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com> --- homeassistant/components/gios/icons.json | 30 ++++++++++++++++++++++++ homeassistant/components/gios/sensor.py | 8 ------- tests/components/gios/test_sensor.py | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 homeassistant/components/gios/icons.json diff --git a/homeassistant/components/gios/icons.json b/homeassistant/components/gios/icons.json new file mode 100644 index 00000000000..e1d848e276b --- /dev/null +++ b/homeassistant/components/gios/icons.json @@ -0,0 +1,30 @@ +{ + "entity": { + "sensor": { + "aqi": { + "default": "mdi:air-filter" + }, + "c6h6": { + "default": "mdi:molecule" + }, + "co": { + "default": "mdi:molecule" + }, + "no2_index": { + "default": "mdi:molecule" + }, + "o3_index": { + "default": "mdi:molecule" + }, + "pm10_index": { + "default": "mdi:molecule" + }, + "pm25_index": { + "default": "mdi:molecule" + }, + "so2_index": { + "default": "mdi:molecule" + } + } + } +} diff --git a/homeassistant/components/gios/sensor.py b/homeassistant/components/gios/sensor.py index 99c1775beef..1b13430128f 100644 --- a/homeassistant/components/gios/sensor.py +++ b/homeassistant/components/gios/sensor.py @@ -54,7 +54,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( GiosSensorEntityDescription( key=ATTR_AQI, value=lambda sensors: sensors.aqi.value if sensors.aqi else None, - icon="mdi:air-filter", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="aqi", @@ -63,7 +62,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_C6H6, value=lambda sensors: sensors.c6h6.value if sensors.c6h6 else None, suggested_display_precision=0, - icon="mdi:molecule", native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, state_class=SensorStateClass.MEASUREMENT, translation_key="c6h6", @@ -72,7 +70,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_CO, value=lambda sensors: sensors.co.value if sensors.co else None, suggested_display_precision=0, - icon="mdi:molecule", native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, state_class=SensorStateClass.MEASUREMENT, translation_key="co", @@ -89,7 +86,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_NO2, subkey="index", value=lambda sensors: sensors.no2.index if sensors.no2 else None, - icon="mdi:molecule", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="no2_index", @@ -106,7 +102,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_O3, subkey="index", value=lambda sensors: sensors.o3.index if sensors.o3 else None, - icon="mdi:molecule", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="o3_index", @@ -123,7 +118,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_PM10, subkey="index", value=lambda sensors: sensors.pm10.index if sensors.pm10 else None, - icon="mdi:molecule", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="pm10_index", @@ -140,7 +134,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_PM25, subkey="index", value=lambda sensors: sensors.pm25.index if sensors.pm25 else None, - icon="mdi:molecule", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="pm25_index", @@ -157,7 +150,6 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = ( key=ATTR_SO2, subkey="index", value=lambda sensors: sensors.so2.index if sensors.so2 else None, - icon="mdi:molecule", device_class=SensorDeviceClass.ENUM, options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"], translation_key="so2_index", diff --git a/tests/components/gios/test_sensor.py b/tests/components/gios/test_sensor.py index e14b4548d86..7a7a735ff42 100644 --- a/tests/components/gios/test_sensor.py +++ b/tests/components/gios/test_sensor.py @@ -43,7 +43,7 @@ async def test_sensor(hass: HomeAssistant, entity_registry: er.EntityRegistry) - state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == CONCENTRATION_MICROGRAMS_PER_CUBIC_METER ) - assert state.attributes.get(ATTR_ICON) == "mdi:molecule" + assert state.attributes.get(ATTR_ICON) is None entry = entity_registry.async_get("sensor.home_benzene") assert entry