This package started somewhere in 2020 as a simple script to resume a Google Cast device after it was interrupted by a TTS message. During the years more functionality was added, the Cast devices can also be resumed after playing an audio file, or casting a Home Assistant Dasboard. In the past years I also created others scripts using the Google Home Resume script. There is a script to determine on which device a question was asked and send a TTS or play a file on that specific device. Another script stores the state of the cast devices in a template sensor, so it can be resumed in later (for example store it when you leave home, and restore it when you arrive home again).
All these scripts are now combined in one package
The automation to start the resume is intended to be used as a backup. If you already know you are going to send (like a TTS or mp3) and know you want to resume what was playing afterwards, I strongly advice to start the script yourself, and not rely on the automation, as it is a bit flaky. See here for instructions how to do that.
service
to action
speaker_groups
section in the setting, as the members are stored in an attribute of the media player entity.false
actually works.Previous changes can be found here:
If you are still using a version wich is not using the YYYY.MM version numbering, you are not using packages yet. Remove the existing Google Home scripts you are using (Resume/Voice/Event) and the Google Home Resume automation if you were using that. If you were using the Google Home Event script, also remove the template sensor used by that script.
After removing all the old stuff reload Scripts, Automations and Template entities from Developer Tools > YAML () or restart Home Assistant. Then move on to Install the package.
Remove the Google Home Voice script if you were already using it, and the Google Home Event package if you were using that. Reload scripts and template entities in Developer Tools > YAML Developer Tools > YAML or restart Home Assistant.
π¨ IMPORTANT: Add the settings for the Voice Script to the settings you already have. The line voice_settings: &voice_settings
needs to be included, otherwise you'll get errors while loading the configuration π¨ Then copy everything below the settings from the package file on this GitHub repo and overwrite the current code in the package on your system using a file editor (like Visual Studio Code Add-on or File Editor Add-on), not via the GUI.
Make sure to add these voice_settings
in a way that the current settings are still under the settings
key.
## correct
settings: &settings
primary_spotcast: john_doe
voice_settings: &voice_settings
## also correct
voice_settings: &voice_settings
settings: &settings
primary_spotcast: john_doe
## not correct
settings: &settings
voice_settings: &voice_settings
primary_spotcast: john_doe
configuration.yaml
homeassistant:
# include this line
packages: !include_dir_named packages
packages
in your configuration folder (the same folder as where configuration.yaml
is located)google_home_resume.yaml
in that folder, and paste the contents of the link above in that file.You can perform the steps above using a file editor (like Visual Studio Code Add-on or File Editor Add-on), not via the GUI.
There are no required settings, but if you use Google Home speaker groups you should define those as described below. Resuming Spotify with multiple accounts won't work properly without primary_spotcast
. dummy_player
is required to send a TTS with picture and text.
Variable | Default | Example | Description |
---|---|---|---|
primary_spotcast | pepijn |
The Spotify account which is used as primary account for spotcast, should match the last part of the Spotify media player. | |
radio_data | My settings | A dictionary with the pictures and titles. The picture urls should be full urls, not HA internal urls). As key value the artist should be used (check media_artist in developer tools > states) |
|
speaker_groups | My settings | A combination of a dictionary and a list, with the speaker groups created in the Google Home app and it's members. | |
default_volume_level | 0.25 |
0.5 |
The default volume level to use to restore the entity to if the old volume can not be retreived (this should actually never be used, but it there as a failsafe). This is not used for the TTS message |
dummy_player | media_player.vlc_telnet |
The dummy media_player used for the TTS with picture and text feature | |
default_resume_delay | 20 seconds | 20 |
The delay after which the resume will started when it was interrupted by sending an image. Follows the syntax of delay, so also "00:00:20" or seconds: 20 can be used. |
max_runtime | "00:10:00" | The maximum duration the Resume script should run, if this time is reached the script will be stopped. This avoids entities being logged in the groups, which will stop them from being resumed on a new disruption. Follows the syntax of delay, so also 600 or minutes: 10 can be used. |
|
stop_before_action | false |
true |
If media_players should be stopped before the actions provided in the script data are performed. |
automation_enabled | false |
true |
If the automation for automatic resume should be used or not |
dashboard_cast | false |
false |
If the automation should be used in case a HA Dasboard is cast to the device |
announce_volume_automation | 0.75 |
The volume used for announcements in the automation, remove or leave empty to leave the volume as it is. |
For the Google Home Voice script there are 2 specific settings, these are described in the [documentation]() of the Voice script.
media_player.spotify_{{ account name }}
. sp_key
and sp_dc
as described in the spotcast documentation. It is very important that the account names you use here, match the account names from the entity_ids of the Spotify media_player entities.primary_spotcast
account.3 Spotify integrations:
The media_players entities connected to these Spotify integration are named:
media_player.spotify_floris
media_player.spotify_marleen
media_player.spotify_martijn
Spotcast setup (the Spotify account for Floris
is the primary account, and has no named account in the spotcast setup), so the primary_account
in this example is floris
:
spotcast:
sp_dc: !secret sp_dc
sp_key: !secret sp_key
country: NL
accounts:
marleen:
sp_dc: !secret sp_dc_marleen
sp_key: !secret sp_key_marleen
floris:
sp_dc: !secret sp_dc_martijn
sp_key: !secret sp_key_martijn
In case you want to send a TTS with a picture and some text, you need to set up a dummy media_player which accepts TTS messages.
The feature to send a TTS together with picture and text works as as follows. The TTS is sent to a dummy player, and the script will wait for this event, and will take the url the the mp3 used as TTS message. It will then send this mp3 together with the picture and text to the actual target. As of Home Assistant 2022.4 there is a check if a target of a service call actually supports the service call. So the dummy player has to support TTS. As the media_player created by the VLC Telnet integration supports TTS, I use this.
In case you use HA OS, or run a supervised install, you can add the VLC Add-on from the add-on store. After starting the add-on it will automatically be detected by Home Assistant, and you can add the VLC Telnet integration. This will create media_player.vlc_telnet
which you can use as dummy player.
In case you don't have the supervisor or already use this add-on for other purposes, you can possibly use the media_player created by the browser_mod custom component. Or you can buy an additionaly Nest Mini, set the volume to 0
and hide it somewhere π
The Google Home Resume script is used to resume a Google Home device after it has been interrupted. For example when a TTS has been sent, or when a sound has been played. You can manually trigger the script, and include the action after which it should be resumed in the service call for the script, or you can use the automation. More information on how to use the Google Home Resume script can be found here
The Google Home Voice script uses Google Home Routines and Ambient sounds to check on which device you issued a voice command, so it can send a TTS message or other action to that specific device. More information on how to use the Google Home Voice script can be found here
The Google Home Event script can store the data of your devices in a template sensor, so you can restore the states on a later moment. So you can store the state when you leave the house, and restore the music when you come back in. More information on how to use the Google Home Event script can be found here
In case you have a question, you found a bug, or have a feature request, you can either ask here, or open an issue on my GitHub repository. In case you create a GitHub issue, please label it with google home scripts
In case something isn't working or you found a bug, a trace of the script will be needed in most cases to determine the cause. The trace can be downloaded as a json file. To do this follow the steps below:
Configuration > Automations & Scenes > Scripts
or use Traces
Download trace
In case you create the issue on GitHub you can upload the json files, in case you create the issue as a post here, you can copy the json files to a code sharing website like dpaste.org. Please create a different link for each json file.
I've been asked a couple of times if I ever considered to make a blueprint out of this script. I do understand this would make updates more easy, however there are also some things which make it quite complicated:
So, basically, I gave it a try, and decided it would not work :)
If you like this script, please feel free to buy me a coffee (I might spend it on another beverage though). In case you decide to do so, thanks a lot!