Skip to content

Commit

Permalink
Send notification only if command exists fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
ianperrin authored May 26, 2019
1 parent 8d7a263 commit b1dd8c3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions MMM-NetworkScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,19 @@ Module.register("MMM-NetworkScanner", {
if (anyoneHome > 0) {
if (this.occupied === false) {
if (this.config.debug) Log.info("Someone has come home");
command = self.config.occupiedCMD;
this.sendNotification(command.notification, command.payload);
if (this.config.occupiedCMD) {
var occupiedCMD = self.config.occupiedCMD;
this.sendNotification(occupiedCMD.notification, occupiedCMD.payload);
}
this.occupied = true;
}
} else {
if (this.occupied === true) {
if (this.config.debug) Log.info("Everyone has left home");
command = self.config.vacantCMD;
this.sendNotification(command.notification, command.payload);
if (this.config.vacantCMD) {
var vacantCMD = this.config.vacantCMD;
this.sendNotification(vacantCMD.notification, vacantCMD.payload);
}
this.occupied = false;
}
}
Expand Down

0 comments on commit b1dd8c3

Please sign in to comment.