Skip to content

Instantly share code, notes, and snippets.

@trexx
Last active January 16, 2024 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trexx/5759e7af0d60fb90c37517f8dbccb92e to your computer and use it in GitHub Desktop.
Save trexx/5759e7af0d60fb90c37517f8dbccb92e to your computer and use it in GitHub Desktop.
Additional costs calculation for Aura + Dinel.
# A Jinja2 template for the Nordpool Home Assistant integration to include additional costs for Aura.
# This includes hourly and seasonal tariff for electricity transportation (Dinel) and its taxes, state taxes, and a fixed cost.
{% set s = {
"summertarif_start_month": 4,
"summertarif_end_month": 9,
"summertarif_low_price": 0.0882,
"summertarif_high_price": 0.1323,
"summertarif_max_price": 0.3439,
"wintertarif_start_month": 10,
"wintertarif_end_month": 3,
"wintertarif_low_price": 0.0882,
"wintertarif_high_price": 0.2645,
"wintertarif_max_price": 0.7936,
"low_price_start_hour": 0,
"low_price_end_hour": 6,
"high_price_1_start_hour": 6,
"high_price_1_end_hour": 17,
"max_price_start_hour": 17,
"max_price_end_hour": 21,
"high_price_2_start_hour": 21,
"transportation_tax": 0.25,
"state_tax": 111,
"flex_el_fixed_cost": 0.10
}
%}
{% if now().month >= s.summertarif_start_month and now().month <= s.summertarif_end_month %}
{% if now().hour >= s.low_price_start_hour and now().hour < s.low_price_end_hour %}
{{ (s.summertarif_low_price * s.transportation_tax) + s.summertarif_low_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.high_price_1_start_hour and now().hour < s.high_price_1_end_hour %}
{{ (s.summertarif_high_price * s.transportation_tax) + s.summertarif_high_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.max_price_start_hour and now().hour < s.max_price_end_hour %}
{{ (s.summertarif_max_price * s.transportation_tax) + s.summertarif_max_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.high_price_2_start_hour %}
{{ (s.summertarif_high_price * s.transportation_tax) + s.summertarif_high_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% endif %}
{% elif now().month >= s.wintertarif_start_month or now().month <= s.wintertarif_end_month %}
{% if now().hour >= s.low_price_start_hour and now().hour < s.low_price_end_hour %}
{{ (s.wintertarif_low_price * s.transportation_tax) + s.wintertarif_low_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.high_price_1_start_hour and now().hour < s.high_price_1_end_hour %}
{{ (s.wintertarif_high_price * s.transportation_tax) + s.wintertarif_high_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.max_price_start_hour and now().hour < s.max_price_end_hour %}
{{ (s.wintertarif_max_price * s.transportation_tax) + s.wintertarif_max_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% elif now().hour >= s.high_price_2_start_hour %}
{{ (s.wintertarif_high_price * s.transportation_tax) + s.wintertarif_high_price + s.flex_el_fixed_cost + s.state_tax / 100 | float }}
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment