From cd9219d4c693868588302e717bf44df82688fa12 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 28 Feb 2024 08:49:58 +0100 Subject: [PATCH] Add icon translations to GDACS (#111611) * Add icon translations to GDACS * Add icon translations to GDACS * Add icon translations to GDACS --- homeassistant/components/gdacs/icons.json | 9 +++++++++ homeassistant/components/gdacs/sensor.py | 4 ++-- tests/components/gdacs/test_sensor.py | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 homeassistant/components/gdacs/icons.json diff --git a/homeassistant/components/gdacs/icons.json b/homeassistant/components/gdacs/icons.json new file mode 100644 index 00000000000..1a99aa9fb7b --- /dev/null +++ b/homeassistant/components/gdacs/icons.json @@ -0,0 +1,9 @@ +{ + "entity": { + "sensor": { + "alerts": { + "default": "mdi:alert" + } + } + } +} diff --git a/homeassistant/components/gdacs/sensor.py b/homeassistant/components/gdacs/sensor.py index 8039d5274ed..f660c8f73c8 100644 --- a/homeassistant/components/gdacs/sensor.py +++ b/homeassistant/components/gdacs/sensor.py @@ -17,7 +17,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import dt as dt_util from . import GdacsFeedEntityManager -from .const import DEFAULT_ICON, DOMAIN, FEED +from .const import DOMAIN, FEED _LOGGER = logging.getLogger(__name__) @@ -48,10 +48,10 @@ class GdacsSensor(SensorEntity): """Status sensor for the GDACS integration.""" _attr_should_poll = False - _attr_icon = DEFAULT_ICON _attr_native_unit_of_measurement = DEFAULT_UNIT_OF_MEASUREMENT _attr_has_entity_name = True _attr_name = None + _attr_translation_key = "alerts" def __init__( self, config_entry: ConfigEntry, manager: GdacsFeedEntityManager diff --git a/tests/components/gdacs/test_sensor.py b/tests/components/gdacs/test_sensor.py index 9e585de41dd..f40756235e1 100644 --- a/tests/components/gdacs/test_sensor.py +++ b/tests/components/gdacs/test_sensor.py @@ -15,7 +15,6 @@ from homeassistant.components.gdacs.sensor import ( ATTR_UPDATED, ) from homeassistant.const import ( - ATTR_ICON, ATTR_UNIT_OF_MEASUREMENT, CONF_LATITUDE, CONF_LONGITUDE, @@ -101,7 +100,6 @@ async def test_setup(hass: HomeAssistant) -> None: assert attributes[ATTR_LAST_UPDATE_SUCCESSFUL].tzinfo == dt_util.UTC assert attributes[ATTR_LAST_UPDATE] == attributes[ATTR_LAST_UPDATE_SUCCESSFUL] assert attributes[ATTR_UNIT_OF_MEASUREMENT] == "alerts" - assert attributes[ATTR_ICON] == "mdi:alert" # Simulate an update - two existing, one new entry, one outdated entry mock_feed_update.return_value = "OK", [mock_entry_1, mock_entry_4, mock_entry_3]