diff --git a/lib/ESPEasyUnit.js b/lib/ESPEasyUnit.js index c8e56eb..7a49c54 100644 --- a/lib/ESPEasyUnit.js +++ b/lib/ESPEasyUnit.js @@ -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); } }