Hello!
I have a code for a variable like this:
temp: >
{% set result = {'current': 0, 'target': 0} %}
{% set thermostats_array = expand(thermostats) %}
{% for thermostat in thermostats_array %}
{% set result = {'current': 12, 'target': 34} %}
{% endfor %}
{{ result }}
This is only the stripped testing code focused on the problem, in the real code, some more calculations are done.
The thing is I want to be able to return more than one value accessing them with:
temp.current
temp.target
The problem is that “result” in the for-loop only exists in the for-loop which makes this code return:
temp.current = 0
temp.target = 0
How can I set result.current and result.target inside the for-loop and preserve it to return it at the end?