[CODE] return a shorter waitTime when it’s night time
This commit is contained in:
parent
0e18048954
commit
85f3ee44ca
|
@ -14,6 +14,7 @@ $timezone = "Europe/Berlin";
|
||||||
class LightStatus {
|
class LightStatus {
|
||||||
public $state = true;
|
public $state = true;
|
||||||
public $changeTime = 1;
|
public $changeTime = 1;
|
||||||
|
public $waitTime = 0;
|
||||||
|
|
||||||
public $times = null;
|
public $times = null;
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ class LightStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
function __toString() {
|
function __toString() {
|
||||||
return 's='.(int)$this->state.' t='.$this->changeTime;
|
return 's='.(int)$this->state.' t='.$this->waitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
|
@ -46,6 +47,7 @@ class LightStatus {
|
||||||
if ($this->times['instant-on'] > time()) {
|
if ($this->times['instant-on'] > time()) {
|
||||||
$this->state = true;
|
$this->state = true;
|
||||||
$this->changeTime = (int)(($this->times['instant-on']-time())/60);
|
$this->changeTime = (int)(($this->times['instant-on']-time())/60);
|
||||||
|
$this->waitTime = $this->changeTime;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -78,18 +80,21 @@ class LightStatus {
|
||||||
if ($currentTime > $startTime && $currentTime < $stopTime) {
|
if ($currentTime > $startTime && $currentTime < $stopTime) {
|
||||||
$this->state = true;
|
$this->state = true;
|
||||||
$this->changeTime = (int)(($stopTime - $currentTime) / 60);
|
$this->changeTime = (int)(($stopTime - $currentTime) / 60);
|
||||||
|
$this->waitTime = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->state = false;
|
$this->state = false;
|
||||||
$this->changeTime = (int)(($stopTime - $currentTime) / 60);
|
$this->changeTime = (int)(($stopTime - $currentTime) / 60);
|
||||||
|
$this->waitTime = 1;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if ($currentTime > $sunrise && $currentTime < $sunset) {
|
} else if ($currentTime > $sunrise && $currentTime < $sunset) {
|
||||||
// it's day: nothing else check
|
// it's day: nothing else check
|
||||||
$this->state = false;
|
$this->state = false;
|
||||||
$this->changeTime = (int)(($sunset - $currentTime) / 60);
|
$this->changeTime = (int)(($sunset - $currentTime) / 60);
|
||||||
|
$this->waitTime = $this->changeTime;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in a new issue