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

Add support for enqueue options in media_player.play_media service and other minor improvements

This commit is contained in:
Nathan Spencer
2024-07-31 19:16:15 -06:00
parent d70dd0a650
commit cc80c295f6
8 changed files with 119 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ from typing import Any, Awaitable, Callable
from homeassistant.components.select import SelectEntity, SelectEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@@ -48,6 +48,7 @@ class OasisMiniSelectEntity(OasisMiniEntity, SelectEntity):
await self.entity_description.select_fn(self.device, self.options.index(option))
await self.coordinator.async_request_refresh()
@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
new_value = self.entity_description.current_value(self.device)
@@ -89,7 +90,7 @@ DESCRIPTORS = (
OasisMiniSelectEntityDescription(
key="playlist",
name="Playlist",
current_value=lambda device: (device.playlist, device.playlist_index),
current_value=lambda device: (device.playlist.copy(), device.playlist_index),
select_fn=lambda device, option: device.async_change_track(option),
update_handler=playlist_update_handler,
),