Hi,
I try to determine the number of batteries with less than 20%. I figured out how to to count those with exactliy 20%, but not with less than 20%. Here’s my code in the sensor template:
{% set label = 'batteries' %}
{% set threshold = '20' %}
{% set num = (label_entities(label) | select('is_state',threshold) | list | count) %}
{{num}}
I tried a “solution” i found in via google
{% set label = 'batteries' %}
{% set threshold = '20' %}
{% set num = (label_entities(label) | selectattr('state','lt',threshold) | list | count) %}
{{num}}
but i get that error: “UndefinedError: ‘str object’ has no attribute ‘state’”
How can i count the entities ?