mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-11-16 00:53:50 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07446f56da | ||
|
|
bd5b2e876d |
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user