SmartThings Community

Water leak sensor with alexa routine?

(Jamie Ashby) #21

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.

1 Like

(Phillip) #22

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

0 Likes

#23

There are almost no explanatory comments in the script. Besides copying and pasting it into the device handler what else needs to be done?

0 Likes

#24

The following FAQ explains how to use custom code in smartthings. It should give you all the details that you need.

0 Likes

(Titus Tucan) #26

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 # :grinning:

0 Likes

#27

It’s still in post 97.

Using Contact and Motion Sensors to Trigger Alexa Routines (DTH in post 97) (Official Amazon Feature)

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.

0 Likes

(Titus Tucan) #28

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 again…

1 Like

(Titus Tucan) #29

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

  1. Create and account and login here: https://graph.api.smartthings.com/
  2. Click My Locations / Home, then click My Devices and make sure the Water Leak Sensor is listed
  3. Look above in this thread, in post #2, there is a link for FAQs. Go to Post97 to find the DHT Code
  4. Copy the DHT code in your clipboard
  5. Click My Device Handlers. Click Create New Device Handler, Click From Code
  6. In this window paste the code that you copied previously, and click Create then click Publish for You
  7. 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.
    Click Create
  8. 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:
  9. Open the ST (Samsung Connect) / Automations / + (to add) / click Smart Lights / New
  10. Which device you want to control? Select the Virtual Switch you created at 7.
  11. What to do Turn On (by default the virtual switch is off when there is no leak)
  12. Select Trigger: Water Leak
  13. Select detector: Water Leak Sensor
  14. 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 :slight_smile:
    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.

Regards
Titus

0 Likes

#30

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 :slight_smile:

0 Likes