Make remaining WLED entities translatable (#108534)

This commit is contained in:
Jan-Philipp Benecke 2024-01-21 13:44:32 +01:00 committed by GitHub
parent 48c434da86
commit fcaa2fcf03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 56 additions and 18 deletions

View File

@ -34,7 +34,7 @@ class WLEDUpdateBinarySensor(WLEDEntity, BinarySensorEntity):
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_device_class = BinarySensorDeviceClass.UPDATE
_attr_name = "Firmware"
_attr_translation_key = "firmware"
# Disabled by default, as this entity is deprecated.
_attr_entity_registry_enabled_default = False

View File

@ -121,7 +121,8 @@ class WLEDSegmentLight(WLEDEntity, LightEntity):
if segment == 0:
self._attr_name = None
else:
self._attr_name = f"Segment {segment}"
self._attr_translation_key = "segment"
self._attr_translation_placeholders = {"segment": str(segment)}
self._attr_unique_id = (
f"{self.coordinator.data.info.mac_address}_{self._segment}"

View File

@ -49,7 +49,7 @@ class WLEDNumberEntityDescription(NumberEntityDescription):
NUMBERS = [
WLEDNumberEntityDescription(
key=ATTR_SPEED,
name="Speed",
translation_key="speed",
icon="mdi:speedometer",
entity_category=EntityCategory.CONFIG,
native_step=1,
@ -59,7 +59,7 @@ NUMBERS = [
),
WLEDNumberEntityDescription(
key=ATTR_INTENSITY,
name="Intensity",
translation_key="intensity",
entity_category=EntityCategory.CONFIG,
native_step=1,
native_min_value=0,
@ -87,7 +87,8 @@ class WLEDNumber(WLEDEntity, NumberEntity):
# Segment 0 uses a simpler name, which is more natural for when using
# a single segment / using WLED with one big LED strip.
if segment != 0:
self._attr_name = f"Segment {segment} {description.name}"
self._attr_translation_key = f"segment_{description.translation_key}"
self._attr_translation_placeholders = {"segment": str(segment)}
self._attr_unique_id = (
f"{coordinator.data.info.mac_address}_{description.key}_{segment}"

View File

@ -139,7 +139,7 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
_attr_entity_category = EntityCategory.CONFIG
_attr_icon = "mdi:palette-outline"
_attr_name = "Color palette"
_attr_translation_key = "color_palette"
_segment: int
def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
@ -149,7 +149,8 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
# Segment 0 uses a simpler name, which is more natural for when using
# a single segment / using WLED with one big LED strip.
if segment != 0:
self._attr_name = f"Segment {segment} color palette"
self._attr_translation_key = "segment_color_palette"
self._attr_translation_placeholders = {"segment": str(segment)}
self._attr_unique_id = f"{coordinator.data.info.mac_address}_palette_{segment}"
self._attr_options = [

View File

@ -35,12 +35,40 @@
}
},
"entity": {
"binary_sensor": {
"firmware": {
"name": "Firmware"
}
},
"light": {
"main": {
"name": "Main"
},
"segment": {
"name": "Segment {segment}"
}
},
"number": {
"intensity": {
"name": "Intensity"
},
"segment_intensity": {
"name": "Segment {segment} intensity"
},
"speed": {
"name": "Speed"
},
"segment_speed": {
"name": "Segment {segment} speed"
}
},
"select": {
"color_palette": {
"name": "Color palette"
},
"segment_color_palette": {
"name": "Segment {segment} color palette"
},
"live_override": {
"name": "Live override",
"state": {
@ -97,6 +125,12 @@
},
"sync_receive": {
"name": "Sync receive"
},
"reverse": {
"name": "Reverse"
},
"segment_reverse": {
"name": "Segment {segment} reverse"
}
}
},

View File

@ -159,7 +159,7 @@ class WLEDReverseSwitch(WLEDEntity, SwitchEntity):
_attr_icon = "mdi:swap-horizontal-bold"
_attr_entity_category = EntityCategory.CONFIG
_attr_name = "Reverse"
_attr_translation_key = "reverse"
_segment: int
def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
@ -169,7 +169,8 @@ class WLEDReverseSwitch(WLEDEntity, SwitchEntity):
# Segment 0 uses a simpler name, which is more natural for when using
# a single segment / using WLED with one big LED strip.
if segment != 0:
self._attr_name = f"Segment {segment} reverse"
self._attr_translation_key = "segment_reverse"
self._attr_translation_placeholders = {"segment": str(segment)}
self._attr_unique_id = f"{coordinator.data.info.mac_address}_reverse_{segment}"
self._segment = segment

View File

@ -38,7 +38,7 @@
'platform': 'wled',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'translation_key': 'firmware',
'unique_id': 'aabbccddeeff_update',
'unit_of_measurement': None,
})

View File

@ -2,7 +2,7 @@
# name: test_numbers[number.wled_rgb_light_segment_1_intensity-42-intensity]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 Intensity',
'friendly_name': 'WLED RGB Light Segment 1 intensity',
'max': 255,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
@ -42,11 +42,11 @@
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Segment 1 Intensity',
'original_name': 'Segment 1 intensity',
'platform': 'wled',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'translation_key': 'segment_intensity',
'unique_id': 'aabbccddeeff_intensity_1',
'unit_of_measurement': None,
})
@ -86,7 +86,7 @@
# name: test_numbers[number.wled_rgb_light_segment_1_speed-42-speed]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 Speed',
'friendly_name': 'WLED RGB Light Segment 1 speed',
'icon': 'mdi:speedometer',
'max': 255,
'min': 0,
@ -127,11 +127,11 @@
}),
'original_device_class': None,
'original_icon': 'mdi:speedometer',
'original_name': 'Segment 1 Speed',
'original_name': 'Segment 1 speed',
'platform': 'wled',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'translation_key': 'segment_speed',
'unique_id': 'aabbccddeeff_speed_1',
'unit_of_measurement': None,
})

View File

@ -230,7 +230,7 @@
'platform': 'wled',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'translation_key': 'segment_color_palette',
'unique_id': 'aabbccddeeff_palette_1',
'unit_of_measurement': None,
})

View File

@ -117,7 +117,7 @@
'platform': 'wled',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'translation_key': 'reverse',
'unique_id': 'aabbccddeeff_reverse_0',
'unit_of_measurement': None,
})