BatteryState
Represents battery charge level, voltage, current, and charging status.
Attributes:
Attribute | Type | Description |
|---|---|---|
|
| Battery metadata header |
|
| Temperature, unit: degrees Celsius |
|
| Current charge, unit: |
|
| Capacity, unit: |
|
| Battery serial number |
Read-only attributes:
Attribute | Type | Description |
|---|---|---|
|
| Charge percentage, range |
|
| Voltage, unit: |
|
| Current, unit: |
|
| Raw power supply status code |
|
| Human-readable status, e.g. |
|
| Second-precision timestamp, equivalent to |
|
| Whether the battery is currently charging |
|
| Whether charge is below 20% |
|
| Whether charge is below 10% |
BatteryState
Signature:
BatteryState(
percentage: float,
voltage: float | None = None,
current: float | None = None,
status: int = 0,
header: Header | None = None,
temperature: float | None = None,
charge: float | None = None,
capacity: float | None = None,
serial_number: str = "",
)
Description:
Constructs a BatteryState instance.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | Charge percentage, typically in range |
|
| No | Voltage, unit: |
|
| No | Current, unit: |
|
| No | Raw power supply status code: |
|
| No | Battery metadata header; uses default |
|
| No | Temperature, unit: degrees Celsius |
|
| No | Current charge, unit: |
|
| No | Capacity, unit: |
|
| No | Battery serial number |
Returns:
BatteryState instance.
Raises:
None.
to_numpy
Signature:
BatteryState.to_numpy() -> dict[str, np.float32]
Description:
Returns a dictionary of core numeric fields. Includes percentage; optional fields voltage / current / temperature / charge / capacity are included when not None.
Parameters:
No parameters.
Returns:
dict[str, np.float32].
Raises:
None.