# Battery Information battery

# Interface Declaration

{ "name": "system.battery" }

# Import Module

import battery from '@system.battery' 
// or 
const battery = require('@system.battery')

# Interface Definition

# battery.getStatus(OBJECT)

Obtain the battery information of the current device.

# Parameters:

Parameter Name Type Required Description
success Function No Callback for success
fail Function No Callback for failure
complete Function No Callback after execution completion

# Return Values for success:

Parameter Name Type Description
charging Boolean Whether charging is in progress
level Number Current battery level, ranging from 0.0 to 1.0

# Example

battery.getStatus({
  success: function(data) {
      console.log(`handling success: ${data.level}`)
  },
  fail: function(data, code) {
      console.log(`handling fail, code = ${code}`)
  }
})

# Support Details

Device Product Description
Xiaomi S1 Pro Sports and Health Watch Not supported
Xiaomi Band 8 Pro Not supported
Xiaomi Band 9 / 9 Pro Not supported
Xiaomi Watch S3 Not supported
Redmi Watch 4 Not supported
Xiaomi Wrist ECG Blood Pressure Monitor Not supported
Xiaomi Band 10 Supported
Xiaomi Watch S4 Supported
REDMI Watch 5 Supported