Populating helper entities with EPEX Spot data

Hello everyone,

I’ve been a long-time reader here, often searching for solutions and learning a lot. I’m relatively new to the Home Assistant world. I’ve been considering it for a while, but was a bit intimidated by the transition and the time commitment. However, I recently had some free time, and now my Home Assistant Core is running smoothly on a NUC. I’m incredibly happy with the switch!

So, that’s my little introduction in my first post.

Now for my problem. With the help of a YouTube tutorial, I quickly and easily set up a daily push notification for my phone, which tells me daily when the electricity price is lowest in a 3-hour interval the following day.

I now want to apply what I’ve learned to create two helper entities that are populated daily with the two relevant values (time and price). I created the two helpers in the configuration.yaml file. I initially wrote the code manually, but then imported it into the UI (letting it assign the ID). Mainly because I was hoping that my mistake would then become clear to me. But it didn’t. Home Assistant accepts the code as is and executes the automation willingly. Unfortunately, the helpers are not populated.

Here’s the code from my configuration.yaml:

input_datetime:
  waschepreis_uhrzeit_helper:
    name: Wäschepreis Uhrzeit Helper
    has_date: true
    has_time: true
    icon: mdi:clock-alert-outline
  
input_number:
  waschepreis_preis_helper:
    name: Wäschepreis Preis Helper
    min: -50
    max: 100
    unit_of_measurement: 'Ct/kWh'
    icon: mdi:currency-eur`

And the code from my automations.yaml:

- id: '1740088741686'
  alias: Täglichen Wäschepreis ermitteln
  description: ''
  triggers:
  - at: '18:00:00'
    trigger: time
  conditions: []
  actions:
  - data:
      earliest_start: 06:00:00
      earliest_start_post: 1
      latest_end: '18:00:00'
      latest_end_post: 1
      duration:
        hours: 3
        minutes: 0
        seconds: 0
    response_variable: niedrigsterpreis
    action: epex_spot.get_lowest_price_interval
  - data:
      entity_id: input_datetime.waschepreis_uhrzeit_helper
      value: '{{ as_timestamp(niedrigsterpreis.start) }}'
    action: input_datetime.set_datetime
  - data:
      entity_id: input_number.waschepreis_preis_helper
      value: '{{ niedrigsterpreis.price_per_kwh | round(3) * 100 }}'
    action: input_number.set_value
  mode: single

For those who are not familiar with the EPEX Spot integration, here is the code that the action outputs when you run it in Home Assistant:

start: "2025-02-22T11:00:00+01:00"
end: "2025-02-22T14:00:00+01:00"
price_per_kwh: 0.04674
net_price_per_kwh: 0.199256

Is it generally not possible at all what I’m trying to do? Do I need a different entity? Do I need to create a sensor? Or is there simply an error in the code that I can’t see?

Thank you in advance for taking the time to look at this.

Best regards, rulekicker

Best would be to use a Template integration that runs at midnight.
Then you don’t need extra automations, can output a sensor, etc.

Have I look on what I’m using, to inspire you:

template:
  - trigger:
      - trigger: time
        at: "00:00:00"
      - trigger: state
        entity_id: input_number.heating_lenght
    action:
      - action: epex_spot.get_lowest_price_interval
        data:
          duration:
            hours: "{{ states('input_number.heating_lenght')|int }}"
        response_variable: resp
    sensor:
      - name: Start Heatpump
        device_class: timestamp
        state: "{{ resp.start is defined and resp.start }}"

What I’m doing here:

  • I have a input number to allow me to change the amount of hours I want my heating to work.
  • Everytime I change this, or at midnight this template runs
  • When this template runs, it creates a sensor with a timestamp with the cheapest time to start my heating, taking in consideration how many hours I want it to run.
  • This sensor is used on automations

Hope this helps.