fusion_hat.battery module
Battery class
Read battery data from upower
Example
>>> battery = Battery()
>>> print(battery)
Fusion Hat SunFounder Discharging 76% 7935.00 mV
>>> print(battery.present)
True
>>> print(battery.online)
True
>>> print(battery.status)
Discharging
>>> print(battery.capacity)
76
>>> print(battery.voltage_now)
7935
>>> print(battery.model_name)
Fusion HAT
>>> print(battery.manufacturer)
SunFounder
- class fusion_hat.battery.Battery(*args, **kwargs)[source]
Bases:
_BaseBattery class
Read battery data from upower
- Parameters:
*args – pass to
fusion_hat._base._base**kwargs – pass to
fusion_hat._base._base
- DEVICE_NAME = 'fusion-hat'
- PATH = '/sys/class/power_supply/fusion-hat'
- property present: bool
check if battery is present
- Returns:
True if battery is present, False otherwise
- Return type:
bool
- property online: bool
check if battery is online
- Returns:
True if battery is online, False otherwise
- Return type:
bool
- property status: str
get battery status
- Returns:
battery status
- Return type:
str
- property capacity: int
get battery capacity
- Returns:
battery capacity in percent
- Return type:
int
- property voltage: float
get battery voltage
- Returns:
battery voltage in V
- Return type:
float
- property model_name: str
get battery model name
- Returns:
battery model name
- Return type:
str
- property is_charging: bool
check if battery is charging
- Returns:
True if battery is charging, False otherwise
- Return type:
bool
- property manufacturer: str
get battery manufacturer
- Returns:
battery manufacturer
- Return type:
str