The device hanlder JD linked you to should be exposed as a switch in smart lighting. So create a device using that handler and then create a smart lighting rule to turn on that device when moisture is detected by your leak sensor.
Ok ive done that and its setup using the smartlighting app and it switches on when the leak sensor detects water.
Now its a switch though rather than contact sensor alexa wont allow me to use this within a routine. ill go the my alexa app it discovers it as a switch but if i go to routines and try and create one it will only allow me to select a sensor device (motion/contact) not a switch
It should show as both. you’re using the device handler with namespace: “bjpierron” right?
Doh! No wonder i couldn’t get it working. I was using the wrong device handler all along.
It now works a treat. Thanks alot guys.
interesting topic. I’m having trouble with trying to add the dth. should I copy the whole code and then click the from code tab in the IDE. because when I do that and click create, I get an error message saying something about error on line 36
There are almost no explanatory comments in the script. Besides copying and pasting it into the device handler what else needs to be done?
The following FAQ explains how to use custom code in smartthings. It should give you all the details that you need.
Maybe I’m very stupid, or something changed recently, I don’t want to blame anyone here, but today, I can clearly see the DHT has been published by BJPierron in Post 95, NOT Post 97. I was simply pooling my hair out to find the link for the code in post 97. Yes, I know, post 95 was just 2 posts upper, but just for the sake of accuracy…
Please correct if I’m wrong, but my browser shows today the DHT in post 95. Should I always subtract 2 from the post #
It’s still in post 97.
The counter on the right of the screen has to do with whereever your cursor last had focus. But if you click on the date in the upper right of the post you can see the exact number of it.
Thanks a lot for your fast answer. It was quite helpful for someone like me who’s new to this forum.
Now grace to you, I understand how to check the post#.
I could have sword the counter that shows at the right of the page when scrolling is the post #. Damn it.
Thanks a lot to JDRoberts for his excellent input in this thread.
Because I’m new to ST, and I had to start from scratch in my understanding of how ST works, I was overwhelmed by the quantity of information that I had to read, and to test and to read… again.
That’s why I wrote a step by step procedure for creating an Alexa announcement when a water leak happens triggered by the Samsung Water Leak Sensor when it becomes wet. I hope this will help other people to spend less time than me in understanding how ST works with Alexa and Routines.
0. Install your ST hub and ST (Samsung Connect) then add the Water Leak Sensor device
- Create and account and login here: https://graph.api.smartthings.com/
- Click My Locations / Home, then click My Devices and make sure the Water Leak Sensor is listed
- Look above in this thread, in post #2, there is a link for FAQs. Go to Post97 to find the DHT Code
- Copy the DHT code in your clipboard
- Click My Device Handlers. Click Create New Device Handler, Click From Code
- In this window paste the code that you copied previously, and click Create then click Publish for You
- In My Devices click New Device, the fill up as follows:
Click My Devices / Click the New Device Button
Enter a Name for the device, whatever you want.
Enter a Label for the device, this is optional and can be whatever you want
Enter a Device Network Id - can be anything you want (keep it short)
Zigbee Id should be left blank
Type: from the drop down, at the bottom of the list select Alexa Switch (the DHT you created previously)
Version should be published
Location should be your hub location, probably Home
Hub should be your hub name
Group you won’t be able to select when creating, but these are Groups you’ve created in the Things page in the SmartThings app.
- Now you have a Virtual On/Off Switch in Things, that can be recognized by Alexa. This virtual switch will be triggered by the Water Leak Sensor. In order to do this create an Automation as follows:
- Open the ST (Samsung Connect) / Automations / + (to add) / click Smart Lights / New
- Which device you want to control? Select the Virtual Switch you created at 7.
- What to do Turn On (by default the virtual switch is off when there is no leak)
- Select Trigger: Water Leak
- Select detector: Water Leak Sensor
- Turn on when Wet
This automation will set the virtual SW on
Now you have to create as well another automation that will reset the virtual SW to the Off position when the Leak Sensor becomes Dry again. (if you don’t do this the virtual SW will remain always On)
Proceed similarly to above to create the Automation for resetting the virtual SW but this time select Turn Off when Leak Sensor Dry
Now let’s open Alexa / Find Devices. Alexa will find the Virtual Switch that you created at 7, BUT It will not discover the physical Water Leak Sensor. That’s why we did all this long and boring procedure.
The Virtual SW should be seen by Alexa in the Off position
Open Routines, Create Routine
When it happens + / Device / Select the Virtual SW / Click Open / Next
Add Action Messaging / Send Announcement / Enter Announcement
Alert, Water Leak in the Laundry Room, Alert, Water Leak in the Laundry Room, etc.
Save the Routine
Now go and put your tong on the water leak sensor contacts.
This will trigger the water leak sensor to Wet, this will turn On the virtual SW, and trigger the Alexa Announcement.
That’s it. I have tested this is it worked just fine (not from the first try of course)
I hope this will help other people to work and search less do other automations with Alexa, eventually with door contacts where similarly you can annonce when a garage door is opened, etc.
For those of you who noticed that I did something wrong, or an extra useless step let me know please.
I want to keep learning from my mistakes.
P.S. The worse problems I encountered in my struggle to implement this was the Smartthings (Samsung Connect) app that crashed on me numerous times, pissing me off.
Smartthings (Samsung Connect) is still not able to detect the state of the Virtual switch (on or off). If I click on the virtual it sais cannot connect to device
The ST Classic app is capable to see the state, and even Alexa devices is capable
Too bad such a nice community of people to have such a bad tool to work with.
Hey all, I just got my ST today and it’s pretty great. I wanted to share my experience after reading the first couple of posts here. I found that final post with a nice walkthrough after, but I had issues following it, so I thought i’d comment.
In my ST app, i couldn’t select smart lights, my app just spins forever until i force close it. Instead, i created a custom automation. If my water leak sensor (physical) is wet, it will set the water detected state to on. (i created the reverse also)
I discovered the new device with alexa. It is seen as type “Switch,” but I changed it to light. Once i did this, i was able to create my routine and set the announcement. I set the sensor on a moist washcloth and my alexas immediately let me know there was a leak.
Thanks all! I suppose I’ll need to make more of these devices under the same handler to cover my water leak sensors in other places. I’m pretty excited because I found that ST picks up my ecobee temp sensors as motion sensors. So i’m using direct ecobee-alexa for temperate and i’m going to try these custom devices to leverage the motion capabilities ST picked up.
Anyway, I hope my experience helps someone else if they struggle with step 9 of Titus’ guide. I honestly wish i had scrolled all the way down as it likely would’ve saved me some time, but I think i learned more by reading so much
I’ve tried all the steps listed in posts 28 & 29 but I’m having trouble with Alexa seeing the new device after “routine> when this happens> + device”. It just doesn’t show up. Have discovered it as a new device and can change it from light to switch and vice verse. It can even be controlled as the “Alexa will” action just not the trigger. Any thoughts?
I recently purchased 15 water leak sensors. As expected, per this thread, Alexa does not see the devices. Is there anything new on this front? Will I still need to create a virtual switch for all 15 sensors?
This works perfectly. I just picked up a SmartThings V3 hub off Amazon after Wink announced they were moving to a subscription based model. I’ve been playing around with custom device handlers on the API web page and have had success implementing Insteon device control, something the Wink could never do. Anyway, I have leak sensor in my sump pump pit to detect if water reaches a certain level. I used the device handler for a SmartThings virtual switch mentioned in this thread and simply have SmartThings activate the virtual switch based of the real water sensor state using Automations in the NEW SmartThings app. Alexa can see the virtual switch which I added to an Alexa routine to send a Push notification to my phone and announce on all Alexa devices “Sump Pump Water Level High!” Thanks to those folks who contribute to this community!
I just wanted to share that you MUST disable and re-enable the Alexa skill for SmartThings after you add a new virtual switch. I spent too long troubleshooting this only to miss this key step. Everything responded as it should except the routine wouldn’t play. After the disable/re-enable it all worked!
Thanks to everyone for their efforts and time to explain and list out the directions.
Hopefully someone sees this and it saves them some time.
Am a techy but a bit of a newbie setting up smart home stuff and having some difficulty in getting the Water Leak Sensor Alexa alert set up. I’m in the UK if that makes any difference to the options & settings I’m likely to see in the Alexa app.
I’ve worked my way through Titus’ step by step article but, when going into the Alexa routines ‘When it happens’ option, I don’t see anything but Voice, Schedule, Smart Home, Alarms, Echo Button & Sound Detection so what am I missing or not seeing? Are the options/settings used in the “how to” based on the US version of the Alexa app?
I’ve done this using a virtual switch. Here is my instructional video which will show how I did this setup. I hope this is helpful. ~ Bud
Many thanks Bud, 3 sensors all up & running with Alexa vocal alerts
Great! Glad I could help