Skip to content

Commit

Permalink
fix: update last updated when new mqtt
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja committed May 26, 2024
1 parent 9b0a8b4 commit 4a46e6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions yoto_api/YotoMQTTClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import logging
import paho.mqtt.client as mqtt
import json
import datetime
import pytz


from .const import DOMAIN, VOLUME_MAPPING_INVERTED
from .Token import Token
Expand Down Expand Up @@ -145,6 +148,7 @@ def _parse_status_message(self, message, player):
player.battery_level_percentage = (
get_child_value(message, "batteryLevel") or player.battery_level_percentage
)
player.last_updated_at = datetime.datetime.now(pytz.utc)

def _parse_events_message(self, message, player):
player.repeat_all = get_child_value(message, "repeatAll") or player.repeat_all
Expand Down Expand Up @@ -175,6 +179,7 @@ def _parse_events_message(self, message, player):
or player.sleep_timer_seconds_remaining
)
player.card_id = get_child_value(message, "cardId") or player.card_id
player.last_updated_at = datetime.datetime.now(pytz.utc)

# {"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}

Expand Down

0 comments on commit 4a46e6b

Please sign in to comment.