Skip to content

Commit

Permalink
Add restart function to local speaker
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 16, 2024
1 parent 29b592d commit 732ab66
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions custom_components/yandex_station/core/yandex_station.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import binascii
import json
import logging
Expand Down Expand Up @@ -821,9 +822,6 @@ async def async_play_media(
elif media_type == "json":
payload = json.loads(media_id)

elif RE_MUSIC_ID.match(media_id):
payload = {"command": "playMusic", "id": media_id, "type": media_type}

elif media_type == "shopping_list":
coro = shopping_list.shopping_sync(self.hass, self.glagol)
await self.hass.async_create_background_task(coro, self.name)
Expand All @@ -835,6 +833,15 @@ async def async_play_media(
await self.response(card, request_id)
return

elif media_type == "restart":
await self.glagol.stop()
await asyncio.sleep(float(media_id))
await self.glagol.start_or_restart()
return

elif RE_MUSIC_ID.match(media_id):
payload = {"command": "playMusic", "id": media_id, "type": media_type}

else:
_LOGGER.warning(f"Unsupported local media: {media_id}")
return
Expand Down

0 comments on commit 732ab66

Please sign in to comment.