From 33b5564dd1e3a2b2b4fa33204498c422835bc17a Mon Sep 17 00:00:00 2001 From: Omer Ozgur Cetinoglu Date: Sun, 19 Jun 2016 05:35:50 -0500 Subject: [PATCH] MSA-1361: Smartthings presence sensor --- .../beep-when-closed.groovy | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 smartapps/smartthings/beep-when-closed.src/beep-when-closed.groovy diff --git a/smartapps/smartthings/beep-when-closed.src/beep-when-closed.groovy b/smartapps/smartthings/beep-when-closed.src/beep-when-closed.groovy new file mode 100644 index 0000000..99b1a46 --- /dev/null +++ b/smartapps/smartthings/beep-when-closed.src/beep-when-closed.groovy @@ -0,0 +1,34 @@ +definition( + name: "Beep, When Closed", + namespace: "smartthings", + author: "SmartThings", + description: "Beep presence sensor when open/close sensor closes.", + category: "Convenience", + iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", + iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png", +) + +preferences { + section ("When closes...") { + input "contact1", "capability.contactSensor", title: "Which open/contact sensor?" + } + section("Beep the presence sensor..") { + input "presence", "capability.presenceSensor", title: "Which sensor beep?" + } +} + +def installed() +{ + subscribe(contact1, "contact.closed", contactClosedHandler) +} + +def updated() +{ + unsubscribe() + subscribe(contact1, "contact.closed", contactClosedHandler) +} + +def contactClosedHandler(evt) { + + presence.beep() +} \ No newline at end of file