I ran into the "No valid power detection" issue, as did some others. In my case I had to add "pending-charge" as status to make it work.
best regards,
Michael
try:
out = subprocess.check_output(('upower', '-i', '/org/freedesktop/UPower/devices/battery_BAT0'))
res = re.search(rb'state:\s+(.+)', out).group(1).decode().strip()
if res == 'discharging':
return True
elif res == 'pending-charge':
return False
elif res in ('fully-charged', 'charging'):
return False
except:
pass
warning('No valid power detection methods found. Assuming that the system is running on battery power.')
return True
Hi,
I ran into the "No valid power detection" issue, as did some others. In my case I had to add "pending-charge" as status to make it work.
best regards, Michael
try: out = subprocess.check_output(('upower', '-i', '/org/freedesktop/UPower/devices/battery_BAT0')) res = re.search(rb'state:\s+(.+)', out).group(1).decode().strip() if res == 'discharging': return True elif res == 'pending-charge': return False elif res in ('fully-charged', 'charging'): return False except: pass