mirror of
https://github.com/home-assistant/core
synced 2024-10-04 07:58:43 +02:00
Make remaining WLED entities translatable (#108534)
This commit is contained in:
parent
48c434da86
commit
fcaa2fcf03
@ -34,7 +34,7 @@ class WLEDUpdateBinarySensor(WLEDEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
_attr_device_class = BinarySensorDeviceClass.UPDATE
|
_attr_device_class = BinarySensorDeviceClass.UPDATE
|
||||||
_attr_name = "Firmware"
|
_attr_translation_key = "firmware"
|
||||||
|
|
||||||
# Disabled by default, as this entity is deprecated.
|
# Disabled by default, as this entity is deprecated.
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
|
@ -121,7 +121,8 @@ class WLEDSegmentLight(WLEDEntity, LightEntity):
|
|||||||
if segment == 0:
|
if segment == 0:
|
||||||
self._attr_name = None
|
self._attr_name = None
|
||||||
else:
|
else:
|
||||||
self._attr_name = f"Segment {segment}"
|
self._attr_translation_key = "segment"
|
||||||
|
self._attr_translation_placeholders = {"segment": str(segment)}
|
||||||
|
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{self.coordinator.data.info.mac_address}_{self._segment}"
|
f"{self.coordinator.data.info.mac_address}_{self._segment}"
|
||||||
|
@ -49,7 +49,7 @@ class WLEDNumberEntityDescription(NumberEntityDescription):
|
|||||||
NUMBERS = [
|
NUMBERS = [
|
||||||
WLEDNumberEntityDescription(
|
WLEDNumberEntityDescription(
|
||||||
key=ATTR_SPEED,
|
key=ATTR_SPEED,
|
||||||
name="Speed",
|
translation_key="speed",
|
||||||
icon="mdi:speedometer",
|
icon="mdi:speedometer",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_step=1,
|
native_step=1,
|
||||||
@ -59,7 +59,7 @@ NUMBERS = [
|
|||||||
),
|
),
|
||||||
WLEDNumberEntityDescription(
|
WLEDNumberEntityDescription(
|
||||||
key=ATTR_INTENSITY,
|
key=ATTR_INTENSITY,
|
||||||
name="Intensity",
|
translation_key="intensity",
|
||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
native_step=1,
|
native_step=1,
|
||||||
native_min_value=0,
|
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
|
# Segment 0 uses a simpler name, which is more natural for when using
|
||||||
# a single segment / using WLED with one big LED strip.
|
# a single segment / using WLED with one big LED strip.
|
||||||
if segment != 0:
|
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 = (
|
self._attr_unique_id = (
|
||||||
f"{coordinator.data.info.mac_address}_{description.key}_{segment}"
|
f"{coordinator.data.info.mac_address}_{description.key}_{segment}"
|
||||||
|
@ -139,7 +139,7 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
|
|||||||
|
|
||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
_attr_icon = "mdi:palette-outline"
|
_attr_icon = "mdi:palette-outline"
|
||||||
_attr_name = "Color palette"
|
_attr_translation_key = "color_palette"
|
||||||
_segment: int
|
_segment: int
|
||||||
|
|
||||||
def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
|
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
|
# Segment 0 uses a simpler name, which is more natural for when using
|
||||||
# a single segment / using WLED with one big LED strip.
|
# a single segment / using WLED with one big LED strip.
|
||||||
if segment != 0:
|
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_unique_id = f"{coordinator.data.info.mac_address}_palette_{segment}"
|
||||||
self._attr_options = [
|
self._attr_options = [
|
||||||
|
@ -35,12 +35,40 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"firmware": {
|
||||||
|
"name": "Firmware"
|
||||||
|
}
|
||||||
|
},
|
||||||
"light": {
|
"light": {
|
||||||
"main": {
|
"main": {
|
||||||
"name": "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": {
|
"select": {
|
||||||
|
"color_palette": {
|
||||||
|
"name": "Color palette"
|
||||||
|
},
|
||||||
|
"segment_color_palette": {
|
||||||
|
"name": "Segment {segment} color palette"
|
||||||
|
},
|
||||||
"live_override": {
|
"live_override": {
|
||||||
"name": "Live override",
|
"name": "Live override",
|
||||||
"state": {
|
"state": {
|
||||||
@ -97,6 +125,12 @@
|
|||||||
},
|
},
|
||||||
"sync_receive": {
|
"sync_receive": {
|
||||||
"name": "Sync receive"
|
"name": "Sync receive"
|
||||||
|
},
|
||||||
|
"reverse": {
|
||||||
|
"name": "Reverse"
|
||||||
|
},
|
||||||
|
"segment_reverse": {
|
||||||
|
"name": "Segment {segment} reverse"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -159,7 +159,7 @@ class WLEDReverseSwitch(WLEDEntity, SwitchEntity):
|
|||||||
|
|
||||||
_attr_icon = "mdi:swap-horizontal-bold"
|
_attr_icon = "mdi:swap-horizontal-bold"
|
||||||
_attr_entity_category = EntityCategory.CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
_attr_name = "Reverse"
|
_attr_translation_key = "reverse"
|
||||||
_segment: int
|
_segment: int
|
||||||
|
|
||||||
def __init__(self, coordinator: WLEDDataUpdateCoordinator, segment: int) -> None:
|
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
|
# Segment 0 uses a simpler name, which is more natural for when using
|
||||||
# a single segment / using WLED with one big LED strip.
|
# a single segment / using WLED with one big LED strip.
|
||||||
if segment != 0:
|
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._attr_unique_id = f"{coordinator.data.info.mac_address}_reverse_{segment}"
|
||||||
self._segment = segment
|
self._segment = segment
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
'platform': 'wled',
|
'platform': 'wled',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'firmware',
|
||||||
'unique_id': 'aabbccddeeff_update',
|
'unique_id': 'aabbccddeeff_update',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# name: test_numbers[number.wled_rgb_light_segment_1_intensity-42-intensity]
|
# name: test_numbers[number.wled_rgb_light_segment_1_intensity-42-intensity]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'WLED RGB Light Segment 1 Intensity',
|
'friendly_name': 'WLED RGB Light Segment 1 intensity',
|
||||||
'max': 255,
|
'max': 255,
|
||||||
'min': 0,
|
'min': 0,
|
||||||
'mode': <NumberMode.AUTO: 'auto'>,
|
'mode': <NumberMode.AUTO: 'auto'>,
|
||||||
@ -42,11 +42,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Segment 1 Intensity',
|
'original_name': 'Segment 1 intensity',
|
||||||
'platform': 'wled',
|
'platform': 'wled',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'segment_intensity',
|
||||||
'unique_id': 'aabbccddeeff_intensity_1',
|
'unique_id': 'aabbccddeeff_intensity_1',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
@ -86,7 +86,7 @@
|
|||||||
# name: test_numbers[number.wled_rgb_light_segment_1_speed-42-speed]
|
# name: test_numbers[number.wled_rgb_light_segment_1_speed-42-speed]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'friendly_name': 'WLED RGB Light Segment 1 Speed',
|
'friendly_name': 'WLED RGB Light Segment 1 speed',
|
||||||
'icon': 'mdi:speedometer',
|
'icon': 'mdi:speedometer',
|
||||||
'max': 255,
|
'max': 255,
|
||||||
'min': 0,
|
'min': 0,
|
||||||
@ -127,11 +127,11 @@
|
|||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': None,
|
||||||
'original_icon': 'mdi:speedometer',
|
'original_icon': 'mdi:speedometer',
|
||||||
'original_name': 'Segment 1 Speed',
|
'original_name': 'Segment 1 speed',
|
||||||
'platform': 'wled',
|
'platform': 'wled',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'segment_speed',
|
||||||
'unique_id': 'aabbccddeeff_speed_1',
|
'unique_id': 'aabbccddeeff_speed_1',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
@ -230,7 +230,7 @@
|
|||||||
'platform': 'wled',
|
'platform': 'wled',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'segment_color_palette',
|
||||||
'unique_id': 'aabbccddeeff_palette_1',
|
'unique_id': 'aabbccddeeff_palette_1',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
'platform': 'wled',
|
'platform': 'wled',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': 0,
|
'supported_features': 0,
|
||||||
'translation_key': None,
|
'translation_key': 'reverse',
|
||||||
'unique_id': 'aabbccddeeff_reverse_0',
|
'unique_id': 'aabbccddeeff_reverse_0',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user