From 99063122e12d9e063c3389c58f68eed4b8f62f67 Mon Sep 17 00:00:00 2001 From: simont77 <26008536+simont77@users.noreply.github.com> Date: Sun, 15 Apr 2018 15:01:08 +0200 Subject: [PATCH] set back timer to guarantee correct countdown when app is close --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index f00ad8d..17b6c46 100644 --- a/index.js +++ b/index.js @@ -289,8 +289,14 @@ class LegrandMyHome { if (accessory.power) { accessory.RemDuration = _value; + accessory.timerHandle = setInterval(function() { accessory.IrrigationService.setCharacteristic(Characteristic.RemainingDuration,accessory.RemDuration); + accessory.RemDuration--; + if (accessory.RemDuration == 0) + clearInterval(accessory.timerHandle); + }.bind(this),1000); } + } }.bind(this)); @@ -1792,6 +1798,7 @@ class MHIrrigation { } else { + clearInterval(this.timerHandle); this.RemDuration = 0; this.IrrigationService.setCharacteristic(Characteristic.RemainingDuration,this.RemDuration); }