Compare commits

..

No commits in common. "09713684824fa423b7a66e8308f5725c7ce55565" and "c927997d6944e6be129e5a8bdcd21f53bab40e19" have entirely different histories.

2 changed files with 39 additions and 20 deletions

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
*.log
.inspect.json
shelly.conf shelly.conf
*.log

24
pool.js
View File

@ -7,6 +7,7 @@ let status = {
temp_yesterday: null, temp_yesterday: null,
update_time: null, update_time: null,
update_time_last: 0,
update_temp_max_last: null, update_temp_max_last: null,
disable_temp: null, disable_temp: null,
@ -23,6 +24,7 @@ let status = {
tick_temp: 0, tick_temp: 0,
tick_lock: 0, tick_lock: 0,
tick_pump: 0, tick_pump: 0,
tick_pump_skip: 0,
tick_day: 0, tick_day: 0,
}; };
@ -241,7 +243,11 @@ function update_temp(temp) {
print("[POOL] update_temp - max:", status.temp_max, "today:", status.temp_today, "yesterday:", status.temp_yesterday); print("[POOL] update_temp - max:", status.temp_max, "today:", status.temp_today, "yesterday:", status.temp_yesterday);
let time = Shelly.getComponentStatus("sys").time; // "HH:MM" Shelly.call (
"Sys.GetStatus",
{},
function (result) {
let time = result.time; // "HH:MM"
print("[POOL] time", time); print("[POOL] time", time);
// compute current time in float format (12h45 -> 12.75) // compute current time in float format (12h45 -> 12.75)
@ -253,12 +259,21 @@ function update_temp(temp) {
status.update_time = t; status.update_time = t;
if ((status.temp_max !== null) && (status.temp_max !== status.update_temp_max_last)) { if ((status.temp_max !== null) && (status.temp_max !== status.update_temp_max_last)) {
if ((t - status.update_time_last) > 0.15) { // 9 minutes
update_pump(status.temp, status.temp_max, t); update_pump(status.temp, status.temp_max, t);
status.update_time_last = t;
status.update_temp_max_last = status.temp_max; status.update_temp_max_last = status.temp_max;
} }
else {
status.tick_pump_skip++;
print("[POOL] to much update_pump, skipped", status.tick_pump_skip);
}
}
else { else {
print("[POOL] no temp change, skip update_pump"); print("[POOL] no temp change, skip update_pump");
} }
}
);
status.lock_update = false; status.lock_update = false;
} }
@ -335,10 +350,15 @@ Timer.set(
true, true,
function() { function() {
status.tick++; status.tick++;
let result = Shelly.getComponentStatus("sys"); Shelly.call (
"Sys.GetStatus",
{},
function (result) {
print("[POOL] tick", result.time); print("[POOL] tick", result.time);
status.time = result.time; status.time = result.time;
status.uptime = result.uptime; status.uptime = result.uptime;
} }
);
}
); );