BB.Message.Sensor.BatteryState (bb v0.2.1)
View SourceBattery state information.
Fields
voltage- Voltage in Voltscurrent- Current in Amperes (negative when discharging)charge- Charge in Ampere-hours (0 if not measured)capacity- Capacity in Ampere-hours (full charge, 0 if not measured)percentage- Charge percentage (0.0 to 1.0, or nil if not measured)power_supply_status- Status of the power supplypower_supply_health- Health of the power supplypresent- Whether battery is present
Power Supply Status
:unknown- Cannot determine status:charging- Battery is charging:discharging- Battery is discharging:not_charging- Not charging (full or error):full- Battery is full
Power Supply Health
:unknown- Cannot determine health:good- Battery is healthy:overheat- Battery is overheating:dead- Battery is dead:overvoltage- Voltage too high:cold- Battery is too cold
Examples
alias BB.Message.Sensor.BatteryState
{:ok, msg} = BatteryState.new(:battery,
voltage: 12.6,
current: -0.5,
percentage: 0.85,
power_supply_status: :discharging,
power_supply_health: :good,
present: true
)
Summary
Types
@type power_supply_health() ::
:unknown | :good | :overheat | :dead | :overvoltage | :cold
@type power_supply_status() ::
:unknown | :charging | :discharging | :not_charging | :full
@type t() :: %BB.Message.Sensor.BatteryState{ capacity: float(), charge: float(), current: float(), percentage: float() | nil, power_supply_health: power_supply_health(), power_supply_status: power_supply_status(), present: boolean(), voltage: float() }
Functions
@spec new( atom(), keyword() ) :: {:ok, BB.Message.t()} | {:error, term()}