Cheapest Energy Hours - Jinja macro for dynamic energy prices

so if i push button at 00:15 it will take time btw 00:15 - 06:00 right?

Well, kinda, if you push the button at 00:15 it will take the times from then until 6:00 the next day, so that’s 23:45 hours on that day, and 6 hours of the next day. As the prices for the next day are not known at 00:15 it will use what it has, which is 00:15 - 06:00.

You probably want something like this (you didn’t provide the attributes with the prices for tomorrow, I assumed it’s prices_tomorrow):

{% from ‘cheapest_energy_hours.jinja’ import cheapest_energy_hours %}
{% set end = today_at('06:00') %}
{% set end = end + timedelta(days=1) if now() > end else end %}
{{ cheapest_energy_hours('sensor.energi_data_service_incl_vat_tarif', attr_today='prices_today'', attr_tomorrow='prices_tomorrow', hours=4, start=now(), end=end) }}

Hi there,

My goal is to create an average cheapest energy hours of 3 hours.

While reading the docs I can’t find out how and where to implement the tibber source sensor. Should it be in configuration.yaml or as my other sensors in the sensor directory? I have succesfully installed cheapest energy hours through hacs.

If you have them in a sensor folder, it sounds like you’re still using the legacy format.
This Tibber sensor uses the modern template sensor format. You can paste it directly in your configuration.yaml if you don’t use the template: integration in there already