Skip to content

Commit

Permalink
Add channel selection for IR media_player
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 18, 2024
1 parent dd5aab1 commit 10c88bc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions custom_components/yandex_station/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
MediaPlayerEntity,
MediaPlayerEntityFeature,
MediaPlayerState,
MediaType,
)
from homeassistant.const import CONF_INCLUDE

Expand Down Expand Up @@ -119,6 +120,7 @@ def internal_init(self, capabilities: dict, properties: dict):
if "channel" in capabilities:
self._attr_supported_features |= MediaPlayerEntityFeature.NEXT_TRACK
self._attr_supported_features |= MediaPlayerEntityFeature.PREVIOUS_TRACK
self._attr_supported_features |= MediaPlayerEntityFeature.PLAY_MEDIA

if item := capabilities.get("input_source"):
self.sources = {i["name"]: i["value"] for i in item["modes"]}
Expand Down Expand Up @@ -152,9 +154,16 @@ async def async_media_next_track(self):
async def async_media_previous_track(self):
await self.quasar.device_actions(self.device["id"], channel=-1)

async def async_media_play(self):
await self.quasar.device_actions(self.device["id"], pause=False)

async def async_media_pause(self):
await self.quasar.device_actions(self.device["id"], pause=True)

async def async_select_source(self, source: str):
source = self.sources[source]
await self.quasar.device_actions(self.device["id"], input_source=source)

async def async_play_media(self, media_type: MediaType, media_id: str, **kwargs):
if media_type == MediaType.CHANNEL:
await self.quasar.device_actions(self.device["id"], channel=int(media_id))

0 comments on commit 10c88bc

Please sign in to comment.