Skip to content

Commit

Permalink
Remove stale units
Browse files Browse the repository at this point in the history
  • Loading branch information
Joolee committed Jun 9, 2020
1 parent 9bdbd0b commit 9e68c42
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ESPEasyUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,16 @@ module.exports = class ESPEasyUnit extends Homey.SimpleClass {
this.emit("stateChange", this, state);
}

if (this.driver) {
if (
this.lastEvent &&
!this.driver &&
!this.sensors &&
!this.gpios &&
state == false &&
(new Date().getTime() - this.lastEvent.getTime()) > 3600
) {
this.log("Unit not in use and offline for > 1h, removing from cache");
Homey.app.units.removeUnit(this);
}
}

Expand Down

0 comments on commit 9e68c42

Please sign in to comment.