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
|
||||
let on = false;
|
||||
let j = false;
|
||||
for (let i = 0; i < schedule.length; i++) {
|
||||
j = !j;
|
||||
if (time >= schedule[i])
|
||||
on = j;
|
||||
if (schedule.length === 1) {
|
||||
on = true;
|
||||
}
|
||||
else {
|
||||
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}});
|
||||
|
Loading…
Reference in New Issue
Block a user