diff --git a/custom_components/irm_kmi/const.py b/custom_components/irm_kmi/const.py index 0e52f81..a17c1a8 100644 --- a/custom_components/irm_kmi/const.py +++ b/custom_components/irm_kmi/const.py @@ -180,4 +180,10 @@ CURRENT_WEATHER_SENSOR_CLASS: Final = {'temperature': SensorDeviceClass.TEMPERAT 'uv_index': None, 'pressure': SensorDeviceClass.ATMOSPHERIC_PRESSURE} -# TODO add sensor icon map for nice display \ No newline at end of file +# Leave None when we want the default icon to be shown +CURRENT_WEATHER_SENSOR_ICON: Final = {'temperature': None, + 'wind_speed': None, + 'wind_gust_speed': None, + 'wind_bearing': 'mdi:compass', + 'uv_index': None, + 'pressure': None} diff --git a/custom_components/irm_kmi/sensor.py b/custom_components/irm_kmi/sensor.py index f0942e5..7d60a42 100644 --- a/custom_components/irm_kmi/sensor.py +++ b/custom_components/irm_kmi/sensor.py @@ -12,7 +12,7 @@ from homeassistant.util import dt from custom_components.irm_kmi import DOMAIN, IrmKmiCoordinator from custom_components.irm_kmi.const import POLLEN_NAMES, POLLEN_TO_ICON_MAP, CURRENT_WEATHER_SENSOR_UNITS, \ - CURRENT_WEATHER_SENSOR_CLASS, CURRENT_WEATHER_SENSORS + CURRENT_WEATHER_SENSOR_CLASS, CURRENT_WEATHER_SENSORS, CURRENT_WEATHER_SENSOR_ICON from custom_components.irm_kmi.data import IrmKmiForecast from custom_components.irm_kmi.pollen import PollenParser @@ -154,8 +154,7 @@ class IrmKmiCurrentWeather(CoordinatorEntity, SensorEntity): self._attr_unique_id = f"{entry.entry_id}-current-{sensor_name}" self.entity_id = sensor.ENTITY_ID_FORMAT.format(f"{str(entry.title).lower()}_next_{sensor_name}") self._attr_device_info = coordinator.shared_device_info - # TODO - # self._attr_translation_key = f"next_{move}" + self._attr_translation_key = f"current_{sensor_name}" self._sensor_name: str = sensor_name @property @@ -170,3 +169,7 @@ class IrmKmiCurrentWeather(CoordinatorEntity, SensorEntity): @property def device_class(self) -> SensorDeviceClass | None: return CURRENT_WEATHER_SENSOR_CLASS[self._sensor_name] + + @property + def icon(self) -> str | None: + return CURRENT_WEATHER_SENSOR_ICON[self._sensor_name]