-
Before I try figuring it out myself, has anyone created a Jinja template to extract the highest price from the forecast values? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Figured it out. Posting in case useful to others {%- set ns = namespace(highval={}) %} Sample data*
|
Beta Was this translation helpful? Give feedback.
Figured it out. Posting in case useful to others
{%- set ns = namespace(highval={}) %}
{%- for intervals in states.sensor.amber_35_general_forecast.attributes["forecasts"] %}
{%- if loop.index0==0 %}
{%- set ns.highval=intervals["per_kwh"] | float %}
{%- endif %}
{%- if intervals['per_kwh'] | float > ns.highval | float %}
{%- set ns.highval=intervals["per_kwh"] | float %}
{%- endif %}
{%- endfor %}
{{ ns.highval }}
Sample data*
forecasts:
nem_date: '2021-08-14T22:30:00+10:00'
per_kwh: 22
spot_per_kwh: 8
start_time: '2021-08-14T12:00:01+00:00'
end_time: '2021-08-14T12:30:00+00:00'
renewables: 21
spike_status: none
range_min: 4.68735
range_max: 31.12405
nem_date: …