Skip to content

Commit

Permalink
Fix for extreme_now when current price is not included (#141)
Browse files Browse the repository at this point in the history
Fixes #140
  • Loading branch information
TheFes authored Jun 11, 2024
1 parent 4221a12 commit 9ba0df5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cheapest_energy_hours.jinja
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- set _version = 'v5.5.0'-%}
{%- set _version = 'v5.5.1'-%}

{#- sub-macro to format datetimes to selected time_format -#}
{%- macro _format_date(datetime, time_format) -%}
Expand Down Expand Up @@ -712,8 +712,8 @@
if lowest
else values | map(attribute=value_key) | max - pt
-%}
{%- set current_price = data | sort(attribute=time_key, reverse=true) | selectattr(time_key, '<=', now()) | map(attribute=value_key) | list | first -%}
{%- set output.extreme_now = current_price <= compare_price if lowest else current_price >= compare_price -%}
{%- set current_price = data | sort(attribute=time_key, reverse=true) | selectattr(time_key, '<=', now()) | map(attribute=value_key) | list | first | default(none) -%}
{%- set output.extreme_now = current_price is not none and current_price <= compare_price if lowest else current_price >= compare_price -%}
{#- output date based on the selected mode -#}
{%- if mode == 'all' -%}
{%- set macro_output = dict(
Expand Down

0 comments on commit 9ba0df5

Please sign in to comment.