Tarif threshold for dynamic strategy
Last night my battery's are charged at the cheapest moment, but in my opinion it was not cheap enough.
Would be nice to be able to set a threshold, so charging only happens when the cheapest price is below that.
I noticed this as well, this is (I think) because the cheapest hours logic only looks at today's tariffs (recently changed in 4.0). Now every night there are a few cheap hours, and charging starts. Only discharging appears to be controlled by the configured spread between cheap and expensive hours.
I'm thinking maybe adding a 16/84-percentile statistics helper could be useful to not only determine whether the tariffs are low for the current day but also compared to the last week. This allows the algorithm to go along with seasonal trends. The 16% and 84% roughly correspond to the four cheapest and most expensive hours on the day. Perhaps similar statistics could also be used to determine the spread more reliably. For example, you could then use the 8-percentile as a rough indicator for the average charging tariff and determine if the spread is large enough to compensate for the round trip efficiency.
The logic would then become:
- If current < 16-percentile: charge
- If current > 84-percentile and (current - 8-percentile) > spread: self-consumption
- Else: charge PV
I just realised that this does not take into account any duration of consecutive expensive or cheap hours, I'm no sure whether that's a net positive or negative. It could allow to cover multiple expensive peaks during a day, possibly charging in between. It does however mean less "clean" cycles of discharging and charging, not sure what that means for the battery life, but probably still better than a full self-consumption model with rapid switching from charging to discharging and back again.
Thinking a bit more about this I also realised that when today is an expensive day but the daily spread is large enough, one might want to charge even though the cheapest hours are more expensive than the longer term cheap hours. But that only makes sense if the cheapest hours occur before the expensive hours, which is not always the case.
The logic would then be something like this (where the daily spread still needs a better definition than it currently has):
- If current < 16-percentile or daily_spread > min_spread: charge
- If current > 84-percentile and (current - 8-percentile) > spread: self-consumption
- Else: charge PV
Though I like your idea @Hugovdberg, is my idea not way simpeler to implement?
I think it isn't much harder to implement, in either case you need to monitor input from home assistant. Home assistant has built in functionality to track the percentiles, which then removes the need to manually update the threshold.
Just as an update. Recent development is laying the ground work for more advanced algorithms in the near future, like the one suggested here. Development in this area is in motion this year.
Just as an update.
Work on the advanced algorithm has been voted as development priority for the next months.
I will share my work so far later this week