Source code for hub.battery

"""The hub's own battery: how full it is and whether it is charging.

Values update about every 2 seconds.
"""

[docs] UNKNOWN: int
"""State: not known yet."""
[docs] ON_BATTERY: int
"""State: running on battery, no charger plugged in."""
[docs] CHARGING: int
"""State: plugged in and charging."""
[docs] FULLY_CHARGED: int
"""State: plugged in and the battery is full."""
[docs] def voltage() -> int: """Battery voltage in millivolts (1000 mV = 1 V). ``0`` if it can't be measured.""" ...
[docs] def percent() -> int: """How full the battery is, from 0 to 100 %.""" ...
[docs] def state() -> int: """What the battery is doing: ``UNKNOWN``, ``ON_BATTERY``, ``CHARGING`` or ``FULLY_CHARGED``.""" ...
[docs] def charging() -> bool: """``True`` while the battery is charging.""" ...
[docs] def fully_charged() -> bool: """``True`` when a charger is plugged in and the battery is full.""" ...