EPEX Spot and Awattar Electricity Prices

Hi.
Nachdem man EPEX installiert hat, hat man die entsprechenden Senoren in Home Assistant.
Diese Intergration kann man entsprechend konfigurieren, je nach dem, was der Provider vorgibt. In meinem Fall gibt es einen Aufschlag von 1,2ct auf den Spot Preis sowie 20% USt.

Daher sieht meine Konfiguration aus wie folgt:
grafik

Ich nehme an, mit den Tabellen meinst Du das hier:
grafik

Ich habe etwas Zeit und Mühe investiert, alles unter 10 ist grünlich, zwischen 10 und 20 geht’s über gelb in orange, und ab 20ct/KWh geht’s in den roten, dann tiefroten Bereich.

Dazu muss man sich die apexcharts card über HACS installieren. Die Konfiguration sieht dann z.B. so aus:

type: custom:apexcharts-card
graph_span: 24h
experimental:
  color_threshold: true
header:
  title: Energy price today
  show: true
  show_states: true
span:
  start: day
now:
  show: true
  label: now
  color: darkblue
series:
  - entity: sensor.epex_spot_at_net_price
    type: column
    extend_to: end
    unit: ct/kWh
    float_precision: 3
    yaxis_id: preis
    show:
      in_header: before_now
      extremas: true
      header_color_threshold: true
    color_threshold:
      - value: 2
        color: 00ed01
      - value: 4
        color: 3af901
      - value: 6
        color: 87fa00
      - value: 8
        color: cefb02
      - value: 10
        color: eeff00
      - value: 12
        color: ffde1a
      - value: 14
        color: ffa700
      - value: 16
        color: ff8d00
      - value: 18
        color: ff7400
      - value: 20
        color: ff4d00
      - value: 22
        color: ff4d00
      - value: 24
        color: ff0000
      - value: 26
        color: e60000
      - value: 28
        color: cc0000
      - value: 30
        color: b30000
      - value: 32
        color: '990000'
      - value: 34
        color: '800000'
      - value: 36
        color: '660000'
      - value: 38
        color: 4d0000
      - value: 40
        color: '330000'
    data_generator: |
      return entity.attributes.data.map((entry) => {
        return [new Date(entry.start_time), entry.price_ct_per_kwh];
      });
    group_by:
      func: avg
      duration: 1h
yaxis:
  - id: preis
    decimals: 0
    apex_config:
      title:
        text: ct/kWh
      tickAmount: 5
apex_config:
  legend:
    show: false
  tooltip:
    x:
      show: true
      format: HH:00 - HH:59

Außerdem habe ich mir einen Helper definiert, der mir von 14 bis 23 Uhr die Werte des nächsten Tages (dann allerdings in grau zum Unterscheiden) anzeigt. Ab 24 Uhr sind dann das die aktuellen Werte - die Werte für den nächsten Tag sind noch nicht da und daher wird die Karte erst wieder um 14 Uhr (mit den dann neuen und verfügbaren Werten) angezeigt.

5 Likes

This is amazing :slight_smile:
I am starting looking into spot prices / awattar two days ago, as I have a battery in my basement and less to no solar production. Charging the battery with cheaper energy during night and using it during the day would be great.

I have the integration for epex running and get information. The charts are something I will look into a little later, but I have two questions:

  1. Is it possible to create the template sensor for the lowest/highest prices also via GUI?
  2. Has anyone thought about creating a blueprint to charge a device based on conditions like lowest price etc. so the automation gets simpler for people and therefor switching to such a model?

I am trying to get the sensor up and running via configuration.yml
I copied the example from github and get the sensor but its state is always “unknown”

template:
  - trigger:
      - platform: time
        at: "08:20:00"
    action:
      - service: epex_spot.get_lowest_price_interval
        data:
          duration:
            hours: 3
            minutes: 0
            seconds: 0
          response_variable: resp
    sensor:
      - name: Start Appliance
        device_class: timestamp
        state: "{{ resp.start is defined and resp.start }}"
      - name: Stop Appliance
        device_class: timestamp
        state: "{{ resp.stop is defined and resp.stop }}"

image

If I call the service via Developer Tools, I do get information.

Thanks

1 Like

Hi can you please share this helper?

Did you therefore change the "graph_span to 48h?
and is there a need for edit the custom card to get the grey colors?

Would be very nice!

ALSO is there a way to display the time when its the cheapest? If yes can someone provied code for that please!?

Thanks!

Hi.
First I need the sensor to get the 2 hours cheap window. Here I created this to get the infromation each day at 14:30 (when the data is available for the next day:

template:
  - trigger:
      - platform: time
        at: "14:30:00"
    action:
      - service: epex_spot.get_lowest_price_interval
        data:
          earliest_start: "23:59:00"
          duration:
            hours: 2
        response_variable: resp
    sensor:
      - name: Zwei Stunden Fenster Strom
        device_class: timestamp
        state: "{{ resp.start is defined and resp.start }}"

Based on that I have created a small automation for the helper, called input_datetime.start_gunstigste_2_stunden_zeitfenster - in addtion I get a notification on my mobile with the information each day at 6 and set the helper. Afterwards I can use the helper for any other automation as a trigger:

alias: "Power: Set time for cheapest hour"
description: ""
trigger:
  - platform: time
    at: "18:00:00"
condition:
  - condition: not
    conditions:
      - condition: state
        entity_id: sensor.zwei_stunden_fenster_strom
        state: unavailable
action:
  - service: input_datetime.set_datetime
    data:
      time: >-
        {{ as_timestamp(states('sensor.zwei_stunden_fenster_strom')) |
        timestamp_custom('%H:%M') }}
    target:
      entity_id: input_datetime.start_gunstigste_2_stunden_zeitfenster
  - data:
      title: Strom Update!
      message: >-
        2-Stunden-Zeitfenster für morgen:  <b><span style="color: red"> {{
        as_timestamp(states('sensor.zwei_stunden_fenster_strom')) |    
        timestamp_custom('%H:%M') }} Uhr </span></b>  bis <b><span style="color:
        red"> {{ (states('sensor.zwei_stunden_fenster_strom')|as_timestamp +
        (120*60))|timestamp_custom("%H:%M", True) }} Uhr</span></b>!
      data:
        icon_url: >-
          https://icons.iconarchive.com/icons/icons8/windows-8/256/Weather-Storm-icon.png
    service: notify.mobile_app_pixel_7_pro

Regarding the graph span: I have two cards with 24h - the current day and the next day (after 2, when the data is available until 23 - as a preview).

The code to show the card from 14:00 to 23:00 look like this:

- platform: template
  sensors:
    display_card:
      friendly_name: Display card between 14 and midnight.
      entity_id: sensor.time
      value_template: >
         {% set ct = now().hour + now().minute/60 + now().second/3600 %}
         {{ 14 <= ct <= 23 }}

With the sensor and the helper you can trigger or show whatever you want. You just need to be careful when the data is available and if you are on the current or next day.

P.S. there might be better ways now, but I added some additional topics step by step

2 Likes

Hi thanks for that quick reply.

i can find this service in the devtools and it gives me the values correctly, but when i copy your code to a helper - template it always gives me unavaliable. why?

I have mine in a yaml file - e.g. configuration.yaml

Maybe it is the wrong place here.

you re right!
image

looks better now. no error so lets wait a few hours and see if i get the data

thank you for now

can you please show more in detail how you added the second card?
Seperate apex card or how you acchieve that.
Can you post screenshot too please?

other things are working fine now. thank you for that!!

Hi.

The second card uses the “display card” sensor, which I mentioned earlier as a conditional card:

type: conditional
conditions:
  - entity: sensor.display_card
    state: 'True'
card:
  type: custom:apexcharts-card
  graph_span: 24h
  header:
    title: Energy price tomorrow
    show: true
    show_states: false
  span:
    start: day
    offset: +1day
  series:
    - entity: sensor.epex_spot_at_net_price
      type: column
      extend_to: end
      unit: ct/kWh
      float_precision: 3
      yaxis_id: preis
      group_by:
        func: avg
        duration: 1h
      color: grey
      show:
        in_header: before_now
        extremas: true
      data_generator: |
        return entity.attributes.data.map((entry) => {
          return [new Date(entry.start_time), entry.price_ct_per_kwh];
        });
  yaxis:
    - id: preis
      decimals: 0
      apex_config:
        title:
          text: ct/kWh
        tickAmount: 5
  apex_config:
    legend:
      show: false
    tooltip:
      x:
        show: true
        format: HH:00 - HH:59

As I mentioned a few weeks back, the card for the next day is grey to not confuse me - the current one looks colourful.

Current view see here:

4 Likes

Perfect! THANK YOU SO MUCH! Works flawless!

You’re welcome.

hi again, for some reason the logic to display the card only from 14-23 doesnt work for me. when i click on test the condition it always says: condition not true. it says that always. i tried several differnt things but nothing workd. what could it be?

Check the condition.

It should look like that. Otherwise check the code above.

Hello, maybe someone knows. In the energy configuration I have a Shelly 3em and the epex spot net price from awattar for the price.
Unfortunately the calculation doesn’t work. This is far too high. If I only set the price per megawatt hour, then it calculates in cents, but the network costs and VAT are not included
Does anyone have a solution for this?
Thanks

@styleboy08 Sorry, I don’t understand your question. What do you mean with “if I only set the price per megawatt hour”?

Hello everyone. First of all, thank you for the great integration.
If the time zone is UTC 00:00, then I always have an offset. So if I have the cheapest hours calculated, aren’t they correct?!? Or am I wrong?

The timestamps are correct, they are just displayed in UTC time (which has an offset to CET/CEST of 1/2h) in the developers view. Automations and sensors automatically take care of this and convert it to local time if necessary.

hy,
i’ve added the two apex charts from webwude (costs today and costs tomorrow).
I see the two cards, but when i click on “exit/fertig” i only see the price today card.
Does anybody know why?
Thank you
christian

Maybe the data for tomorrow is not available yet? Usually it is available from 2pm.

Hi there, I’m experimenting with a new feature:

Please let me know if this is a useful addition to EPEX Spot?

5 Likes