Hello guys!
As many of you know, currently it is not possible to send an audio (like an announcement, for example) to a cast device (Google Home Mini in my case) and not cancel/stop the currently playing media. This is a pain since you have to resume playing manually the previous media.
I’ve came up with an idea that could overcome this problem: create a template_sensor
that “calculates” all media_player
entities that are currently not playing and result as text, so it can be used on any script or automation as the entity_id
to play the desired media without interrupting the currently playing ones.
I was not able to came up with a reasonably good solution/code so I’ve decided to write this post. Maybe a good soul here could help me out? I think this could be a nice solution for many people as well.
The idea is to, firstly, see if all speakers are playing something (Group created on the app), if yes, check all other media_players
on a custom list that is not currently playing anything and result all of them as text, comma separated. If non of them are playing, result the all speakers group entity_id
, if all speakers (group) are playing, output nothing, null or empty, not sure.
I find very important to use the “all speakers” group because of the audio synchronization problem if all of them are played at the same time separately…
Here is my “all speakers” group:
media_player.casa_inteira
These are all available individual Google Home Minis:
media_player.banheiro_social
media_player.banheiro_suite
media_player.cozinha
media_player.quarto
media_player.sala
media_player.suite
For example:
if media_player.banheiro_social
and media_player.cozinha
are playing, the sensor_template
should output:
media_player.banheiro_suite, media_player.quarto, media_player.sala, media_player.suite
This can be used to call only the available GHM at the time the service is called, so the rest are not interrupted.
This would be the service call:
- service_template: media_player.play_media
data_template:
entity_id: {{states.sensor.available_speacker.state}}
media_content_id: 'http://hassio.local:8123/local/audio/tts/sistema_reiniciado.mp3'
media_content_type: 'audio/mp3'
Does it make sense?
Sorry, english is not my mother language
Have a great day guys!