reactivate disable_temp during 10mn after switch on
This commit is contained in:
		
							
								
								
									
										31
									
								
								pool.js
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								pool.js
									
									
									
									
									
								
							@@ -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(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user