I need from this list 2 series:
serie1: index 0 -1-2 (basically tha last 3 based on time )
serie2: 9-8-7 ( the first 3 time based on this list)
Scope: average for each serie and after that math compare ( is great is low ,)
By the way, i’m able to retrieve 1 single value:
{{state_attr(‘sensor.atmopressure’,‘hourly_pressure’)[2] .pressure }}
I get the right value for presuure on index 3
I tried several options without any chance to retrieve multi values.
Dont “kill me”
Copy-paste the following into the Template Editor and experiment with it.
{% set x = state_attr('sensor.atmopressure', 'hourly_pressure')
| map(attribute='pressure')
| map('float', 0) | list -%}
First three values (index 0 to 2).
{{ x[:3] }}
Average of first three values.
{% set y = x[:3] | average -%}
y is {{ y }}
Last three values (index 7 to 9).
{{ x[-3:] }}
Average of last three values.
{% set z = x[-3:] | average -%}
z is {{ z }}
Variable y is {{ 'same as' if y == z else 'greater than' if y > z else 'less than' }} variable z.
If you want pressure values based on oldest/newest times then you’ll need to sort them by time (see Didgeridrew’s example).