EPEX Spot price template sensor - jonasbkarlsson/ev_smart_charging GitHub Wiki
To use the EPEX Spot integration, the following template sensor can be used to create the price input.
template:
- sensor:
- name: "Epex Spot template price sensor"
unique_id: epex_spot_template_price_sensor
unit_of_measurement: "€/kWh"
state: "{{ states('sensor.epex_spot_data_net_price') }}"
availability: "{{ 'sensor.epex_spot_data_net_price' | has_value }}"
attributes:
prices_today: >
{%- set forecast_data = state_attr('sensor.epex_spot_data_net_price', 'data') %}
{%- set time_key = 'start_time' %}
{%- set price_key = 'price_ct_per_kwh' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast_data | default([], true) if as_local(as_datetime(i[time_key])).date() == now().date() %}
{%- set ns.data = ns.data + [dict(time = as_local(as_datetime(i[time_key])).isoformat(), price = i[price_key])] %}
{%- endfor %}
{{ ns.data }}
prices_tomorrow: >
{%- set forecast_data = state_attr('sensor.epex_spot_data_net_price', 'data') %}
{%- set time_key = 'start_time' %}
{%- set price_key = 'price_ct_per_kwh' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast_data | default([], true) if as_local(as_datetime(i[time_key])).date() == (now()+timedelta(days=1)).date() %}
{%- set ns.data = ns.data + [dict(time = as_local(as_datetime(i[time_key])).isoformat(), price = i[price_key])] %}
{%- endfor %}
{{ ns.data }}