feat: battery percentage changed event (#126)

New "change_battery" event is triggered when the battery percentage changes. Has current battery percentage and charging state as object param.

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
Aliyss Snow
2020-04-06 05:36:03 +02:00
committed by GitHub
parent 1780436b93
commit 93a617336a
3 changed files with 23 additions and 0 deletions

View File

@@ -237,6 +237,12 @@ client.on('group_update', (notification) => {
console.log('update', notification);
});
client.on('change_battery', (batteryInfo) => {
// Battery percentage for attached device has changed
const { battery, plugged } = batteryInfo;
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
});
client.on('disconnected', (reason) => {
console.log('Client was logged out', reason);
});