Add entity translations to Ukraine Alarm (#96260)

* Add entity translations to Ukraine Alarm

* Add entity translations to Ukraine Alarm
This commit is contained in:
Joost Lekkerkerker 2023-07-11 20:16:24 +02:00 committed by GitHub
parent 2257e7454a
commit a7edf0a608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 7 deletions

View File

@ -30,36 +30,36 @@ from .const import (
BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = ( BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_UNKNOWN, key=ALERT_TYPE_UNKNOWN,
name="Unknown", translation_key="unknown",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_AIR, key=ALERT_TYPE_AIR,
name="Air", translation_key="air",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
icon="mdi:cloud", icon="mdi:cloud",
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_URBAN_FIGHTS, key=ALERT_TYPE_URBAN_FIGHTS,
name="Urban Fights", translation_key="urban_fights",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
icon="mdi:pistol", icon="mdi:pistol",
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_ARTILLERY, key=ALERT_TYPE_ARTILLERY,
name="Artillery", translation_key="artillery",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
icon="mdi:tank", icon="mdi:tank",
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_CHEMICAL, key=ALERT_TYPE_CHEMICAL,
name="Chemical", translation_key="chemical",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
icon="mdi:chemical-weapon", icon="mdi:chemical-weapon",
), ),
BinarySensorEntityDescription( BinarySensorEntityDescription(
key=ALERT_TYPE_NUCLEAR, key=ALERT_TYPE_NUCLEAR,
name="Nuclear", translation_key="nuclear",
device_class=BinarySensorDeviceClass.SAFETY, device_class=BinarySensorDeviceClass.SAFETY,
icon="mdi:nuke", icon="mdi:nuke",
), ),
@ -92,6 +92,7 @@ class UkraineAlarmSensor(
"""Class for a Ukraine Alarm binary sensor.""" """Class for a Ukraine Alarm binary sensor."""
_attr_attribution = ATTRIBUTION _attr_attribution = ATTRIBUTION
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
@ -105,7 +106,6 @@ class UkraineAlarmSensor(
self.entity_description = description self.entity_description = description
self._attr_name = f"{name} {description.name}"
self._attr_unique_id = f"{unique_id}-{description.key}".lower() self._attr_unique_id = f"{unique_id}-{description.key}".lower()
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE, entry_type=DeviceEntryType.SERVICE,

View File

@ -28,5 +28,27 @@
"description": "If you want to monitor not only state and district, choose its specific community" "description": "If you want to monitor not only state and district, choose its specific community"
} }
} }
},
"entity": {
"binary_sensor": {
"unknown": {
"name": "Unknown"
},
"air": {
"name": "Air"
},
"urban_fights": {
"name": "Urban fights"
},
"artillery": {
"name": "Artillery"
},
"chemical": {
"name": "Chemical"
},
"nuclear": {
"name": "Nuclear"
}
}
} }
} }