I have an automation that, at a time in the morning, starts casting a YouTube video to a Nest HUB. When I first set this up, it worked fine:
alias: Wake Up
description: ""
trigger:
- platform: time
at: "07:30:00"
condition: []
action:
- data:
media_content_type: cast
media_content_id: " { \"app_name\": \"youtube\", \"media_id\": \"GOCWT8Ng0yo\" }"
enqueue: play
service: media_player.play_media
target:
device_id: 323a99912ae05ec9a79471e420b87103
- service: media_player.volume_set
data:
volume_level: 0.4
target:
device_id: 323a99912ae05ec9a79471e420b87103
mode: single
Since then, I have updated HA to 2023.8, and migrated my HA to a new Pi 4 with a different IP address that it had previously.
Now the automation fails to automatically work.
In the logs Iām getting:
Wake Up: Error executing script. Unexpected error for call_service at pos 1: 400 Client Error: Parameter missing. for url: https://www.youtube.com/api/lounge/pairing/get_lounge_token_batch
07:30:10 ā (ERROR) Automation - message first occurred at 07:30:10 and shows up 2 times
Failed to update screen_id
07:30:10 ā (WARNING) /usr/local/lib/python3.11/site-packages/pychromecast/controllers/youtube.py
The strange thing is if I manually run the automation / script it starts casting fine, itās just when left to run automatically itās failing.
Iāve had a look and can see mention that things have changed around Nest, but as a newbie to HA, Iām none the wiser as to what Iām required to do to resolve any issue.
Donāt the logs suggest itās more so a YouTube issue in some way?
I donāt know what will replace and if there is something that will work. Personnaly, I found that Nest hub a bit weird. Apart ask something to google and reply, those products are not giving me a lot of possibilities.
Iām not sure what you mean by a custom component. The automation was built using HAās standard interface of triggers and actions (and then changing the YAML to cast YouTube as described here ).
The actions used are ācall a serviceā which use media_player.play_media which are native to HA is my understanding.
I tried some small tests and basic cast is ok (cast local camera) but even by using multimedia tab, choose spotify to Google TV or Nest Hub, nothing is played.
Cast radio available in multimedia work just fine.
If I open spotify app and cast to those devices, itās OK.
So for me, itās not your automation. I also test using dev tool - service play media . I didnāt have a chance to play something from youtube
Last night I created a brand-new automation, and throughout the evening I changed its trigger to test at different times. It worked fine and would kick in automatically, casting YouTube to the device.
Thinking everything was working fine, I then set itās time for 07:30 for this morning.
The script triggered, but no YouTube cast started on the device.
Doing a bit of digging around the 'ol internet I get the sense this might be due to YouTube lounge tokens expiring and needing to be refreshed. But I could be wrong. I know nothing about this topic.
Just to update that Iāve had no joy resolving this.
My super low-tech idea for a solution was that if itās a refresh issue, that Iād make two automations with a minute between them. So the first one would fire (and fail, but hopefully refresh any API / tokens), and the second one would then kick in:
What I fundamentally donāt understand is if I manually run / force the automation, they work fine. Thereās something about the inclusion of the automatic time trigger, which when used means they donāt work.
I donāt understand why that would make a difference, but thatās what Iām experiencing.
I am having the exact same issue. Automation worked. I changed to .8 and started getting the failure to get lounge token or missing api parameter error.
Iām having the issue also, it produces the ātoken batchā error and also āunknown errorā. If an automation includes any media casting it doesnāt work. This includes both the cast and url methods.