24/7 media player in group: handle idle as off state

I have a Kodi box in my living room running 24/7 and i have added it to a group representing that room.

Until somewhen last year it would simply be ignored for the group state. Only lights, switches and binary sensors were used for the group state. I relied on this for quite some automations to trigger when any light would be turned on, e.g.

Now, behavior has changed and any media player state not being off seems to lead to my group being on. With Kodi being idle 24/7 all my groups are now on all the time! So, automations won’t trigger.

Is there a way to make group state calculation treat idle as an off state?

Did you find a solution for this? Thanks!

No, unfortunately I have not found a way to do this “natively” in Home Assistant. But I have a work-around for me.

It turned out, I was mainly using the group’s state semantics in a script, which would toggle the group. So, I implemented the old semantics myself. The relevant piece of template is this one:

'on' in expand(entity_id) | map(attribute='state') | list

It returns true if any member of the group passed in the variable entity_id is on. And false otherwise.

Since I had a script and templates already anyway, I just resorted to replacing states(entity_id) with something using the above template snippet:

   toggle_it:
     alias: Toggle anything
     sequence:
+    - variables:
+        entity_id: >
+           {{ entity_id | default(entity,true) }}
+        target_state: >
+          {{ 'off' if 'on' in expand(entity_id) | map(attribute='state') | list else 'on' }}
     - service: script.turn_it
       data_template:
-        entity_id:    '{{ entity }}'
-        target_state: '{{ "off" if states(entity) == "on" else "on" }}'
+        entity_id:    '{{ entity_id }}'
+        target_state: '{{ target_state }}'
1 Like