SmartThings Community

Simulated device script for Water Leak Sensor

#1

I am trying to create a device handler that will trigger a simulated contact sensor when a water leak sensor is “wet” so that Alexa can alert. There are a few scripts on here that do not have any comments with the code explaining what variables need to change and the authors are unwilling to elaborate. Any help is much appreciated.

0 Likes

(Glen King) #2

Here’s what I do. I use a water sensor to determine whether my hot tub is sufficiently filled with water. The piston goes like this:
IF
sensor’s ‘water’ changes to wet
Then
With ‘sim bath’ (my simulated sensor)
Do ‘close’

And when that simulated sensor closes, my announcement on Echo Speaks says “your bath is ready. Please turn off the water.”

0 Likes

#3

Most people wouldn’t try to work this into the device type handler. They would just let the water leak sensor report as normal and then use any of the official features to have that water sensor reporting turn on a virtual contact sensor. And then have that virtual contact sensor trigger the Echo routine.

It depends whether you are using the new app or the classic app, but if you are using the new app you can use the custom automation creator. If you are using the classic app you can use the custom option under smart home monitor.

The trick to this is that when you create the virtual contact sensor, you also give it the capability “switch.“ that will then allow it to be turned on and off like a switch but still appear to be a sensor which is opened or closed.

There’s a community FAQ on this process which includes the code for sensor of this type. The topic title is a clickable link.

But in general when you want to have one device mirror another one, virtual or not, you do that through an automation, not through a device type handler. You just have two separate devices as always, and you have the action on one be the “if” And then changing the status of the other device be the “that.”

0 Likes

(Todd M) #4

I know that you specifically asked about an Alexa alert. But my SmartThings water leak sensor sends an alert to my phone (and any other number you provide) that is configured through Smart Home Monitor.

Otherwise, I would read through here.

1 Like

#5

Based on your comment in another thread, it appears that no one has ever given you the link to the FAQ on using custom code. Read that, and hopefully it will help clear up the confusion.

0 Likes

#6

I tried the automation before looking on the forum but the simulated contact sensor does not show up. It seems like the problem may be that I am unable to find an option to add “switch capability”. Where is this located?

0 Likes

#7

It’s not an option, you just have to use a device type handler that has that capability as well as the sensor capability. There is a device type handler of this kind of already included in the Echo Routines FAQ, you just follow the instructions In the custom code FAQ to copy it to your own account.

0 Likes

#8

Also, when you read the echo routines FAQ, there is a link to the wiki (so the information won’t go out of date) with seven steps that you have to follow in that exact order or the devices don’t show up on your Amazon account. So that might also be the problem.

0 Likes

#9

Thanks for your help. I used contact sensor script and also tried the momentary button script and the virtual contact sensor still won’t show up in automation. It seems from the FAQ that this only works in the UK or USA for some odd reason.

0 Likes

#10

That’s true. It is dependent on where Amazon has turned on the feature. So you should write to them if you are in a different part of the world and ask them when they will bring the feature to that area.

0 Likes