Wty-batinfo Today
# Status info['status'] = read_file(f"BAT_PATH/status") # Charging, Discharging, Full info['voltage_mV'] = read_file(f"BAT_PATH/voltage_now") info['current_mA'] = read_file(f"BAT_PATH/current_now") info['temp_c'] = read_file(f"BAT_PATH/temp") if info['temp_c']: info['temp_c'] = int(info['temp_c']) / 10 # often in deci-Celsius
def read_file(path): try: with open(path, 'r') as f: return f.read().strip() except: return None WTY-BatInfo
BAT_PATH = "/sys/class/power_supply/BAT0" WTY-BatInfo