Open TheFes opened 2 days ago
@TheFes was helping me with the template to use the Zonneplan
component as source (Zonneplan is one of the Netherlands energy providers with dynamic/hourly tariffs)
This is the working result template, might be nice to add to the Wiki:
template:
- sensor:
- name: "Zonneplan template price sensor"
unique_id: zonneplan_template_price_sensor
unit_of_measurement: "€/kWh"
availability: "{{ 'sensor.zonneplan_current_electricity_tariff' | has_value }}"
state: "{{ states('sensor.zonneplan_current_electricity_tariff') }}"
attributes:
prices_today: >
{%- set forecast = state_attr('sensor.zonneplan_current_electricity_tariff', 'forecast') %}
{%- set time_key = 'datetime' %}
{%- set price_key = 'electricity_price' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast | 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] / 10000000 )] %}
{%- endfor %}
{{ ns.data }}
prices_tomorrow: >
{%- set forecast = state_attr('sensor.zonneplan_current_electricity_tariff', 'forecast') %}
{%- set time_key = 'datetime' %}
{%- set price_key = 'electricity_price' %}
{%- set ns = namespace(data=[]) %}
{%- for i in forecast | 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] / 10000000 )] %}
{%- endfor %}
{{ ns.data }}
Added unit_of_measurement
, unique_id
and availability
to the YAML
The unique_id
is an UUID which I generated here https://www.uuidgenerator.net/
Also updated the name to be more read friendly, this will be slugified to epex_spot_transformed
for the entity_id
@TheFes, thanks for the alternative version. I have used it to update the EPEX Spot Wiki page. Except for the UUID, which is good for automatically generated IDs, but maybe not as good for manually created IDs.
@hmmbob, I also added the Zonneplan variant to the Wiki page.
Also, when adding unique_id
to the template, the properties of the entity changed in such a way that I needed to update the code a bit. So now there is a v1.11.0-dev2 release available.
I couldn't find an edit button for the Wiki lemma, but I wanted to propose an alternative template sensor for the creation of the template sensor:
The variables set in the first 3 lines of the attribute make it more easy for the users to adjust the template for their own source sensor. I also found it a bit redundant to create the lists for both today and tomorrow in each attribute.
Not a user of the integration myself, but I was asked to help with creating a template sensor to be used with this integration, and thought it might be good to share :)