Add entity translations to DWD (#98254)

* Add device to DWD

* Add entity translations to DWD
This commit is contained in:
Joost Lekkerkerker 2023-08-12 11:03:37 +02:00 committed by GitHub
parent d6498aa39e
commit be9afd7eae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -56,12 +56,12 @@ from .coordinator import DwdWeatherWarningsCoordinator
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key=CURRENT_WARNING_SENSOR, key=CURRENT_WARNING_SENSOR,
name="Current Warning Level", translation_key=CURRENT_WARNING_SENSOR,
icon="mdi:close-octagon-outline", icon="mdi:close-octagon-outline",
), ),
SensorEntityDescription( SensorEntityDescription(
key=ADVANCE_WARNING_SENSOR, key=ADVANCE_WARNING_SENSOR,
name="Advance Warning Level", translation_key=ADVANCE_WARNING_SENSOR,
icon="mdi:close-octagon-outline", icon="mdi:close-octagon-outline",
), ),
) )
@ -131,6 +131,7 @@ class DwdWeatherWarningsSensor(
"""Representation of a DWD-Weather-Warnings sensor.""" """Representation of a DWD-Weather-Warnings sensor."""
_attr_attribution = "Data provided by DWD" _attr_attribution = "Data provided by DWD"
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
@ -142,7 +143,6 @@ class DwdWeatherWarningsSensor(
super().__init__(coordinator) super().__init__(coordinator)
self.entity_description = description self.entity_description = description
self._attr_name = f"{DEFAULT_NAME} {entry.title} {description.name}"
self._attr_unique_id = f"{entry.unique_id}-{description.key}" self._attr_unique_id = f"{entry.unique_id}-{description.key}"
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(

View File

@ -15,5 +15,15 @@
"already_configured": "Warncell ID / name is already configured.", "already_configured": "Warncell ID / name is already configured.",
"invalid_identifier": "[%key:component::dwd_weather_warnings::config::error::invalid_identifier%]" "invalid_identifier": "[%key:component::dwd_weather_warnings::config::error::invalid_identifier%]"
} }
},
"entity": {
"sensor": {
"current_warning_level": {
"name": "Current warning level"
},
"advance_warning_level": {
"name": "Advance warning level"
}
}
} }
} }