Hello. I need some help with my code. I want to list the light that goes unavailable in my group.light_status. Below is what I have. It kinda works, but it does not list the next light that goes unavailable.
{% set list = state_attr(('group.light_status'), 'entity_id') %}
{% if states.light | selectattr('entity_id', 'in', list) | selectattr('state','eq','unavailable') | list | count >=1 %}
{% set light = states.light | selectattr('entity_id', 'in', list) | selectattr('state','eq','unavailable') | map(attribute='entity_id') | sort(attribute='last_changed') | last %}
{{ light }}
{% endif %}
group:
light_status:
- light.wc_1
- light.g_1
- light.h_1
- light.c_1
- light.s_1
- light.l_1
- light.k_1