diff --git a/functions.php b/functions.php index 071b9a1..6369ca7 100644 --- a/functions.php +++ b/functions.php @@ -14,6 +14,7 @@ $timezone = "Europe/Berlin"; class LightStatus { public $state = true; public $changeTime = 1; + public $waitTime = 0; public $times = null; @@ -24,7 +25,7 @@ class LightStatus { } function __toString() { - return 's='.(int)$this->state.' t='.$this->changeTime; + return 's='.(int)$this->state.' t='.$this->waitTime; } public function update() { @@ -46,6 +47,7 @@ class LightStatus { if ($this->times['instant-on'] > time()) { $this->state = true; $this->changeTime = (int)(($this->times['instant-on']-time())/60); + $this->waitTime = $this->changeTime; return true; @@ -78,18 +80,21 @@ class LightStatus { if ($currentTime > $startTime && $currentTime < $stopTime) { $this->state = true; $this->changeTime = (int)(($stopTime - $currentTime) / 60); + $this->waitTime = 1; return true; } } $this->state = false; $this->changeTime = (int)(($stopTime - $currentTime) / 60); + $this->waitTime = 1; return true; } else if ($currentTime > $sunrise && $currentTime < $sunset) { // it's day: nothing else check $this->state = false; $this->changeTime = (int)(($sunset - $currentTime) / 60); + $this->waitTime = $this->changeTime; return true; } else {