With latest release 0.107 hass finally supports multi room states for Bose Soundtouch speakers. When a multi room zone exists all speaker have an attribute is_master: true/false.
Is it possible to use wildcards like states.media_player.soundtouch_* so that only the soundtouch media players are adressed in the search for the master device?
That’s a little more difficult. You can’t use a wildcard but you can make this work.
{%- set media = namespace(devices=[]) %}
{%- for m in states.media_player if m.object_id.startswith('soundtouch_') %}
{%- set media.devices = media.devices + [ m ] %}
{%- endfor %}
{{ media.devices | selectattr('attributes.is_master','eq',True) | map(attribute='name') | list | first }}
I have tried what @tom_l suggested but somehow this is not working and I have no clue why. Attribute is_master is clearly true in this example. Any idea?
You seem to be right. This Attribute is pretty new and came with the Hass 0.107 release but there seems to be an error in the integration. The Attribute is_master is not listed:
alright, you don’t have is_master in that list. So i’m guessing is master only appears when you have them ‘grouped’ or ‘playing together’?
Try pairing them together for ‘group play’ and run that template again. To re-execute a template add a space then remove it anywhere in the template lines
This is strange. I mean even the if statement should not be a problem because it would simply say Undefined when the attribute is not available. Guess I’ll open an issue in hass/core. Thanks for your help @petro. If you have other ideas I am happy to try later on.
You need to understand that attributes appear and disappear. This is not an issue with hass/core.
If the attribute shows up in the states page, it will be accessible. If it does not, it will not. Attributes can appear and disappear based on current hardware settings. I"m trying to help you through a solution that works.
So, group them and run the template. If it doesn’t work, then we can fix it so it does.