How to get combined value

Hi,

I need some help, I’m trying to get a sum, out of this:

{% for state in state_attr('sensor.ct_white', 'Data') |selectattr('Location', 'eq','Wine_fridge')  %}  {{state.Quantity}}  {% endfor %}

Result:

  2    2    1    1    1    1 

How do I get it to add the numbers, so the result will be “8” ?

Hi @Michael_Dahl

Maybe something like this:

{% set ns = namespace(total=0) %}
{% for state in state_attr('sensor.ct_white', 'Data') |selectattr('Location', 'eq','Wine_fridge')  %}
{% set ns.total = ns.total + state.Quantity %}
{% endfor %}
{{ ns.total }}

Thanks, That did the trick :slight_smile: