I added a new field resume_this_action. This is a boolean (true or false). The default is true. If set to false the actions which you use in the script will not be resumed if the script is called again. I can best explain this using a real life example.
I’ve set up a tag scanner on which my kids can scan a card, and then some song will play. If there was already something playing (a TuneIn stream for example) I want that stream to resume after the song finished. However, the kids tend to scan the card a second time when they don’t like the song. If that happens the first kids song which was already playing, would be resumed afterwards. With resume_this_action: false this will not be the case.
To let the resume_this_action: false setting work, I’ve added two dynamically created groups. Because this can get messy when you do a script reload while the scripts are running, the script will remove these groups if it is started for the first time (attribute current is 1).
Bug fixes
Resuming of the ytube_mucis_player entities actually works like I intended it now.
I have no idea how to implement this script. If I copy the lines from your script to script section in HA it tells me that Message malformed: extra keys not allowed @ data[‘google_home_resume’] , I have no idea how to solve this so I have copied the script in the scripts.yaml, also with my
Many thanks! The last 2 days was a adventure for me to setup this to work and I have stumbeld and asked for help for the simplest issue. It WORKS! Thank you again also for the script!
Temporary fix to avoid log warnings when the script tries to remove non existing groups (will replace these 3 choose blocks with a repeat in the next version. (Thanks for reporting this @Manazer )
Groups will also be removed when the last instance of the script finishes.
Sorry, but after update 1.1.2 another error occures:
Logger: homeassistant.helpers.template
Source: helpers/template.py:1834
First occurred: 8:20:07 AM (3 occurrences)
Last logged: 8:20:07 AM
Template variable error: 'integration_enities' is undefined when rendering '{{ 'group.resume_script_active' in integration_enities('group') }}'
Template variable error: 'integration_enities' is undefined when rendering '{{ 'group.resume_active' in integration_enities('group') }}'
Template variable error: 'integration_enities' is undefined when rendering '{{ 'group.resume_action_false' in integration_enities('group') }}'
and warning:
Logger: homeassistant.helpers.script
Source: helpers/script.py:659
First occurred: 8:20:07 AM (3 occurrences)
Last logged: 8:20:07 AM
Error in 'choose[0]' evaluation: In 'template' condition: UndefinedError: 'integration_enities' is undefined
Sorry, that’s what you got when you quickly want to change something on mobile.
There was a typo in the template function. Should be fixed now in 1.1.3.
Hey @TheFes, great work on the comprehensive script.
Any light at the end of the tunnel for no-screen devices playing YouTube Music ? i.e. Google Home Mini.
Why doesn’t it work when there is no screen ? I can see my mini speaker has media_content_id when playing YouTube music, app_name shows “Youtube Music” and I can control the player through Home Assistant when it’s already “loaded” (started by voice and playing something). I’ve been trying different ways to get it to play something using the media_player.play_media service but no luck. When using app_name: Youtube Music then nothing happens but when using app_name: Youtube then it loads the youtube player in Home Assistant (but nothing starts playing because youtube and youtube music content id’s probably don’t match). Anyways, if you have ideas how to get this to work, that would be super cool, probably many other people looking for this solution as well.
Hi. What you describe here is exactly what I do in the script as well, and what does work for devices with a screen. So the problem is not that the media_content_id doesn’t match, the problem is that the app_name: youtube is not supported on devices without a screen.
I’ve tried everything I could think of as app_name for YouTube Music, but nothing worked.
The only way I could get it to work is using the ytube_music_player custom integration, but only if the stream was started using that integration.
Do note that resuming the stream using cast is limited as well, as it will only resume the video/song which was playing, and not the complete playlist/album/channel
A somewhat workaround solution might be to send a text command from HA to Google Assistant speaker: “play the last song on youtube music”. Then it should at least restart the last played song. Could even try something like “continue playing the last song from where it was last stopped”. Google Assistant is pretty smart and something like this might work, haven’t tested tho. I know there were some addons and ways to send text commands this way, don’t remember exactly. Something to do with webhooks and IFTTT. Maybe you get some good ideas through this angle
Could also be done with something like Assistant Relay, but that will be difficult because people will use different languages for their Google Home. So you can’t just use a command in English.
You will also run in issues when there are different people in the same house all using their own account, how will you know which account was used to play it.
For YouTube Music the best solution at this moment is ytube_music_player. But then you can’t start it by voice command, you’ll have to use the media browser of HA.
It’s unfortunate that the same information as is available though the Spotify integration is not visible.
I use your script, it works well! Great work, thak you! I have two small problems with it. I only use to resume to tunein, and the resume is a bit slow(start to conect to stream quickly, but the connecting is slow). It’s a lot slower, like I’m just starting tunein. Why? The other problem is that after resume, on my hub, the screen is blank, not showing what it is playing(not showing anything). Am i doing something wrong, or is it normal?