1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-16 00:53:50 -05:00

2 Commits
0.3.0 ... 0.3.1

Author SHA1 Message Date
Nathan Spencer
07446f56da Merge pull request #7 from natekspencer/dev
Handle options update in select entity
2024-07-11 14:30:45 -06:00
Nathan Spencer
bd5b2e876d Handle options update in select entity 2024-07-11 14:28:54 -06:00

View File

@@ -27,15 +27,7 @@ class OasisMiniSelectEntity(OasisMiniEntity, SelectEntity):
) -> None: ) -> None:
"""Construct an Oasis Mini select entity.""" """Construct an Oasis Mini select entity."""
super().__init__(coordinator, entry, description) super().__init__(coordinator, entry, description)
self._attr_options = [ self._handle_coordinator_update()
TRACKS.get(str(track), {}).get("name", str(track))
for track in self.device.playlist
]
@property
def current_option(self) -> str:
"""Return the selected entity option to represent the entity state."""
return self.options[self.device.playlist_index]
async def async_select_option(self, option: str) -> None: async def async_select_option(self, option: str) -> None:
"""Change the selected option.""" """Change the selected option."""
@@ -44,11 +36,14 @@ class OasisMiniSelectEntity(OasisMiniEntity, SelectEntity):
def _handle_coordinator_update(self) -> None: def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator.""" """Handle updated data from the coordinator."""
self._attr_options = [ options = [
TRACKS.get(str(track), {}).get("name", str(track)) TRACKS.get(str(track), {}).get("name", str(track))
for track in self.device.playlist for track in self.device.playlist
] ]
return super()._handle_coordinator_update() self._attr_options = options
self._attr_current_option = options[self.device.playlist_index]
if self.hass:
return super()._handle_coordinator_update()
DESCRIPTOR = SelectEntityDescription(key="playlist", name="Playlist") DESCRIPTOR = SelectEntityDescription(key="playlist", name="Playlist")