pool: switch fix when schedule is [off, on]
This commit is contained in:
parent
f3c444d0de
commit
34143560a7
19
pool.js
19
pool.js
@ -158,11 +158,20 @@ function update_pump(temp, max, time) {
|
|||||||
|
|
||||||
// compute the current switch state according to the schedule
|
// compute the current switch state according to the schedule
|
||||||
let on = false;
|
let on = false;
|
||||||
let j = false;
|
if (schedule.length === 1) {
|
||||||
for (let i = 0; i < schedule.length; i++) {
|
on = true;
|
||||||
j = !j;
|
}
|
||||||
if (time >= schedule[i])
|
else {
|
||||||
on = j;
|
for (let i = 0; i < schedule.length; i+=2) {
|
||||||
|
let a=schedule[i];
|
||||||
|
let b=schedule[i+1];
|
||||||
|
if (a<b && time >= a && time < b) {
|
||||||
|
on = true;
|
||||||
|
}
|
||||||
|
else if (a>b && (time >= a || time < b)) {
|
||||||
|
on = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calls.push({method: "Switch.Set", params: {id: 0, on: on}});
|
calls.push({method: "Switch.Set", params: {id: 0, on: on}});
|
||||||
|
Loading…
Reference in New Issue
Block a user