The original Tibber API have this “Price Level” comparing the current value with the average value in the past 3 days. I like that, but for some devices I’d like the same levels, but compared only with the current day, so you will find the 2 sensors with “(1-day)” or “(3-days)” in the name.
The “Combined” will result the worse case between those 2 sensors. Let’s say the price now is “VERY_CHEAP” in the 3-days sensor, but it’s “NORMAL” in the 1-day (this will happen in a day where electricity is cheaper than the previous 2 days). The result of the combined sensor will be “NORMAL”, as this is the worse case between those two.
In the same way, it can be that today is way more expensive than the previous days, so it can happy that at certain time, the 1-day sensor will result in “CHEAP”, but when comparing to the 3-days, that would be “EXPENSIVE”, to the combine will return “EXPENSIVE” (the worse between the 2 other sensors). It will be rarer to have “VERY_CHEAP” in the combined sensor.
I have some devices where I don’t have to turn on every day… let’s say, I have a bench with lots of battery chargers where my electric screwdriver, a AAA-battery charger, my camera’s charger, etc. are all connected to a switch. I wanna those devices to be charging only when the price is really cheap, so I use the combined sensor to find when it was “VERY_CHEAP” on both the 1-day and the 3-day sensors.
Yes, I believe to have numbers as results you should have something like this (it’s ugly, maybe we should hve the values into a variable and then convert to int later):
Note that I’ve converted “unknown” to “-1”, just because I don’t know how the “unknown” will affect your plot.
Try it and let me know. I can play a bit with this later.
My next steps will be to adapt the code to my CTC heater, which only takes 4 levels as input. Also, I want to add variables so it’s easier to adjust each levels threshold. Something like this in dashboard:
Create a new automation in the UI. In the top right corner, click the overflow menu and select “Edit in YAML”. Now paste the example code I provided, replacing existing trigger: and action:. You should then be able to switch back to UI mode.
Thanks for the reply! You reminded me to update here at the community as well
I optimized my code a bit and will not be using “Tibber level 3 days”.
Please have a look here:
The thresholds are similar to what Tibber are using, here from Tibber Developer Reference docs.
I am not sure how these thresholds will adapt to my 4 level needs…
So instead, I made my thresholds variables that I can change when/if I need to tune the settings of the thresholds. I hope it made it a bit more clear to you
Please also have a look at my updated and commented code here: CTC i350 (heat pump) smartcontrol using Tibber electricity prices by the hour
Hi,
I just started completely new into HA and have no clue so far. I’m trying to get an overview on how this whole thing works in general ^^
I am thinking about the same idea - charging my battery with grid power when the price is low and tanking it out again when it’s bigherly priced.
If you have a solution I’d be very glad to participate.
Sadly at my current knowledge level, I won’t have a chance to help here ^^
In his apexchart this guy is also implementing a minimum price, should be easy enough to create a sensor that compares that value (on state change (see above) of the current price) and sets it to 1 if equal or 0 if not.
Actually, the same guy Edward is everywhere
Also I just found out that tibber is indeed giving min/max/avg price - I just looked at two different sensors and could not find the attribute -.-
Hello Edward,
I am new to HA. Where do I put the code exactly?
I am also strugfgling to automate due to the “3-day” price level. I need an entity with a “todays price level”.
Thank you in advance