-
-
Notifications
You must be signed in to change notification settings - Fork 29
Nordpool
Jonas Karlsson edited this page Jul 4, 2024
·
2 revisions
The Nordpool integration is nativly supported by this integration, so there is no need to use a template sensor. However, the following template sensor can be used to create the price input for an integration with the same output format as Nordpool.
template:
- sensor:
- name: "Nordpool template price sensor"
unique_id: nordpool_template_price_sensor
unit_of_measurement: "öre/kWh"
state: "{{ states('sensor.nordpool_kwh_se3_sek_2_095_0') }}"
availability: "{{ 'sensor.nordpool_kwh_se3_sek_2_095_0' | has_value }}"
attributes:
prices_today: >
{%- set forecast_data = state_attr('sensor.nordpool_kwh_se3_sek_2_095_0', 'raw_today') %}
{%- set time_key = 'start' %}
{%- set price_key = 'value' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast_data | default([], true) if i[time_key].date() == now().date() %}
{%- set ns.data = ns.data + [dict(time = i[time_key].strftime('%Y-%m-%d %H:%M:%S%z'), price = i[price_key])] %}
{%- endfor %}
{{ ns.data }}
prices_tomorrow: >
{%- set forecast_data = state_attr('sensor.nordpool_kwh_se3_sek_2_095_0', 'raw_tomorrow') %}
{%- set time_key = 'start' %}
{%- set price_key = 'value' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast_data | default([], true) if i[time_key].date() == (now()+timedelta(days=1)).date() %}
{%- set ns.data = ns.data + [dict(time = i[time_key].strftime('%Y-%m-%d %H:%M:%S%z'), price = i[price_key])] %}
{%- endfor %}
{{ ns.data }}