From 9ba0df525d27018f2bd2268b29286d5252e12af8 Mon Sep 17 00:00:00 2001 From: Martijn van der Pol Date: Tue, 11 Jun 2024 16:41:16 +0200 Subject: [PATCH] Fix for extreme_now when current price is not included (#141) Fixes #140 --- cheapest_energy_hours.jinja | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cheapest_energy_hours.jinja b/cheapest_energy_hours.jinja index 404324c..ffce2fb 100644 --- a/cheapest_energy_hours.jinja +++ b/cheapest_energy_hours.jinja @@ -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) -%} @@ -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(