Zonneplan - Dynamic Energy pricing and three lowest hours

Great, i am go to have a look at this one and let know. BTW, cheap hours is relative to the day, so there always will be a relative cheap one. Let me see how this works. tx a lot!

Thanks for the template, looking interesting. What I cannot find is how to add this sensor to Home Assistant. I’m trying to add a Template Sensor but then I get the error:

Any suggestion how to fix this?

Put this line in your configuration.yaml.

template: !include template.yaml

Then make a new file named template.yaml and past the template in there.

Restart HA and the it should work.

1 Like

Thanks @micronikje for your support on this topic. I found some time to check and plat the template. And in general this works good, when the 3 cheapest hours are sequential to each other. I’ve seen response from this template sensor where the three cheapest hours are not sequential. So ideally the formula needs to be updated to go through the forecast list, calculates the average price of the 3 sequential hours and then provide the start date/time (of the 3 hour slot) of the cheapest average price. My programming knowledge on Home Assistant is very limited, so I cannot update the template unfortunately, are you able to help me out and update the template?

I would try to re-use the programming done by TheFes. Install the ‘cheapest energy hours’ macro, as described here: GitHub - TheFes/cheapest-energy-hours: Jinja macro to find the cheapest energy prices

Then you can create a sensor to find the start of the cheapest set of 3 hours (assuming equally distributed load within those 3 hours, which is often not the case in the use case you described, so you can also be much more specific) with this template:

- sensor:
      - name: "Goedkoopste uren om een apparaat aan te zetten"
        unique_id: "goedkoopste_uren"
        device_class: timestamp
        state: >
          {%- set zonneplan = 'sensor.zonneplan_current_electricity_tariff' -%}
          {%- from 'cheapest_energy_hours.jinja' import cheapest_energy_hours -%}
          {{ cheapest_energy_hours(sensor='zonneplan', hours=3) }}

If you do what @willembuys suggests it will work too.
@willembuys thanks for your support.

1 Like

I added this template to template.yaml and added the yaml file to the config. I need the data for automating charging my car. I get values when pasted in the template editor, but can’t seem to get the values from automation.

Maybe not the answer you are looking for, but for EV charging based on price, I like GitHub - jonasbkarlsson/ev_smart_charging: Electric vehicle smart charging for Home Assistant. a lot.