remove all update disables
This commit is contained in:
		
							
								
								
									
										44
									
								
								pool.js
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								pool.js
									
									
									
									
									
								
							@@ -7,10 +7,8 @@ let status = {
 | 
			
		||||
  temp_yesterday: null,
 | 
			
		||||
 | 
			
		||||
  update_time: null,
 | 
			
		||||
  update_time_last: 0,
 | 
			
		||||
  update_temp_max_last: null,
 | 
			
		||||
 | 
			
		||||
  disable_temp: null,
 | 
			
		||||
  lock_update: false,
 | 
			
		||||
 | 
			
		||||
  duration: null,
 | 
			
		||||
@@ -22,9 +20,7 @@ let status = {
 | 
			
		||||
  tick: 0,
 | 
			
		||||
  tick_mqtt: 0,
 | 
			
		||||
  tick_temp: 0,
 | 
			
		||||
  tick_lock: 0,
 | 
			
		||||
  tick_pump: 0,
 | 
			
		||||
  tick_pump_skip: 0,
 | 
			
		||||
  tick_day: 0,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -215,11 +211,6 @@ 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;
 | 
			
		||||
@@ -259,15 +250,8 @@ function update_temp(temp) {
 | 
			
		||||
      status.update_time = t;
 | 
			
		||||
 | 
			
		||||
      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);
 | 
			
		||||
          status.update_time_last = t;
 | 
			
		||||
          status.update_temp_max_last = status.temp_max;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
          status.tick_pump_skip++;
 | 
			
		||||
          print("[POOL] to much update_pump, skipped", status.tick_pump_skip);
 | 
			
		||||
        }
 | 
			
		||||
        update_pump(status.temp, status.temp_max, t);
 | 
			
		||||
        status.update_temp_max_last = status.temp_max;
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        print("[POOL] no temp change, skip update_pump");
 | 
			
		||||
@@ -319,30 +303,6 @@ 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(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user