1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added device battery indication

This commit is contained in:
Ylian Saint-Hilaire 2020-05-30 17:21:45 -07:00
parent 1a2c85e9f0
commit bf5be3c145
7 changed files with 1406 additions and 1339 deletions

View file

@ -1351,6 +1351,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
obj.updateSessions();
break;
}
case 'battery': {
// Device battery and power state
if (obj.sessions == null) { obj.sessions = {}; }
if (obj.sessions.battery == null) { obj.sessions.battery = {}; }
if ((command.state == 'ac') || (command.state == 'dc')) { obj.sessions.battery.state = command.state; } else { delete obj.sessions.battery.state; }
if ((typeof command.level == 'number') && (command.level >= 0) && (command.level <= 100)) { obj.sessions.battery.level = command.level; } else { delete obj.sessions.battery.level; }
obj.updateSessions();
break;
}
case 'plugin': {
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
try {