Shut off the water supply valve during a triger water leakage sensor

Shuts off the water valve after 3 seconds after the leakage sensor triggers and sends an Email

Task

Event:
— Triggering the water leakage sensor

Do:
— Shut off the water supply valve
— Send email

Additional terms:
1. Cancel the overlap of the water supply valve in case of short-term sensor triggering (accidentally touched with a rag).
2. Give the ability to block the leak sensor.

Script

/** 
* @name Water leakage with sensor blocking
* @desc Shuts off the water valve 3 seconds after the leakage sensor has trigered.
*       Works if the sensor is not blocked.
*       For example, you can block the sensors at the time of cleaning to avoid false alarms
* @version 4
*/

const actor  = Device("ActorD", "Water valve"); 
const sensor = Device("SensorD", "Leakage sensor");  

startOnChange([sensor,actor], !sensor.blk && sensor.isOn() && actor.isOn()); 

script ({
    start() {
     this.startTimer("T1", 3, "close");       
    },
    
    close() {
     actor.off();  
     this.info("email", "OWNER", 'Water leak! The water valve is shut off!')
    }
});
Close Menu