batteryState.getState()

Type Function
Return value Table
Revision Release 2022.3683
Keywords battery, batteryState, getState
See also batteryState.init()
batteryState.*

Overview

Reads the current battery state. This method returns a table of results immediately, with the following properties:

Note

If you want a persistent method of checking the battery state, you should follow the listener-based example illustrated in batteryState.init().

Syntax

batteryState.getState()

Example

local batteryState = require( "plugin.batteryState" )

-- Initialize plugin without state listener
batteryState.init()

-- Get current battery state
local batt = batteryState.getState()

print( "Level: " .. tostring(batt.level) )
print( "State: " .. tostring(batt.state) )
print( "isError: " .. tostring(batt.isError) )