Skip to main content
Version: v3

BATTERY

Creating Sensors

const battery = hmSensor.createSensor(hmSensor.id.BATTERY)

console.log('The current battery level is ' + battery.current + '\r\n')

Battery instance

battery: object

PropertiesDescriptionType
current-current powernumber

Registering sensor instance callback events.

battery.addEventListener(event, callback: Callback)

the events of CHANGE

The value of events

hmSensor.event.CHANGE

Callback

() => void

The example of events

battery.addEventListener(hmSensor.event.CHANGE, function () {
console.log('The current battery level is ' + battery.current + '\r\n')
})