2 * Send HAM Bridge Command When…
4 * For more information about HAM Bridge please visit http://solutionsetcetera.com/HAMBridge/
6 * Copyright 2014 Scottin Pollock
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at:
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
14 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
15 * for the specific language governing permissions and limitations under the License.
19 name: "Send HAM Bridge Command When",
20 namespace: "smartthings",
21 author: "Scottin Pollock",
22 description: "Sends a command to your HAM Bridge server when SmartThings are activated.",
23 category: "Convenience",
24 iconUrl: "http://solutionsetcetera.com/stuff/STIcons/HB.png",
25 iconX2Url: "http://solutionsetcetera.com/stuff/STIcons/HB@2x.png"
29 section("Choose one or more, when..."){
30 input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
31 input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
32 input "contactClosed", "capability.contactSensor", title: "Contact Closes", required: false, multiple: true
33 input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
34 input "mySwitch", "capability.switch", title: "Switch Turned On", required: false, multiple: true
35 input "mySwitchOff", "capability.switch", title: "Switch Turned Off", required: false, multiple: true
36 input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true
37 input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true
38 input "smoke", "capability.smokeDetector", title: "Smoke Detected", required: false, multiple: true
39 input "water", "capability.waterSensor", title: "Water Sensor Wet", required: false, multiple: true
41 section("Send this command to HAM Bridge"){
42 input "HAMBcommand", "text", title: "Command to send", required: true
44 section("Server address and port number"){
45 input "server", "text", title: "Server IP", description: "Your HAM Bridger Server IP", required: true
46 input "port", "number", title: "Port", description: "Port Number", required: true
51 log.debug "Installed with settings: ${settings}"
56 log.debug "Updated with settings: ${settings}"
61 def subscribeToEvents() {
62 subscribe(contact, "contact.open", eventHandler)
63 subscribe(contactClosed, "contact.closed", eventHandler)
64 subscribe(acceleration, "acceleration.active", eventHandler)
65 subscribe(motion, "motion.active", eventHandler)
66 subscribe(mySwitch, "switch.on", eventHandler)
67 subscribe(mySwitchOff, "switch.off", eventHandler)
68 subscribe(arrivalPresence, "presence.present", eventHandler)
69 subscribe(departurePresence, "presence.not present", eventHandler)
70 subscribe(smoke, "smoke.detected", eventHandler)
71 subscribe(smoke, "smoke.tested", eventHandler)
72 subscribe(smoke, "carbonMonoxide.detected", eventHandler)
73 subscribe(water, "water.wet", eventHandler)
76 def eventHandler(evt) {
81 def ip = "${settings.server}:${settings.port}"
82 def deviceNetworkId = "1234"
83 sendHubCommand(new physicalgraph.device.HubAction("""GET /?${settings.HAMBcommand} HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))