i3pystatus icon indicating copy to clipboard operation
i3pystatus copied to clipboard

Battery displaying incorrect information when fully charged.

Open alexytsu opened this issue 9 years ago • 11 comments

When my laptop is plugged in and fully charged, the battery status displays as "Battery Checker: CHARGE_NOW". As soon as the power supply is unplugged, it displays the correct discharging value. When plugged back in, the status will display as FULL for a few seconds before changing colour to BatteryChecker: 'CHARGE_NOW' indefinitely.

alexytsu avatar Jun 19 '15 12:06 alexytsu

  • Which i3pystatus version?
    • If git, any errors logged in ~/.i3pystatus-<pid>?
  • What does cat /sys/class/power_supply/BAT0/uevent say?
  • Laptop make / model?

enkore avatar Jun 19 '15 12:06 enkore

Same issue here.

  • i3pystatus version 3.33
  • Laptop Dell XPS 15
  • /sys/class/power_supply/BAT1/uevent says:
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11370000
POWER_SUPPLY_VOLTAGE_NOW=12782000
POWER_SUPPLY_ENERGY_FULL_DESIGN=91000000
POWER_SUPPLY_ENERGY_FULL=89210000
POWER_SUPPLY_ENERGY_NOW=89210000
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_CAPACITY_LEVEL=Full
POWER_SUPPLY_MODEL_NAME=PABAS0241231
POWER_SUPPLY_MANUFACTURER=Simplo
POWER_SUPPLY_SERIAL_NUMBER=41167

Note the absence of POWER_SUPPLY_POWER_NOW. Right after plugin the AC back, this value is present and set to 0. i3pystatus then displays correct info. This value then quickly vanishes and i3pystatus says BatteryChecker: 'CHARGE_NOW'.

FYI, ~/.i3pystatus-$pid is full of:

> Exception in Thread-4 at Fri 03 Jul 2015 03:20:25 PM CEST, module BatteryChecker
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/i3pystatus/core/threading.py", line 68, in __call__
    self.workload()
  File "/usr/lib/python3.4/site-packages/i3pystatus/core/modules.py", line 158, in __call__
    self.run()
  File "/usr/lib/python3.4/site-packages/i3pystatus/battery.py", line 249, in run
    batteries.append(Battery.create(path))
  File "/usr/lib/python3.4/site-packages/i3pystatus/battery.py", line 35, in create
    return BatteryCharge(battery_info)
  File "/usr/lib/python3.4/site-packages/i3pystatus/battery.py", line 65, in __init__
    bi["CHARGE_FULL"] = bi["CHARGE_FULL_DESIGN"] if bi["CHARGE_NOW"] > bi["CHARGE_FULL"] else bi["CHARGE_FULL"]
KeyError: 'CHARGE_NOW'

galaux avatar Jul 03 '15 12:07 galaux

An estimate is a bit hard for these batteries (since they don't give current power or current consumption, although we could differentiate ENERGY/CHARGE_NOW numerically), but it shouldn't crash. I'll look into it.

enkore avatar Jul 03 '15 15:07 enkore

When battery is charging/discharging, everything is OK. It is just when AC is plugged and battery is fully charged that this value disappears. Shouldn't we thus assume "no value" means "fully charged"? I mean I can't figure out whether this value should be present in /sys – this would thus be a battery module bug – or if it can be absent – this would thus be a i3pystatus bug.

galaux avatar Jul 15 '15 12:07 galaux

Ok, I'll look into it again

enkore avatar Jul 15 '15 13:07 enkore

Alright, I just ran into this and managed to track it down.

As shown by the above uevent example, POWER_NOW can disappear when the battery is fully charged. This causes Battery.create to use BatteryCharge in place of BatteryEnergy which means all the CHARGE_* keys don't exist.

belak avatar Jul 28 '15 18:07 belak

@belak would you have a fix for this?

galaux avatar Sep 10 '15 16:09 galaux

I'm also getting the output BatteryChecker: Keyerror: 'CHARGE_NOW'.

I'm not sure if it's the same bug, or something similar but not quite the same.

$ cat /sys/class/power_supply/BAT1/uevent
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Unknown
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_NOW=10000000
POWER_SUPPLY_ENERGY_FULL_DESIGN=50000000
POWER_SUPPLY_ENERGY_FULL=50000000
POWER_SUPPLY_ENERGY_NOW=50000000
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_CAPACITY_LEVEL=Full
POWER_SUPPLY_MODEL_NAME=VMware Virtual Battery
POWER_SUPPLY_MANUFACTURER=
POWER_SUPPLY_SERIAL_NUMBER=

WhyNotHugo avatar Oct 30 '18 17:10 WhyNotHugo

Hello guys. Any update on the issue?
Me too, getting the output BatteryChecker: Keyerror: 'CHARGE_NOW'
And this issue is already 4 years old. So yeah - any updates?

RZarifov avatar Mar 25 '22 20:03 RZarifov

I moved away from i3/i3pystatus so can't say. Sorry.

galaux avatar Mar 26 '22 08:03 galaux

I've never seen this bug, and I haven't worked on this code before, but it seems like the POWER_SUPPLY_STATUS line of the uevent file would be more reliable to determine whether or not the battery is currently charging, than relying on POWER_SUPPLY_POWER_NOW.

❯ grep POWER_SUPPLY_STATUS /sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_STATUS=Charging

terminalmage avatar Mar 27 '22 19:03 terminalmage