Samsung Water Sensor, Leaks, turn item(s) OFF?

So, I have a water sensor. I have the security section in Leaks set up to turn on some lights. But, I want it to also turn off items. Mainly, I have an Intermatic CA3750 Z-Wave 220v contactor that is hooked to my pool’s pump. The pump and all equipment are indoors. I want the sensor to turn off the Intermatic switch when it detects water, so that 30gpm of water doesn’t go into the house while there’s a leak! I can’t find any way to have it turn stuff OFF, just ON.

This might help as it turns off a switch when a leak is detected. Just add a new smartapp and copy in the code below…

name: “Leak prevention”,
namespace: “Ghilen”,
author: “Trevor Williams”,
description: “Turn of switch on leak detection”,
category: “My Apps”,
iconUrl: “”,
iconX2Url: “”,
iconX3Url: “”)

preferences {
section(“Turn off when water is detected:”) {
input “thewater”, “capability.waterSensor”, required: true, title: “Where?”
section(“Turn off this switch”) {
input “theswitch”, “capability.switch”, required: true

def installed() {

def updated() {

def initialize() {
subscribe(thewater, “water.wet”, waterDetectedHandler)
subscribe(thewater, “water.dry”, waterStoppedHandler)

def waterDetectedHandler(evt) {
log.debug "waterDetectedHandler called: $evt"

def waterStoppedHandler(evt) {
log.debug “waterStoppedHandler called: $evt”

1 Like

Hey Trevor,

I was in a bit of a hurry to get this working, so after I did not hear anything for a day I went ahead and wrote my own code. I don’t like writing code, but can do so if pushed into the requirement. I even think I found some other code you wrote to use as an example. :slight_smile:

So, I have it set so that anytime water is sensed in that equipment room, it turns off the pump and the salt water chlorine generator, sends an alert to both of our cell phones, and turns on the bedroom and kitchen light if it were to happen at night, it will wake me up and light my way to teh room so I can see what happened.

Hey Guys,

I was surprised this did not exist already. I just set it up and it works well. So Trevor thanks for the code and Tim for the initial ask.

Can you post your code, Tim? Would like to see it.

Thanks again.

This worked perfectly… thank you. I used it to command my Utilitech to command an outlet/plug to be turned off if rain was sensed. The only improvement would be for it to have the option of turning off multiple switches, but I didn’t mind having to create a couple different rules for this.