Add icon translations to GDACS (#111611)

* Add icon translations to GDACS

* Add icon translations to GDACS

* Add icon translations to GDACS
pull/111709/head
Joost Lekkerkerker 2024-02-28 08:49:58 +01:00 committed by GitHub
parent 3077039470
commit cd9219d4c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,9 @@
{
"entity": {
"sensor": {
"alerts": {
"default": "mdi:alert"
}
}
}
}

View File

@ -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

View File

@ -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]