Dynamic Media Player group for google home minis

Hi all,

does anyone knows a way to create a dynamic media player group ? Basically I want to create a group for all my google mini that are NOT playing anything when a message is brodcast so music is not stopped.

I checked Media Player Group, Universal Media Player and Media Player Template (HACS) but there’s no mention for my specific need.

Any hint?

up?

I found out media_player.join in media_player integration page but there’s just a example to call the service.

Not an example to create a group.

Does anyone ever use it for this purpose?

Up?

Even a “no” would be a good response for me. I’m just asking if this is possible. I created a sensor that does it but it seems that I cannot use sensor domain for tts messages.

Here’s my code anyway :

sensor:
  - platform: template
    sensors:
      media_player_google:
        value_template: >-
          {% if is_state('input_boolean.multiroom','on') %} 
          {%- set players = expand('group.media_player_google')|map(attribute='entity_id')|list %}
          {{ states.media_player | selectattr('state','!=','playing') | selectattr('entity_id', 'in', players) | map(attribute='entity_id') | join(', ') }}
          {% else %}
          {%set domains=['media_player','group']-%}
          {%for x in states if x.domain in domains and x.name|lower==states('input_select.notification_media_player_google')|lower-%}
          {%if x.domain=='group'%}{{-x.attributes.entity_id|join(', ')-}}{%else%}{{-x.entity_id-}}{%endif%}{%endfor%}
          {% endif %}
        icon_template: >-
          {% if is_state('input_boolean.multiroom','on') %} 
          mdi:speaker-multiple
          {% else %}
          {%set domains=['media_player','group']-%}
          {%for x in states if x.domain in domains and x.name|lower==states('input_select.notification_media_player_google')|lower-%}
          {%if x.domain=='group'%}mdi:speaker-multiple{%elif x.domain=='sensor'%}mdi:cast-audio{%else%}mdi:speaker{%endif%}{%endfor%}
          {% endif %}

I don’t think this is possible. The underlying cast library doesn’t seem to support it.

1 Like

Ok thank you for your feedback

There was a discussion around trying to implement this on the library’s github, but it seems to have stalled.

1 Like

Well at least maybe “will” be possible somewhere in the future. I will love to do the same thing as " LukeDefeo" declared. Now I’m subscribed to that issue. Finger crossed and thank you for pointing me to it.

Hi @Jokerigno,

I made a “tts and resume” script that after a tts, if the media player was player before, it continues and at previous volume.

So you can maybe use it

let me know if you have any question

Kind regards, Ghassan

1 Like

WOW!

I’ll have a look at it and let you know. In the meantime thank you ! :slight_smile:

Hi @Jokerigno,

The join service is actually a create and join service.
you specify the master mediaplayer by “entity_id” that controls the slave mediaplayers specified by “group_members”

Here is an example:

service: media_player.join
target:
  entity_id: media_player.spisestue
data:
  group_members: mediaplayer.mibox4

Hope this helps :slight_smile:

@ghassan so does this implicate, i have to start playback on media player first and then execute the service call?

The official Documenation doesnt state what Devices/Services are supporting this feature

Hi @PX80,

I am not sure what you want to achieve. And what service you want to call.

In case it is my “TT and continue” script, then no, you need not to start playback before calling the script. The script will set the media player back to same state after executing the TTS command as it was before. This should work whether the media player was playing or not.

If you are thinking of something else, please explain then I will try to give you my feedback on that.

/Ghassan

@ghassan good morning, basically i want to join cast player as a group player ( which can be achieved native via Google Home ) however i want to realise this via HASS

Hi @PX80

yes should be doable.

What have you done so far, and what is the result?
which challenges do you face?

/Ghassan

My challenge is, that the Spotify Addon or Spotcast do not list Media Player Groups from HA es it only detects cast or spotify connect devices

1.) Can i make a media play group “cast enabled” ?
2.) If i start playback from a Cast Media Player, how to join in the other speaker (Cast Devices)

Cheers
PX

using this for a long time, only found this thread because I was exploring media_player.join, which apparently cant do what we are after…

    action:
      - service: group.set
        data:
          object_id: broadcast_available
          name: Broadcast available
          entities: >
            {{expand('group.broadcast')|rejectattr('state','in',['unknown','unavailable'])
              |map(attribute='entity_id')|join(',')}}

and yes, that group can take all media_player commands, this why I was asking : Use group with media_players, or media_player group

my group.broadcast is a regular group, with all media_players I have. this script/automation auto selects only the available ones. In my player scripts, I use that group.broadcast_available

1 Like

hey Marius…did you find also a way to sync all media players of group.broadcast_available?

you mean if they play the same source in the exact same time? No, I havent explored that, as I dont use that at all.
In fact, I only use this for my intercom, and having it announce slightly out of sync has this nice eerie effect I kind of like :wink: Like an echo waving through the house…

my wife instead HATE the out of sync…that’s why I’m looking for that type of solution.

just found that update. so you are saying it can group all cast devices but do not sync?
as i am using all Nest Audio Speaker and Google is capable of syncing, i assume this will work as well