reactivate disable_temp during 10mn after switch on

This commit is contained in:
Gilles Grandou 2022-10-31 18:30:36 +01:00
parent e1f6561331
commit 4b968ca944
1 changed files with 31 additions and 0 deletions

31
pool.js
View File

@ -9,6 +9,7 @@ let status = {
update_time: null,
update_temp_max_last: null,
disable_temp: null,
lock_update: false,
duration: null,
@ -20,6 +21,7 @@ let status = {
tick: 0,
tick_mqtt: 0,
tick_temp: 0,
tick_lock: 0,
tick_pump: 0,
tick_day: 0,
};
@ -211,6 +213,11 @@ function update_temp(temp) {
print("[POOL] update_temp", status.tick_temp, temp);
if (status.disable_temp !== null) {
print("[POOL] update disabled");
return;
}
if (status.lock_update) {
print("[POOL] update_temp locked");
return;
@ -303,6 +310,30 @@ MQTT.subscribe(
}
)
// after a Switch Event, disable temp update
// during 10 minutes
Shelly.addEventHandler(
function (data) {
if (data.info.event === "toggle") {
status.tick_lock++;
print("[POOL] disable temp", status.tick_lock);
if (status.disable_temp !== null)
Timer.clear(status.disable_temp);
status.disable_temp = Timer.set(
600 * 1000,
false,
function () {
print("[POOL] re-enable temp");
status.disable_temp = null;
}
);
}
}
);
// Debug...
Timer.set(