Skip to content

Commit

Permalink
Merge branch 'browseMedia' of https://github.com/cdnninja/yoto_ha int…
Browse files Browse the repository at this point in the history
…o browseMedia
  • Loading branch information
cdnninja committed Jun 17, 2024
2 parents d1ff11f + 824d0f1 commit d8bbf8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The easiest way to install this integration is via HACS. https://hacs.xyz/
# Services Working

- Play/Pause
- Play Media/Card via service call (format of media id is cardid-chapterid-trackid, if you leave off chapterid/trackid will start at chapter and track 1.)
- Play Media/Card via service call (format of media id is cardid-chapterid-trackid, if you leave off chapterid/trackid will start at chapter and track 1.)
- Stop Media via service call
- Set Time for Day/Night Modes
- Set display brightness Day/Night including auto
Expand Down
5 changes: 4 additions & 1 deletion custom_components/yoto/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ async def async_play_media(
announce: bool | None = None,
**kwargs: Any,
) -> None:
await self.coordinator.async_play_card(self.player.id, media_id)
cardid, chapterid, trackid = split_media_id(media_id)
await self.coordinator.async_play_card(
self.player.id, cardid, chapterid, trackid
)

async def async_set_volume_level(self, volume: float) -> None:
await self.coordinator.async_set_volume(self.player.id, volume)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/yoto/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def rgetattr(obj, attr):

def split_media_id(text):
# a synthetic media idea in the format of cardid-chapterid-trackid
parts = text.split('-')
parts = text.split("-")
if len(parts) >= 3:
cardid, chapterid, trackid = parts
elif len(parts) == 2:
Expand All @@ -26,4 +26,4 @@ def split_media_id(text):
else:
cardid = text
chapterid = trackid = None
return cardid, chapterid, trackid
return cardid, chapterid, trackid

0 comments on commit d8bbf8e

Please sign in to comment.