Add icon translations to Utility meter helper (#109656)

This commit is contained in:
Jan-Philipp Benecke 2024-02-04 23:21:57 +01:00 committed by GitHub
parent 945aff6050
commit f18448950c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 11 deletions

View file

@ -1,8 +1,6 @@
"""Constants for the utility meter component."""
DOMAIN = "utility_meter"
TARIFF_ICON = "mdi:clock-outline"
QUARTER_HOURLY = "quarter-hourly"
HOURLY = "hourly"
DAILY = "daily"

View file

@ -0,0 +1,14 @@
{
"entity": {
"sensor": {
"utility_meter": {
"default": "mdi:counter"
}
},
"select": {
"tariff": {
"default": "mdi:clock-outline"
}
}
}
}

View file

@ -13,13 +13,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import (
CONF_METER,
CONF_SOURCE_SENSOR,
CONF_TARIFFS,
DATA_UTILITY,
TARIFF_ICON,
)
from .const import CONF_METER, CONF_SOURCE_SENSOR, CONF_TARIFFS, DATA_UTILITY
_LOGGER = logging.getLogger(__name__)
@ -100,6 +94,8 @@ async def async_setup_platform(
class TariffSelect(SelectEntity, RestoreEntity):
"""Representation of a Tariff selector."""
_attr_translation_key = "tariff"
def __init__(
self,
name,
@ -113,7 +109,6 @@ class TariffSelect(SelectEntity, RestoreEntity):
self._attr_device_info = device_info
self._current_tariff: str | None = None
self._tariffs = tariffs
self._attr_icon = TARIFF_ICON
self._attr_should_poll = False
@property

View file

@ -362,7 +362,7 @@ class UtilitySensorExtraStoredData(SensorExtraStoredData):
class UtilityMeterSensor(RestoreSensor):
"""Representation of an utility meter sensor."""
_attr_icon = "mdi:counter"
_attr_translation_key = "utility_meter"
_attr_should_poll = False
def __init__(