Hi,
is there anything similar to the sonos.snapshot service for the Denon HEOS integration? Especially in connection with text-to-speech (tts) service?
I’m using the following script for tts on HEOS and it would be great if – after the tts-file was played – the HEOS speakers would start playing the content they were playing before.
heos_say:
alias: "HEOS TTS script"
sequence:
- service: media_player.volume_set
data:
entity_id: "{{ heos_entity }}"
volume_level: "{{ volume }}"
- service: tts.google_translate
data:
entity_id: "{{ heos_entity }}"
message: "{{ message }}"
- delay: '{{ delay }}'
- service: media_player.clear_playlist
data:
entity_id: "{{ heos_entity }}"
Has anybody an idea how I can achieve that with the HEOS integration? With the SONOS integration the script would look like this:
sonos_tts:
alias: 'sonos tts'
sequence:
- service: sonos.snapshot
data:
entity_id: media_player.living_room
- service: sonos.unjoin
data:
entity_id: media_player.living_room
- service: media_player.volume_set
target:
entity_id: media_player.living_room
data:
volume_level: 0.5
- service: tts.google_say
data:
entity_id: media_player.living_room
message: "message"
language: en-uk
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: sonos.restore
data:
entity_id: media_player.living_room
(source: TTS with Sonos)
Thanks for any suggestions.
1 Like
I have been looking for the same behaviour, but it wasn’t on my priority list yet to actually figure out.
After taking a look at how it’s done (in the code) for Sonos, it seems it’s baked into the library used. Sadly the heos library does not support this (yet).
However, it seems like the library sort of just stores the media_url and media_ids of what’s actually playing. Perhaps it’s a possibility to store this data inside variables during the automation? That way you could set the players to continue playing the same media, it’s likely it’ll restart songs though, not sure how those playlists from Spotify etc actually get handled.
I can not even figure out how to get spotify to play on a heos speaker using automations… but this was actually the same use case… wanted to resume music after a message is spoken…
Coming back to this, I’m now starting to configure a lot of things with media_players in my house. I was able to get a first version up and running for my use case:
- service: media_player.media_pause
target:
entity_id: media_player.spotify_xx
- service: media_player.volume_set
target:
entity_id: media_player.heos_living
data:
volume_level: 0.4
- service: tts.cloud_say
data:
entity_id: media_player.heos_living
message: Hallo, dit is een test berichtje, hoe cool is dit?
options:
gender: female
language: nl-NL
- wait_for_trigger:
- platform: device
device_id: 3ba398b405128b0ebd7de3f28daf604c
domain: media_player
entity_id: media_player.heos_living
type: idle
- service: media_player.volume_set
data:
volume_level: 0.22
target:
entity_id: media_player.heos_living
- service: media_player.media_play_pause
target:
entity_id: media_player.spotify_xx
This is part of a nested choose right now, to check if Spotify is playing on the heos_living
media player. This check is simply done by 2 conditions:
- condition: device
device_id: 3558409bf1a011ea827953ae963abbfc
domain: media_player
entity_id: media_player.spotify_xx
type: is_playing
- condition: state
entity_id: media_player.spotify_xx
state: Living
attribute: source
Currently it seems there’s still a small issue, where it seemingly wants to play the message a second time or something like that (I hear the ‘Hallo’ part again, then it switches back).
Obviously this only works with spotify, because that one keeps it’s playlist and progress internally.
Next up will be trying to properly set it up to work with simple URLs (like internet radios)
Can you play Spotify to your HEOS speaker from your phone? also, do you have Spotify Premium? If I recall correctly you can’t interact with Spotify at all (other than seeing is it’s playing and what it’s playing) if you have the free tier
I do have premium, and yes we always use our phones to play Spotify on our heos speakers. But now I wanted to resume the music after interrupted it with a notification. We have 4 Spotify accounts in the family and all of us get pretty annoyed over that we need to restart the music after a notification has been played. So i only use it for important stuff. But would like to use it more often
With my previously posted code it would work, but you’d need to find and store which account is actually playing on the speakers so you can restore the same account. Multi-room (grouped) speakers also wouldn’t really play nicely, as you’d pause the music on all speakers, for my use case it doesn’t happen as I don’t have them grouped, but it’s a problem I could see happening…
Yes, pausing Spotify first before changing source is a smart way, will try it next time i have time