Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106117

Data type error, I guess

$
0
0

Hi,
I use Heos players around the house.
I created a nice little dashboard and some cards visibility are linked to Helpers value.

My goal is to identify if a player is in a group but NOT the group leader. In this case, I hide its card as it is linked to a group leader and I don’t need to change anything to it.

For instance, for “kitchen”, here are the different possibilities for “group_members” value

  • group_members: media_player.kitchen, media_player.office, media_player.workshop
    => result should be FALSE as it is leader of the group (first in the list)
  • group_members: media_player.office, media_player.kitchen, media_player.workshop
    => result should be TRUE as it is member of a group BUT not the leader.
  • group_members: null
    => Result should be FALSE as it is not member of a group.

To do so, I tried this :

{% set m = ‘media_player.kitchen’ %}
{% set g = state_attr(m, ‘group_members’) | list %}
{{ m in g and g|first|default(‘’) != m }}

It nearly works :slight_smile:

It gives me the correct answer BUT, if the device is not a group member at all, “group_members” is null and my test fails.

I might have some kind of variable declaration issue where the test can not evaluate the content of a null list. If it set g as a string, it works when the string is null (but fails if the string is actually a list).

Any suggestion ?

Thanks a lot !

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106117

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>