Fix order of palettes, presets and playlists in WLED integration (#132207)

* Fix order of palettes, presets and playlists in WLED integration

* fix tests: update palette items order

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Michal Schwarz 2025-03-30 16:14:56 +02:00 committed by Franck Nijhof
parent 5d45b84cd2
commit 35fc81b038
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 126 additions and 123 deletions

View File

@ -79,9 +79,10 @@ class WLEDPresetSelect(WLEDEntity, SelectEntity):
super().__init__(coordinator=coordinator)
self._attr_unique_id = f"{coordinator.data.info.mac_address}_preset"
self._attr_options = [
preset.name for preset in self.coordinator.data.presets.values()
]
sorted_values = sorted(
coordinator.data.presets.values(), key=lambda preset: preset.name
)
self._attr_options = [preset.name for preset in sorted_values]
@property
def available(self) -> bool:
@ -115,9 +116,10 @@ class WLEDPlaylistSelect(WLEDEntity, SelectEntity):
super().__init__(coordinator=coordinator)
self._attr_unique_id = f"{coordinator.data.info.mac_address}_playlist"
self._attr_options = [
playlist.name for playlist in self.coordinator.data.playlists.values()
]
sorted_values = sorted(
coordinator.data.playlists.values(), key=lambda playlist: playlist.name
)
self._attr_options = [playlist.name for playlist in sorted_values]
@property
def available(self) -> bool:
@ -159,9 +161,10 @@ class WLEDPaletteSelect(WLEDEntity, SelectEntity):
self._attr_translation_placeholders = {"segment": str(segment)}
self._attr_unique_id = f"{coordinator.data.info.mac_address}_palette_{segment}"
self._attr_options = [
palette.name for palette in self.coordinator.data.palettes.values()
]
sorted_values = sorted(
coordinator.data.palettes.values(), key=lambda palette: palette.name
)
self._attr_options = [palette.name for palette in sorted_values]
self._segment = segment
@property

View File

@ -99,77 +99,77 @@
'attributes': ReadOnlyDict({
'friendly_name': 'WLED RGB Light Segment 1 color palette',
'options': list([
'Default',
'* Random Cycle',
'* Color 1',
'* Colors 1&2',
'* Color Gradient',
'* Colors 1&2',
'* Colors Only',
'Party',
'Cloud',
'Lava',
'Ocean',
'Forest',
'Rainbow',
'Rainbow Bands',
'Sunset',
'Rivendell',
'Breeze',
'Red & Blue',
'Yellowout',
'* Random Cycle',
'Analogous',
'Splash',
'Pastel',
'Sunset 2',
'Beach',
'Vintage',
'Departure',
'Landscape',
'Beech',
'Sherbet',
'Hult',
'Hult 64',
'Drywet',
'Jul',
'Grintage',
'Rewhi',
'Tertiary',
'Fire',
'Icefire',
'Cyane',
'Light Pink',
'Autumn',
'Magenta',
'Magred',
'Yelmag',
'Yelblu',
'Orange & Teal',
'Tiamat',
'April Night',
'Orangery',
'C9',
'Sakura',
'Aurora',
'Aqua Flash',
'Atlantica',
'Aurora',
'Aurora 2',
'Autumn',
'Beach',
'Beech',
'Blink Red',
'Breeze',
'C9',
'C9 2',
'C9 New',
'Temperature',
'Aurora 2',
'Retro Clown',
'Candy',
'Toxy Reaf',
'Candy2',
'Cloud',
'Cyane',
'Default',
'Departure',
'Drywet',
'Fairy Reaf',
'Semi Blue',
'Pink Candy',
'Red Reaf',
'Aqua Flash',
'Yelblu Hot',
'Fire',
'Forest',
'Grintage',
'Hult',
'Hult 64',
'Icefire',
'Jul',
'Landscape',
'Lava',
'Light Pink',
'Lite Light',
'Magenta',
'Magred',
'Ocean',
'Orange & Teal',
'Orangery',
'Party',
'Pastel',
'Pink Candy',
'Rainbow',
'Rainbow Bands',
'Red & Blue',
'Red Flash',
'Blink Red',
'Red Reaf',
'Red Shift',
'Red Tide',
'Candy2',
'Retro Clown',
'Rewhi',
'Rivendell',
'Sakura',
'Semi Blue',
'Sherbet',
'Splash',
'Sunset',
'Sunset 2',
'Temperature',
'Tertiary',
'Tiamat',
'Toxy Reaf',
'Vintage',
'Yelblu',
'Yelblu Hot',
'Yellowout',
'Yelmag',
]),
}),
'context': <ANY>,
@ -187,77 +187,77 @@
'area_id': None,
'capabilities': dict({
'options': list([
'Default',
'* Random Cycle',
'* Color 1',
'* Colors 1&2',
'* Color Gradient',
'* Colors 1&2',
'* Colors Only',
'Party',
'Cloud',
'Lava',
'Ocean',
'Forest',
'Rainbow',
'Rainbow Bands',
'Sunset',
'Rivendell',
'Breeze',
'Red & Blue',
'Yellowout',
'* Random Cycle',
'Analogous',
'Splash',
'Pastel',
'Sunset 2',
'Beach',
'Vintage',
'Departure',
'Landscape',
'Beech',
'Sherbet',
'Hult',
'Hult 64',
'Drywet',
'Jul',
'Grintage',
'Rewhi',
'Tertiary',
'Fire',
'Icefire',
'Cyane',
'Light Pink',
'Autumn',
'Magenta',
'Magred',
'Yelmag',
'Yelblu',
'Orange & Teal',
'Tiamat',
'April Night',
'Orangery',
'C9',
'Sakura',
'Aurora',
'Aqua Flash',
'Atlantica',
'Aurora',
'Aurora 2',
'Autumn',
'Beach',
'Beech',
'Blink Red',
'Breeze',
'C9',
'C9 2',
'C9 New',
'Temperature',
'Aurora 2',
'Retro Clown',
'Candy',
'Toxy Reaf',
'Candy2',
'Cloud',
'Cyane',
'Default',
'Departure',
'Drywet',
'Fairy Reaf',
'Semi Blue',
'Pink Candy',
'Red Reaf',
'Aqua Flash',
'Yelblu Hot',
'Fire',
'Forest',
'Grintage',
'Hult',
'Hult 64',
'Icefire',
'Jul',
'Landscape',
'Lava',
'Light Pink',
'Lite Light',
'Magenta',
'Magred',
'Ocean',
'Orange & Teal',
'Orangery',
'Party',
'Pastel',
'Pink Candy',
'Rainbow',
'Rainbow Bands',
'Red & Blue',
'Red Flash',
'Blink Red',
'Red Reaf',
'Red Shift',
'Red Tide',
'Candy2',
'Retro Clown',
'Rewhi',
'Rivendell',
'Sakura',
'Semi Blue',
'Sherbet',
'Splash',
'Sunset',
'Sunset 2',
'Temperature',
'Tertiary',
'Tiamat',
'Toxy Reaf',
'Vintage',
'Yelblu',
'Yelblu Hot',
'Yellowout',
'Yelmag',
]),
}),
'config_entry_id': <ANY>,