Skip to content

Commit

Permalink
Exclude devices without monitoring API e.g hs100
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
jamesbarnett91 committed Nov 18, 2018
1 parent 27f8862 commit 01f4993
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions services/device-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ var devices = [];
client.startDiscovery({
deviceTypes: ['plug'],
discoveryTimeout: 20000
}).on('plug-new', plug => {
console.log('Found device: ' + plug.alias + ' [' + plug.deviceId + ']');
devices.push(plug);
}).on('plug-new', registerPlug);

dataLogger.startLogging(plug);
});
function registerPlug(plug) {

if (plug.supportsEmeter) {
console.log('Found device with energy monitor support: ' + plug.alias + ' [' + plug.deviceId + ']');
devices.push(plug);
dataLogger.startLogging(plug);
} else {
console.log('Skipping device: ' + plug.alias + ' [' + plug.deviceId + ']. Energy monitoring not supported.');
}

}

module.exports.getDevice = function(deviceId) {

Expand Down

0 comments on commit 01f4993

Please sign in to comment.