From 345e12e422da1d61e759bb05f4a21ea74f7d6ebd Mon Sep 17 00:00:00 2001 From: cdnninja Date: Wed, 8 May 2024 19:36:58 -0600 Subject: [PATCH] feat: additional status data (#39) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- yoto_api/YotoMQTTClient.py | 11 +++++++++-- yoto_api/YotoPlayer.py | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/yoto_api/YotoMQTTClient.py b/yoto_api/YotoMQTTClient.py index 371ef1f..ade9731 100644 --- a/yoto_api/YotoMQTTClient.py +++ b/yoto_api/YotoMQTTClient.py @@ -64,15 +64,22 @@ def _parse_events_message(self, message, player): player.volume_max = get_child_value(message, "volumeMax") player.online = get_child_value(message, "online") player.chapter_title = get_child_value(message, "chapterTitle") + player.track_title = get_child_value(message, "trackTitle") + player.track_length = get_child_value(message, "trackLength") + player.track_position = get_child_value(message, "position") + player.source = get_child_value(message, "source") + player.playback_status = get_child_value(message, "playbackStatus") + player.sleep_timer_active = get_child_value(message, "sleepTimerActive") + player.card_id = get_child_value(message, "cardId") - # {"repeatAll":true,"volume":6,"volumeMax":6,"cardId":"none","playbackStatus":"stopped","streaming":false,"playbackWait":false,"sleepTimerActive":false,"eventUtc":1714960275} + # {"trackLength":315,"position":0,"cardId":"7JtVV","repeatAll":true,"source":"remote","cardUpdatedAt":"2021-07-13T14:51:26.576Z","chapterTitle":"Snow and Tell","chapterKey":"03","trackTitle":"Snow and Tell","trackKey":"03","streaming":false,"volume":5,"volumeMax":8,"playbackStatus":"playing","playbackWait":false,"sleepTimerActive":false,"eventUtc":1715133271} def _on_message(self, client, player, message): # Process MQTT Message + _LOGGER.debug(f"{DOMAIN} - MQTT Topic: {message.topic}") _LOGGER.debug( f"{DOMAIN} - MQTT Message: {str(message.payload.decode('utf-8'))}" ) - _LOGGER.debug(f"{DOMAIN} - MQTT Topic: {message.topic}") # _LOGGER.debug(f"{DOMAIN} - MQTT QOS: {message.qos}") # _LOGGER.debug(f"{DOMAIN} - MQTT Retain: {message.retain}") parts = message.topic.split("/") diff --git a/yoto_api/YotoPlayer.py b/yoto_api/YotoPlayer.py index f08a373..2c97da8 100644 --- a/yoto_api/YotoPlayer.py +++ b/yoto_api/YotoPlayer.py @@ -32,10 +32,17 @@ class YotoPlayer: power_source: str = None # MQTT + card_id: str = None repeat_all: bool = None volume_max: int = None volume: int = None chapter_title: str = None + source: str = None + track_title: str = None + track_length: int = None + track_position: int = None + playback_status: str = None + sleep_timer_active: bool = None # {'devices': [{'deviceId': 'XXXX', 'name': 'Yoto Player', 'description': 'nameless.limit', 'online': False, 'releaseChannel': 'general', 'deviceType': 'v3', 'deviceFamily': 'v3', 'deviceGroup': '', 'hasUserGivenName': False}]}