1

I have a UPS (Back-UPS ES 850M2) connected via USB to my desktop PC (Ubuntu 19.10). When I disconnect the power cord, the battery in the top bar does not change, take between 2 and 5 minutes to change and display the battery status and percent and then show a notification "Running on batteries..." after plug the power cord again, the same situation, does not change instantly...the battery still displaying the percentage and show "discharging..." during some minutes..

Even, the battery always display "Estimating..." in the menu although the correct % is displayed in the settings:

Menu:

enter image description here

Settings:

enter image description here

I check the status of the ups using apcaccess and tail /var/log/apcupsd.events, when I disconnect the power cord the logs display instantly

Power failure.
Running on UPS batteries.

And after connect again display instantly:

Mains returned. No longer on UPS batteries.
Power is back. UPS running on mains.

apcaccess display the time and status correctly, my question is why the desktop does not change the battery status instantly?. I'ts a bit annoying because it takes too long to update the real battery status and the computer has even turned off, because I thinking that I have more time left. Any suggestions?, any help is appreciated in advance!

rafrsr
  • 1,296
  • 1
    What is the value of ONBATTERYDELAY (in /etc/apcupsd/apcupsd.conf)? – ajgringo619 Nov 16 '19 at 00:33
  • ONBATTERYDELAY 1 and tested with 0, 10, 20 etc, and nothing, something very strange is that the time it takes to change the status of the battery is never the same – rafrsr Nov 16 '19 at 00:37
  • Hmmm...I have mine set to 6 and it has worked reliably so far. The only other setting that I can think of that might make a difference is POLLTIME (mine is set @ 60). – ajgringo619 Nov 16 '19 at 00:41
  • This might help: https://askubuntu.com/questions/878556/get-battery-status-to-update-more-often-or-on-ac-power-wake – WinEunuuchs2Unix Nov 16 '19 at 00:57
  • @ajgringo619 default POLLTIME is 60, I set to 5 seconds but nothing – rafrsr Nov 16 '19 at 01:21
  • @WinEunuuchs2Unix the script does not work, throw exception but I can see some interesting things there, I'm still researching – rafrsr Nov 16 '19 at 01:21
  • @rafrsr I hope it helps. You know my UPS can send a signal via USB to the laptop. In windows there is a program to popup an alert when on battery and run a shutdown job eventually. In Linux there is nothing but I could write something. I just didn't think it that important though. – WinEunuuchs2Unix Nov 16 '19 at 01:26

1 Answers1

1

Finally I found a solution, thanks to @WinEunuuchs2Unix for the suggestions

Like described here:

Get battery status to update more often or on AC power/wake.

All the problem is with upower, the UPower service does calls for updating/refreshing battery information.

Then you need force a refresh, firstly get your device name:

upower -e

/org/freedesktop/UPower/devices/ups_hiddev0

create a batch:

keep-battery-updated.sh

#!/bin/bash
while sleep 2; do
   busctl call --system org.freedesktop.UPower /org/freedesktop/UPower/devices/ups_hiddev0 org.freedesktop.UPower.Device Refresh
done

and add it as a startup script.

I configure the script with 2 second between refresh, change it as you wish.

rafrsr
  • 1,296