cdnninja / yoto_ha

Home Assistant Integration for Yoto
MIT License
54 stars 7 forks source link

Media player / sensors don’t update #115

Open JamesSnaps opened 2 weeks ago

JamesSnaps commented 2 weeks ago

Just something I’ve noticed over the last couple of days, our Yoto doesn’t update the media player after a period of time. It just shows Idle even if something is playing. If I open the Yoto app then the media player updates in HASS and shows the currently playing item.

Strangely I can still control the volume from HASS but the state won’t update to Playing until the Yoto app has been opened.

I also noticed this morning that other sensors like Charging or Ambient Light didn’t update either. Both showed old data until I reloaded the configuration.

cdnninja commented 2 weeks ago

Anything in logs showing disconnects?

JamesSnaps commented 2 weeks ago

Unfortunately not. I went to the Yoto just now, saw it showed idle so plugged a card in and let it play. Still showed idle in HASS. So I turned debug logging on and then opened the Yoto app.

It immediately updated to 'playing' in HASS (this was around 16:49/16:50). No logs listed for Yoto at all until I opened the app but then these followed in the debug file. Almost like the player wasn't sending any commands until I used the app to wake it? Even though it was technically awake as it was playing.

Anything else I can check for you?

2024-09-09 16:50:14.459 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/status 2024-09-09 16:50:14.459 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"status":{"battery":3995,"powerCaps":"0x08","batteryLevel":100,"batteryTemp":0,"batteryData":"0:0:0","batteryLevelRaw":81,"free":3708948,"freeDMA":62506,"free32":84610,"upTime":113429,"utcTime":1725897010,"aliveTime":181410,"activeCard":"qQAag","cardInserted":1,"playingStatus":5,"qiOtp":0,"dnowBrightness":100,"errorsLogged":186,"nightlightMode":"off","temp":"964:24:311","als":4095}} 2024-09-09 16:50:14.459 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv 2024-09-09 16:50:22.054 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/response 2024-09-09 16:50:22.054 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"status":{"events":"OK","req_body":""}} 2024-09-09 16:50:22.054 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv 2024-09-09 16:50:22.115 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/events 2024-09-09 16:50:22.115 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"repeatAll":false,"streaming":false,"volume":4,"volumeMax":16,"playbackWait":false,"sleepTimerActive":false,"eventUtc":1725897018,"trackLength":359,"position":298,"cardId":"qQAag","source":"card","cardUpdatedAt":"2021-11-17T13:05:17.856Z","chapterTitle":"Iron Man: Invincible!","chapterKey":"8z89rR-l14","trackTitle":"Iron Man: Invincible!","trackKey":"8z89rR-l14","playbackStatus":"playing"} 2024-09-09 16:50:22.115 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv 2024-09-09 16:50:22.116 DEBUG (MainThread) [custom_components.yoto.coordinator] yoto - Updating Card details for: qQAag 2024-09-09 16:50:27.175 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/events 2024-09-09 16:50:27.176 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"trackLength":359,"position":303,"cardId":"qQAag","repeatAll":false,"source":"card","cardUpdatedAt":"2021-11-17T13:05:17.856Z","chapterTitle":"Iron Man: Invincible!","chapterKey":"8z89rR-l14","trackTitle":"Iron Man: Invincible!","trackKey":"8z89rR-l14","streaming":false,"volume":4,"volumeMax":16,"playbackStatus":"playing","playbackWait":false,"sleepTimerActive":false,"eventUtc":1725897023} 2024-09-09 16:50:27.176 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv 2024-09-09 16:50:32.225 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/events 2024-09-09 16:50:32.225 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"trackLength":359,"position":311,"cardId":"qQAag","repeatAll":false,"source":"card","cardUpdatedAt":"2021-11-17T13:05:17.856Z","chapterTitle":"Iron Man: Invincible!","chapterKey":"8z89rR-l14","trackTitle":"Iron Man: Invincible!","trackKey":"8z89rR-l14","streaming":false,"volume":4,"volumeMax":16,"playbackStatus":"playing","playbackWait":false,"sleepTimerActive":false,"eventUtc":1725897028} 2024-09-09 16:50:32.225 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv 2024-09-09 16:50:37.341 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Topic: device/y2ENCAR0tJ9EVzZKlo6bVvQv/events 2024-09-09 16:50:37.341 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - MQTT Message: {"trackLength":359,"position":315,"cardId":"qQAag","repeatAll":false,"source":"card","cardUpdatedAt":"2021-11-17T13:05:17.856Z","chapterTitle":"Iron Man: Invincible!","chapterKey":"8z89rR-l14","trackTitle":"Iron Man: Invincible!","trackKey":"8z89rR-l14","streaming":false,"volume":4,"volumeMax":16,"playbackStatus":"playing","playbackWait":false,"sleepTimerActive":false,"eventUtc":1725897033} 2024-09-09 16:50:37.341 DEBUG (Thread-9181 (_thread_main)) [yoto_api.YotoMQTTClient] yoto_api - Message is for: y2ENCAR0tJ9EVzZKlo6bVvQv

cdnninja commented 2 weeks ago

What I find is the Mqtt server stops sending updates after some time. We have to poke the server to wake it up again.

Right now some logic exists to do that after an interval. Sounds like it may need to be shorter. I'm finding mine works fine, but may have other factors.

JamesSnaps commented 2 weeks ago

Okay, let me know if I can help at all. Right now I can just set an automation to reload the integration every hour or so I guess, see how that goes.

cdnninja commented 2 weeks ago

What's your update interval set to? That interval is focused on "config" items like lights etc.

JamesSnaps commented 2 weeks ago

You mean on the Yoto integration? The scan interval is just the default, 60 mins.

Would setting it lower give me a more responsive update on the media player side of things? Basically I want to tie automations to playback start and stop so ideally want to get it fairly reactive.

cdnninja commented 2 weeks ago

Shouldn't be needed, play back should come in real time. That polling interval is just configuration items not playback.

I'll double check the interval that it kicks off the "request playback" update. Like opening the app I wrote in something to ping the server if it hasn't had an update in awhile. Since server seems to fall asleep after awhile.