Hi folks,
Just to give you a bit of background before I ask my question. Here in South Africa, we have rolling power outages which we call load shedding. There are 8 stages and the higher the stage, the more
MW needs to be shed off the gird and thus more areas are affected and more regularly power needs to be cut. The power cuts last around 2 hours. For instance, yesterday my area was shed 3 times as we were on stage 4.
A few months ago before all hell broke loose with the constant load shedding, we installed an inverter/battery system to keep the power on during load shedding. Works great! I have everything integrated with Home Assistant, so I can keep track of state of charge, when the power is out or not, etc. I have a plethora of data at my fingertips.
Of course there are times, like yesterday, where I wasn’t aware that we were load shed … I had did some pool maintenance so I had the pool pump going, my wife had the dishwasher on and basically 10 min before power was to be restored, the battery ran out of juice.
So I immediately added some automations to notify me if the battery is below 50%, 35% and 30% … it is usually around 20% or so that my inverter shuts the power off.
The notifications work great and last night I received the one whereby my battery was below 50% … which was about 10min before power was restored.
I want to make these notifications a bit more intelligent. That one mentioned above I should not have received because the battery would have kept us going for those last 10 min without any issues.
So here is my question.
How can I predict if the battery will die so that I can get these types of notifications out without them being a “cry wolf”?
I have the following at my disposal.
Date and time when the power went out.
Date and time when the power will be restored
State of charge (of course)
The load on the battery i.e. the watts drawn.
I know this is not going to be accurate as power draw is not constant during those 2 or so hours - we might boil the kettle, or watch TV, turn on a computer, etc, etc … we go about our day / night as if we are not load shed - that is the beauty of this, but I am hoping to be able to get notified when the system assesses and sees that we are not going to make it and thus based on these notifications, will know to reduce our usage - like in yesterday’s case, turn off the dishwasher and pool pump.
My thought is predict the state of charge of the battery when power is restored. Since we know when the power went out, the current time and we know when the power will be restored, so my thought is to calculate the number of minutes between those two times and hopefully calculate the predicted state of charge.
eg:
Power went off at 10:00am, will be restored at 12:00pm and it is 10:30am, so 90 min until power is restored. At 10:30, the state of charge is 90%, so between 10:00am and 10:30am, 10% was depleted in 30min. Based on current usage, the battery should be at 60% when the power is restored. As such, the notification won’t be sent out.
At 11:00am, the battery is at 70% which means that more power was used, so in an hour 30% was used and since there is an hour left of load shedding, it will predict that the batter will be 40% and as such, the notification will go out.
I hope that my thinking isn’t flawed, but it is a good start.
The other use case for this is that we have prepaid electricity and there has been a time when I forgot to load more kw/h into the meter and the power went off while I was at work. Thankfully nobody is home, so the power draw is low, but it would be cool to let HA predict as to what time the battery will run out.
I figured a template sensor to contain the predicted state of charge would be what I’d need. So how would I do this using templating? I really would appreciate your help on this please. If you have any other ideas, please let me know. This would be really cool.
Next year I plan to do my on-wall dashboard, so having some info on there to glance at while in the kitchen would be good.