How make a Master control button?

Hi,

I have several media players, light, switches …

So I want a Master Control on my first lovelace card. These button should show if one of the group (I have a group for media players, switches etc.) is on or running. So I will push the button and everything at this group switch to off.

Thanks for a a first step how to start.
Steffen

Make a group

Add that to your UI.

I have defined a group already, but If I add this to th ui nothing happens if I play one or something?

So I think I must have a script to switch all players off and this must run if I push the button. But how can the button show me if one is running?

Steffen

If you have all on/off devices in the group, the group will have a toggle when placed in the UI.

No they have paused, playing etc.!

And the group shows always unknown?!

[group.grp_sonosmedia]
unknown
entity_id: media_player.bad,media_player.buro,media_player.computer,media_player.keller,media_player.kuche,media_player.schlafzimmer,media_player.toilette,media_player.wohnzimmer,media_player.terrasse
order: 1
friendly_name: Sonos Player

How get a sensor that show if one or more players are playing? Shoudl I need a input_boolean?

I’m very new to Hass.io, Thank you.

That won’t work with media players. You’ll have to make a universal media_player entity that marries all the media players together. This is no easy task and I don’t have a full example on hand. However you should study scripts, media_players, and templates. With all that knowledge, you should be able to make a universal media player that controls all of them.

So I think the first step is taken. I have a group for my Sonos Media Players (nothing Special) and a template for the Master Control:

platform: template
sensors:
  tmp_sonosmedia_master:
    friendly_name: "Sonos Master"
    entity_id:
      - media_player.bad
      - media_player.buro
      - media_player.computer
      - media_player.keller
      - media_player.kuche
      - media_player.schlafzimmer
      - media_player.terrasse
      - media_player.toilette
      - media_player.wohnzimmer
    value_template: >-
      {% set output = namespace(state="off") %}
      {% for entity in states.group.grp_sonosmedia.attributes.entity_id %}
        {% set domain, device = entity.split('.') %}
        {% if ((states[domain][device].state == "playing") and (output.state == "off")) %}
          {% set output.state = "on" %}
        {% endif %}
      {% endfor %}
      {{ output.state }}
    icon_template: >-
      {% set output = namespace(state="off") %}
      {% for entity in states.group.grp_sonosmedia.attributes.entity_id %}
        {% set domain, device = entity.split('.') %}
        {% if (((states[domain][device].state) == "playing") and (output.state == "off")) %}
          {% set output.state = "on" %}
        {% endif %}
      {% endfor %}
      {% if output.state == "on" %}
        mdi:play
      {% else %}
        mdi:stop
      {% endif %}

Here I run the group entity_id’s (it’s nicer to manage the devices a one group file then at many automations, templates etc.) and look at the state. If one is ‘playing’ then the master-template is ‘on’.
So I can use the Entity Button and it works.

So now I think I should make a script to set all media-players off and run this from a button action right?

I’m new to hass.io and it would be nice to here I running Ok without the universal media player or do I have a showstopper at my scripting?

Thanks, Steffen