Closed ArjenR49 closed 3 years ago
My bad, as they say .... it was at least partially myself to blame ... Sorry for throwing doubt on the UPS in this respect.
I use Frtz13's script, but have made some changes to it and therefore I prefer to merge a new script version by Frtz13 with my version of it by using the Kompare program on my laptop. One could wait for something to go wrong there ...
The script as I had it since Frtz13's last - sweeping - changes crashed just when it needs to do the shutdown, because of a name change. This all is not very important to others. It was easy to correct after I had set the protection voltage high to gain time and restarted the script after it had crashed and not finished properly, which I didn't realize at the time. Running it in Thonny revealed the error.
Anyway .. in the event reported above I did find the batteries in the morning with very low voltage below 3 V. The control script had missed the shutdown, because it crashed and therefore the countdown timer 0x18 and the back-on-AC 0x19 weren't set. The UPS continued to power the Pi and then somehow missed its own checkpoint voltage (fully discharged) from 0x0F-0x10 set at 3200mV, or the batteries drained very quickly and steeply below the 3200mV in the attempts to start the Pi up. So ... better be careful when editing scripts containing code parts that are only rarely executed, where errors go undetected .... also maybe not go very low in the fully discharged department (which is somehow learned by the f/w from the protection voltage through discharge cycles) ... After all, a UPS 's main goal is to safely shut down the load when there is AC failure and start up again after AC comes back. No need to keep the load running without AC for hours, is there? That is a different scenario, aka mobile computing.
My UPS plus has f/w 9. The control script I use is Frtz13's fanShutDownUPS.py. In addition to its fan control and HA reporting it observes the same UPS functions as the GeeekPi scripts with extra's, i.e. when AC fails, it writes messages to the syslog about the battery voltage dropping and at a margin of 200 mV above the protection voltage it sets the countdown timer 0x18 register to 60 and then sends a shutdown command to the Pi.
I have had the protection voltage at 3200 mV for some time now and have run down the batteries till automatic shutdown by the UPS itself (no control script running) and reconnected AC a few times to have the UPS 'learn' the battery fully discharged value. This has been successful as I described elsewhere.
In order to find out the influence of the battery sampling interval (period) on e.g. the estimated battery capacity and charging/discharging behaviour of the UPS, I had very recently set the sampling interval to 600 instead of the default 2 minutes. I can't say if this is to blame for the mishap that happened last night after disconnecting AC.
Anyway, according to the syslog last night the control script initiated a shutdown at 3.38 a.m. However the Pi kept running past the shutdown command somehow as can be seen from the syslog until at 4.17 a.m. almost an hour later it 'succumbed'. Of course during those 50 mintes the control script was not running any longer and no entries were made by it in the syslog.
The UPS f/w OTOH has no way of writing to the syslog, so I remain the dark how it judged the situation. The batteries must have been going down much past 3200 mV until the Pi stopped at 4:17 after the Pi had been going about its business for almost another hour as if nothing was the matter. Renewing the HA token and other normal things.
The UPS f/w hadn't cut the power at 3200 mV as it had done in my earlier tests, because in the morning I found them having only 2,5 V or lower. Much below the specified 2,75 V for these cells.
When I reconnected AC in the morning as intended, the Pi didn't start. It just kept making attempts without any result flashing its red and green leds. No HDMI output. Eventually I had to take out the batteries to find them dangerously empty and recharge them in a separate Nitecore UM-2 charger to some safer level.
No real clue as to why the UPS didn't just cut the power to the Pi as it should after the 60 seconds written to countdown timer register 0x18 by the control script before the shutdown command, nor why the UPS f/w obviously didn't observe the protection voltage of 3200 mV as it did in earlier tests when no control script was running.
Currently this UPS/Pi is running again and batteries are being charged by the UPS. I set the protection voltage higher than before, to 3500 mV, and the sampling interval had gone back to 2 minutes (apparently automatically after taking out and replacing the batteries).
It was scary to have the batteries so mistreated. They weren't hot when I took them out, but must have taken a hit.