Skip to content

Commit

Permalink
feat: additional status data (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cdnninja and pre-commit-ci[bot] authored May 9, 2024
1 parent 5375f06 commit 345e12e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions yoto_api/YotoMQTTClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down
7 changes: 7 additions & 0 deletions yoto_api/YotoPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]}
Expand Down

0 comments on commit 345e12e

Please sign in to comment.