Package: battery-stats
Version: 0.5.1-1
Severity: normal

On my system, the collector script fails as follows:

# battery-stats-collector
cat: /sys/class/power_supply/BAT0/energy_now: No such file or directory
[exit code 1]

The details of the battery (when fully charged) are:

# cat /sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7400000
POWER_SUPPLY_VOLTAGE_NOW=8544000
POWER_SUPPLY_CURRENT_NOW=1000
POWER_SUPPLY_CHARGE_FULL_DESIGN=6440000
POWER_SUPPLY_CHARGE_FULL=5565000
POWER_SUPPLY_CHARGE_NOW=6440000
POWER_SUPPLY_CAPACITY=115
POWER_SUPPLY_CAPACITY_LEVEL=Full
POWER_SUPPLY_MODEL_NAME=DELL 909H538
POWER_SUPPLY_MANUFACTURER=SMP
POWER_SUPPLY_SERIAL_NUMBER=608

A few seconds after disconnecting, this becomes:

# cat /sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7400000
POWER_SUPPLY_VOLTAGE_NOW=8438000
POWER_SUPPLY_CURRENT_NOW=966000
POWER_SUPPLY_CHARGE_FULL_DESIGN=6440000
POWER_SUPPLY_CHARGE_FULL=5565000
POWER_SUPPLY_CHARGE_NOW=5465000
POWER_SUPPLY_CAPACITY=98
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=DELL 909H538
POWER_SUPPLY_MANUFACTURER=SMP
POWER_SUPPLY_SERIAL_NUMBER=608

So it looks like taking min(100 * charge_now / charge_full, 100) should 
give a percentage indicating how fully the battery is charged.

Can you use this as a fallback if energy_now / energy_full are not 
available for a battery?

Best regards,
Sebastian Kuhnert

--- System information. ---
Architecture: amd64
Kernel:       Linux 4.4.0-1-amd64

Reply via email to