#Tibber best prices - Smart plug loading

1 messages · Page 1 of 1 (latest)

wild tree
#

Hi everyone, I’m looking for some help. I’m using Tibber, Bosch Smart Plugs and an EcoFlow battery. My goal is:

Home Assistant should check Tibber’s daily price curve every day at 00:05.
From that data, I want to identify the two price peaks of the day, with the condition that they must be at least 3 hours apart.

Example:
Peak 1 at 14:00 with 35 ct/kWh
Peak 2 at 20:00 with 31 ct/kWh
(Important: “Peak 1” just means the first peak in the day, not necessarily the highest one.)

After identifying the two peaks, HA should determine:

the cheapest price between 00:05 and Peak 1, and

the cheapest price between Peak 1 and Peak 2.

When these cheapest time slots occur, HA should switch on a Bosch plug to charge the EcoFlow battery.
When charging is finished (EcoFlow draws less than 20 W for 5 minutes), HA should switch off the charging plug and turn on a second plug that feeds power back into the house.

I only want to work with two peaks per day, nothing more.

I already installed the HACS Tibber integration and created a sensor that includes all 15-minute prices for the day. But after two days of trying to build the automations with ChatGPT, I basically lost my mind. For some reason, my “peak 1” and “peak 2” sensors remained empty and never got any values.

I’d appreciate any guidance or working examples on how to solve this properly.

and importan²: Both plugs are not allowed to be "on" at the same time. So when plug 1 (load the battery) starts, the other one has to be turned off automaticly.

civic minnow
#

What's a peak? Is that when the price is above average? Especially since you say it's not necessarily the highest price

wild tree
#

At 8 and 17 we have the peaks. What I meant is: Peak 1 doesn’t have to be the highest peak — it’s simply the first peak of the day.

So the script should identify the two peaks of the day, and whichever one occurs first in time is “Peak 1”, even if it’s not the highest. The later one is “Peak 2”.

Why this matters:
Normally you might sort the peaks by height and call the highest one Peak 1 and the second-highest Peak 2. But in my case, the timing is more important. In the next step of the automation I need to:

Look for the cheapest price between midnight and Peak 1

Then look for the cheapest price between Peak 1 and Peak 2

If “Peak 1” were assigned based on price (instead of time), it might end up being after Peak 2 — and then the logic breaks.

All I want is to make sure the battery charges before a peak happens, so the script must treat the chronologically first peak as Peak 1.

#

@civic minnow

civic minnow
#

Well, what I would do is determine the highest price of the day. That can either be peak 1 or peak 2.
Then, using a for loop, examine the prices before and after that peak.
As soon as the prices begin to increase again, use that as starting point to determine the 2nd peak

#

This using Jinja templates

wild tree
#

No, it’s actually much simpler than that.

I already have all the data — every price of the day is available in a Home Assistant sensor.

Just take that list and identify the two highest prices of the day.
Then check the timestamps of these two prices.

After that, scan for the lowest price between midnight and the first high price.

Then scan for the lowest price between the first high price and the second one.

These two timestamps are the times when my battery should start charging.

civic minnow
#

The two highest prices most probably are two prices which follow next to each other, with only 15 minutes time difference

#

After that, scan for the lowest price between midnight and the first high price.
Which midnight? The one before or the one after? Your first highest price could be at 7:00 or at 23:00
Technically there could also be only one peak

wild tree
#

Check the highest price of the day.
Scan plus and minus 3 hours of that Peak for another high price. These two Data are my peaks of the day.

#

And yes, the highest price could be at 23:00

But the second highest price could be at 13:00

So Peak 1 is at 13:00, and Peak 2 is at 23:00

That's why it is important to Name Peak 1 not as the highest price, but the earliest Peak at the day.

civic minnow
#

Still, I don't think that will give you what you want in all cases.
If you follow your logic you would get your peaks at 20:00 and 23:00, while the actual peaks are at 8:00 and 23:00 in this example

wild tree
#

Got it. But this i normally Not the Case. 90% of the time, it will work. And the 10% your example Hits, its okay

#

But tbh. im charging my battery at the lowest price right now. Once per day... And this is fine. My.idea was to Charge it two times per day, to make it more efficient. But If this is really so complex, im Happy to Charge it once per day and this already works

civic minnow
#

I have a macro where you could just charge it on all cheapest hours