Hi all, probably something really simple that I just can’t understand. But why isn’t the below yaml summing up to 5, but result is zero? Why is this not working???
{% set result = 0 %}
{% set list = [1,2,3,4,5] %}
{% for item in list %}
{% set result = result+ 1 %}
{% endfor %}
{{ result}}
Above jaml is a simplified version of what I actually want to accomplish, because this is what I need;
- I want to sum the
up_kilobytes_per_s
attribute for alldevice_trackers
within the integrationtplink_deco
, that are connected to a specific AP (deco_device
), so I know the total kilobytes_per_s for that specific AP
{% set result = 0 %}
{% set array = integration_entities('tplink_deco') | list %} {# this will create a list of device_trackers within the custom integration 'tplink_deco'#}
{% for a in array if state_attr(a, 'icon') == 'mdi:lan-connect' and state_attr(a, 'deco_device') == 'Mid'%}
{% set result = result+ state_attr(a, 'up_kilobytes_per_s') %}
{% endfor %}
{{ result}}