Variable energy prices EasyEnergy (NL)

Can somebody help me implement the following, which is a (Dutch) post on tweakers.net concerning variable energy prices from EasyEnergy? (I’m quite the beginner in Home Assistant, and can’t figure out what I am doing wrong).

It is the following post on tweakers I’m trying to implement: het grote day ahead energie prijzen topic. - Wonen - GoT

My configuration.yaml now looks as follows:

# Loads default set of integrations. Do not remove.
default_config:

- platform: template
  sensors: 
      prijsopslag_energie:
          friendly_name: "Prijsopslag Energie"
          value_template: "{{(0.968+4.452+3.691+0.064)/100}}"

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
rest: !include rest.yaml
sensor: !include sensors.yaml

I’ve created the file rest.yaml with this code.

In sensors.yaml I have added this code.

In my dashboard I have added this lovelace code.

In my logs I can see the following errors:

TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{[ states('sensor.energieprijs_uur_0')|float, states('sensor.energieprijs_uur_1')|float, states('sensor.energieprijs_uur_2')|float, states('sensor.energieprijs_uur_3')|float, states('sensor.energieprijs_uur_4')|float, states('sensor.energieprijs_uur_5')|float, states('sensor.energieprijs_uur_6')|float, states('sensor.energieprijs_uur_7')|float, states('sensor.energieprijs_uur_8')|float, states('sensor.energieprijs_uur_9')|float, states('sensor.energieprijs_uur_10')|float, states('sensor.energieprijs_uur_11')|float, states('sensor.energieprijs_uur_12')|float, states('sensor.energieprijs_uur_13')|float, states('sensor.energieprijs_uur_14')|float, states('sensor.energieprijs_uur_15')|float, states('sensor.energieprijs_uur_16')|float, states('sensor.energieprijs_uur_17')|float, states('sensor.energieprijs_uur_18')|float, states('sensor.energieprijs_uur_19')|float, states('sensor.energieprijs_uur_20')|float, states('sensor.energieprijs_uur_21')|float, states('sensor.energieprijs_uur_22')|float, states('sensor.energieprijs_uur_23')|float, ]|average}}' but no default was specified') while processing template 'Template("{{[ states('sensor.energieprijs_uur_0')|float, states('sensor.energieprijs_uur_1')|float, states('sensor.energieprijs_uur_2')|float, states('sensor.energieprijs_uur_3')|float, states('sensor.energieprijs_uur_4')|float, states('sensor.energieprijs_uur_5')|float, states('sensor.energieprijs_uur_6')|float, states('sensor.energieprijs_uur_7')|float, states('sensor.energieprijs_uur_8')|float, states('sensor.energieprijs_uur_9')|float, states('sensor.energieprijs_uur_10')|float, states('sensor.energieprijs_uur_11')|float, states('sensor.energieprijs_uur_12')|float, states('sensor.energieprijs_uur_13')|float, states('sensor.energieprijs_uur_14')|float, states('sensor.energieprijs_uur_15')|float, states('sensor.energieprijs_uur_16')|float, states('sensor.energieprijs_uur_17')|float, states('sensor.energieprijs_uur_18')|float, states('sensor.energieprijs_uur_19')|float, states('sensor.energieprijs_uur_20')|float, states('sensor.energieprijs_uur_21')|float, states('sensor.energieprijs_uur_22')|float, states('sensor.energieprijs_uur_23')|float, ]|average}}")' for attribute '_attr_native_value' in entity 'sensor.gemiddelde_energieprijs_vandaag'
22:07:30 – (ERROR) helpers/template_entity.py - message first occurred at 22:07:30 and shows up 2 times
Error while processing template: Template("{{[ states('sensor.energieprijs_uur_0')|float, states('sensor.energieprijs_uur_1')|float, states('sensor.energieprijs_uur_2')|float, states('sensor.energieprijs_uur_3')|float, states('sensor.energieprijs_uur_4')|float, states('sensor.energieprijs_uur_5')|float, states('sensor.energieprijs_uur_6')|float, states('sensor.energieprijs_uur_7')|float, states('sensor.energieprijs_uur_8')|float, states('sensor.energieprijs_uur_9')|float, states('sensor.energieprijs_uur_10')|float, states('sensor.energieprijs_uur_11')|float, states('sensor.energieprijs_uur_12')|float, states('sensor.energieprijs_uur_13')|float, states('sensor.energieprijs_uur_14')|float, states('sensor.energieprijs_uur_15')|float, states('sensor.energieprijs_uur_16')|float, states('sensor.energieprijs_uur_17')|float, states('sensor.energieprijs_uur_18')|float, states('sensor.energieprijs_uur_19')|float, states('sensor.energieprijs_uur_20')|float, states('sensor.energieprijs_uur_21')|float, states('sensor.energieprijs_uur_22')|float, states('sensor.energieprijs_uur_23')|float, ]|average}}")
22:07:30 – (WARNING) config_entries.py - message first occurred at 22:07:21 and shows up 2 times
Error adding entities for domain sensor with platform rest
22:07:22 – (ERROR) Sensor - message first occurred at 22:07:22 and shows up 49 times

And in my dashboard I get the following errors (as the sensors do not exist):

Can someone tell me what I’m doing wrong? And how I can fix it?
Thanks a bunch!

1 Like

Ok, finally figured it out myself. I changed all the instances of

float

to

float(0)

So the code looks like this:

    gemiddelde_energieprijs_vandaag: 
      friendly_name: "Gemiddelde energieprijs vandaag"
      value_template: >
                      {{[
                      states('sensor.energieprijs_uur_0')|float(0),
                      states('sensor.energieprijs_uur_1')|float(0),
                      states('sensor.energieprijs_uur_2')|float(0),
                      states('sensor.energieprijs_uur_3')|float(0),
                      states('sensor.energieprijs_uur_4')|float(0),
                      states('sensor.energieprijs_uur_5')|float(0),
                      states('sensor.energieprijs_uur_6')|float(0),
                      states('sensor.energieprijs_uur_7')|float(0),
                      states('sensor.energieprijs_uur_8')|float(0),
                      states('sensor.energieprijs_uur_9')|float(0),
                      states('sensor.energieprijs_uur_10')|float(0),
                      states('sensor.energieprijs_uur_11')|float(0),
                      states('sensor.energieprijs_uur_12')|float(0),
                      states('sensor.energieprijs_uur_13')|float(0),
                      states('sensor.energieprijs_uur_14')|float(0),
                      states('sensor.energieprijs_uur_15')|float(0),
                      states('sensor.energieprijs_uur_16')|float(0),
                      states('sensor.energieprijs_uur_17')|float(0),
                      states('sensor.energieprijs_uur_18')|float(0),
                      states('sensor.energieprijs_uur_19')|float(0),
                      states('sensor.energieprijs_uur_20')|float(0),
                      states('sensor.energieprijs_uur_21')|float(0),
                      states('sensor.energieprijs_uur_22')|float(0),
                      states('sensor.energieprijs_uur_23')|float(0),
                      ]|average}}
    

Thanks for sharing this. Wouldn’t this custom component give similar data? GitHub - bajansen/home-assistant-frank_energie: Custom Component voor Home Assistant Frank Energie prijsinformatie

Hi, thanks for the link. The custom component should give similar data, but is ofcourse limited to Frank Energy (and not Easy Energy). Would be nice to extend the component so you can choose your energy supplier. I’ve just browsed through the code, but I’m certainly not able to modify it to my suit ;).

1 Like

If you want to be cheap in electricity while having solar panels, don’t use EasyEnergy but UnitedConsumers.
3th year in a row.
And you still get 100% price back for solar production… and not a little compensation, they accept if u want to pay for the used price if the fixed month price is to high.
Also pay now 10€ a month :rofl: so i’m safe for this year, and this contract for 10€ started october 2022.

Frank energie is different, i have also easy energy.
Don’t use frank_energie data, its not correct.

Use from next energy or EasyEnergy.
Remember from 1 december its 0.61ct belasting added for gas.
image

I have these devices created now

sensor:
    
  - platform: rest
    name: easyenergy
#  scan_interval: 43200
    resource_template: >-
      https://mijn.easyenergy.com/nl/api/tariff/getlebatariffs?startTimestamp=
      {% set ts_now = ((as_timestamp(now())/1800)|round(0,'floor')|int * 1800) %}
      {{ (ts_now  ) |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}&endTimestamp=
      {% set ts_tmw = (as_timestamp(now())+86400) %}
      {{ (ts_tmw  ) |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}
    unit_of_measurement: 'euro/m³'
    device_class: monetary
    value_template: "{{ (value_json[-3].TariffUsage) | round(3)  }} "
    json_attributes:
      - "Timestamp"
      #
 
 
  - platform: rest
    name: easyenergyTAX
  # scan_interval: 43200
    resource_template: >-
      https://mijn.easyenergy.com/nl/api/tariff/getlebatariffs?startTimestamp=
      {% set ts_now = ((as_timestamp(now())/1800)|round(0,'floor')|int * 1800) %}
      {{ (ts_now  ) |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}&endTimestamp=
      {% set ts_tmw = (as_timestamp(now())+86400) %}
      {{ (ts_tmw  ) |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}
    unit_of_measurement: 'euro/m³'
    device_class: monetary
    value_template: "{{ (value_json[-3].TariffUsage) | round(2) + 0.61  }} "
    json_attributes:
      - "Timestamp"

Also if u want to manual call the REST entity to be updated in an automation use:

- service: homeassistant.update_entity
  entity_id: sensor.your_rest_sensor

or u use it this way


# https://www.easyenergy.com/nl/energietarieven
StroomTax = 1.962 + 4.010 + 3.325 + 0.104
GssTax = 9.81 + 1.714 + 39.591 + 9.429

FYI, I’m planning for myself to make an integration for EasyEnergy in the coming weeks. For me it is important to know what kind of data should be included in the integration, for example I see that there are prices for usage as well as return, gas/electricity and periods from day to year.

The ones i only use is gas, only need the gas price for the day coming, not the current day. Maybe the current day as an attribute to include @ the energy dashboard.
That’s what i did now, with the above script, and its working good.

Just convert the existing python script to an integration, its already made, but i’m to lazy to do it.
GitHub - malosaa/EasyEnergy here you go.

Would be great to see an integration, but i’m not interested in electricity as EE is expensive.

Thank you for the information.

I’m already well on my way with my own python package that will also be placed on PyPi. As I have it in mind now, you can optionally opt for gas and energy return prices and you will receive the electricity usage prices as standard.

I keep a twitter thread with some sneak peaks:

2 Likes

Did you actually manage to create the add-on ?
Because i actually prefer that instead of a rest sensor.

As right now i still use the rest code what i created, and works also really well.

Regards

I’ll be working on that in the next few days :wink:

1 Like

Hello @malosaa

You mentioned next energy which I will be switching to in few days. I see everyone with easy energy data import but how would you get the next energy one? Are they using the same source? Is there an API for next energy as well that I failed to find?

Thanks!
Meltem

OK, after some blog reading I will answer my own question if anyone else is curious about the same thing. It seems like both Easy Energy and Next Energy are using the same price source so the add-on @klaasnicolaas is creating would also work for Next Energy clients. Someone correct me if I am wrong :slight_smile: At this moment fingers crossed excitedly waiting for the Add-On. Thanks @klaasnicolaas for making this possible.

PS: The pricing difference comes from the BTW incl vs excl.

1 Like

So, its me again. After more research and help of other forums I correct my claim saying Easy Energy has the same price as Next Energy. They might be close but this link has the price per provider where you can see the difference:

https://enever.nl/prijzen-feeds/
I am following the updates here where I started taking the price data from the website above via REST call.
https://gathering.tweakers.net/forum/list_message/73987454#73987454

UPDATE: It works smoothly. I now have:

  1. Todays electricity prices per hour
  2. Tomorrows electricity prices per hour
  3. Today’s gas price (given at 06:00) since it updates only once a day
    It is also possible to get last 30 day data but my subscription only starts in 2 days so I didn’t need that data.

These are the providers you can get the data for:


Looks like this in HA when i got the Next Energy one so it is incl BTW prices.

Now I will start visualization and automation side :slight_smile:

Update : I found this website which works way better for me. I replaced my implementation accordingly. I thought it might help: Home Assistant: Nord Pool Spot prices and how to automate devices for cheapest hours – Creating Smart Home

You might also want to look at entso-e - fully free api which provides epex tariffs. Many more automations and template sensors on this forum for both nordpool and entso-e.

1 Like

I’d like to get something similar to what you have in HA, for EnergyZero through Enever. From the Tweakers forum I got the following yaml configuration for my sensors:

rest:
  - resource: https://enever.nl/feed/gasprijs_vandaag.php
    scan_interval: 21600
    sensor:
      - name: "EZ_gasprijs_enever"
        unique_id: ez_gasprijs_enever
        value_template: "{{ ((value_json.data.0.prijsEZ | float(0)) if value_json is defined else 'unavailable')  }}"
        unit_of_measurement: "EUR/m³"
        json_attributes_path: "$.data.0"
        json_attributes:
          - datum
        device_class: monetary
  - resource: https://enever.nl/feed/stroomprijs_vandaag.php
    scan_interval: 3600
    sensor:
      - name: "EZ_stroomprijs_enever"
        unique_id: ez_stroomprijs_enever
        value_template: "{{ ((value_json.data.0.prijsEZ | float(0)) if value_json is defined else 'unavailable')  }}"
        unit_of_measurement: "EUR/kWh"
        json_attributes_path: "$.data.0"
        json_attributes:
          - datum
        device_class: monetary

which gives me data, but it looks like its only the first entry in the json for the day. For gas this is no issue, but for power which changes every hour it is:

image

Here you see the sensor shows the stroomprijs for 00:00, not for the current hour.

I would like to be able to incorporate the enever api results in HA, to show an apex chart graph for the entire day and to have a sensor entity that has the current price to use in the Energy dashboard. I feel like I’m close, but not quite there yet. :slight_smile:

What am I missing?

It looks like this, so you would need to add a line per hour until you cover 24 hours.

- name: "Electricity price 00:00"
      value_template: "{{ value_json.data[0].prijsNE }}"
      json_attributes_path: "$.data[0]"
      json_attributes:
        - datum
        - prijsNE
      unit_of_measurement: "€/kWh"
    - name: "Electricity price 01:00"
      value_template: "{{ value_json.data[1].prijsNE }}"
      json_attributes_path: "$.data[1]"
      json_attributes:
        - datum
        - prijsNE
      unit_of_measurement: "€/kWh"
    - name: "Electricity price 02:00"
      value_template: "{{ value_json.data[2].prijsNE }}"
      json_attributes_path: "$.data[2]"
      json_attributes:
        - datum
        - prijsNE

Just an update on a possible integration for easyEnergy. I have some code ready, but I still have to work out the sensor entities. Expect it to be ready and tested in a few weeks.

1 Like

Perfect would be great

I think the BTW is higher at Easy energy, and the rest is the same.

How much per 1m³ you pay today inclusive btw for today 11-01-2023 ?

for me its 0.82788 ct + 0.72059 = 1,54847 euro all taxes included for today.

For those who would like to test, you can download the zip below and put the files in the custom_components folder, restart HA and then add the integration in the UI.

easyenergy_v0.1.0.zip (6.5 KB)

3 Likes