mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 13:21:53 +00:00
Compare commits
12 Commits
MSA-1385-2
...
MSA-1391-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7754e9f93 | ||
|
|
962774996e | ||
|
|
d79594cbcb | ||
|
|
bf8fe4cad7 | ||
|
|
65752ce378 | ||
|
|
95f08aeb3d | ||
|
|
cd7bc1b262 | ||
|
|
be7f6a76a9 | ||
|
|
10e5b7e9d7 | ||
|
|
90e6dc91eb | ||
|
|
3ee8f86aa3 | ||
|
|
d1a910f11f |
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Use Switch to Control Outlets
|
||||
*
|
||||
* Copyright 2016 Mark Vickstrom
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
definition(
|
||||
name: "Use Switch to Control Outlets",
|
||||
namespace: "mdvickst",
|
||||
author: "Mark Vickstrom",
|
||||
description: "Use a Switch to control multiple outlets",
|
||||
category: "Convenience",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
|
||||
|
||||
|
||||
preferences {
|
||||
section("Use this Switch") {
|
||||
input "triggerSwitch", "capability.switch", title: "Which Switch?", required: true
|
||||
}
|
||||
section("To Control these Devices") {
|
||||
input "switchesToControl", "capability.switch", title: "Which Outlets/Switches?", multiple: true, required: true
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
subscribe(triggerSwitch, "switch", triggerSwitchPressed)
|
||||
}
|
||||
|
||||
def triggerSwitchPressed(evt){
|
||||
if (evt.value == "on") {
|
||||
log.debug "swtich pressed On"
|
||||
switchesToControl?.on()
|
||||
} else if (evt.value == "off") {
|
||||
log.debug "swtich pressed Off"
|
||||
switchesToControl?.off()
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* Copyright 2016 SmartThings
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* Beep When
|
||||
*
|
||||
* Author: SmartThings
|
||||
* Date: 2016-06-05
|
||||
*/
|
||||
definition(
|
||||
name: "Beep When",
|
||||
namespace: "smartthings",
|
||||
author: "SmartThings",
|
||||
description: "Beep Presence sensor when anything happens in your home.",
|
||||
category: "Convenience",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/window_contact@2x.png"
|
||||
)
|
||||
|
||||
preferences {
|
||||
section("Choose one or more, when..."){
|
||||
input "button", "capability.button", title: "Button Pushed", required: false, multiple: true //tw
|
||||
input "motion", "capability.motionSensor", title: "Motion Here", required: false, multiple: true
|
||||
input "contact", "capability.contactSensor", title: "Contact Opens", required: false, multiple: true
|
||||
input "contactClosed", "capability.contactSensor", title: "Contact Closes", required: false, multiple: true
|
||||
input "acceleration", "capability.accelerationSensor", title: "Acceleration Detected", required: false, multiple: true
|
||||
input "mySwitch", "capability.switch", title: "Switch Turned On", required: false, multiple: true
|
||||
input "mySwitchOff", "capability.switch", title: "Switch Turned Off", required: false, multiple: true
|
||||
input "arrivalPresence", "capability.presenceSensor", title: "Arrival Of", required: false, multiple: true
|
||||
input "departurePresence", "capability.presenceSensor", title: "Departure Of", required: false, multiple: true
|
||||
input "smoke", "capability.smokeDetector", title: "Smoke Detected", required: false, multiple: true
|
||||
input "water", "capability.waterSensor", title: "Water Sensor Wet", required: false, multiple: true
|
||||
}
|
||||
section("Beep the presence sensor..") {
|
||||
input "presence", "capability.presenceSensor", title: "Which sensor beep?"
|
||||
}
|
||||
|
||||
section("Minimum time between beeps (optional, defaults to every beep)") {
|
||||
input "frequency", "decimal", title: "Minutes", required: false
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
subscribeToEvents()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
unsubscribe()
|
||||
subscribeToEvents()
|
||||
}
|
||||
|
||||
def subscribeToEvents() {
|
||||
subscribe(button, "button.pushed", eventHandler) //tw
|
||||
subscribe(contact, "contact.open", eventHandler)
|
||||
subscribe(contactClosed, "contact.closed", eventHandler)
|
||||
subscribe(acceleration, "acceleration.active", eventHandler)
|
||||
subscribe(motion, "motion.active", eventHandler)
|
||||
subscribe(mySwitch, "switch.on", eventHandler)
|
||||
subscribe(mySwitchOff, "switch.off", eventHandler)
|
||||
subscribe(arrivalPresence, "presence.present", eventHandler)
|
||||
subscribe(departurePresence, "presence.not present", eventHandler)
|
||||
subscribe(smoke, "smoke.detected", eventHandler)
|
||||
subscribe(smoke, "smoke.tested", eventHandler)
|
||||
subscribe(smoke, "carbonMonoxide.detected", eventHandler)
|
||||
subscribe(water, "water.wet", eventHandler)
|
||||
}
|
||||
|
||||
def eventHandler(evt) {
|
||||
log.debug "Notify got evt ${evt}"
|
||||
if (frequency) {
|
||||
def lastTime = state[evt.deviceId]
|
||||
if (lastTime == null || now() - lastTime >= frequency * 60000) {
|
||||
presence.beep() }
|
||||
}
|
||||
else {
|
||||
presence.beep()
|
||||
}
|
||||
}
|
||||
@@ -823,8 +823,8 @@ def deviceHandler(evt) {
|
||||
}
|
||||
|
||||
def sendToHarmony(evt, String callbackUrl) {
|
||||
def callback = new URI(callbackUrl)
|
||||
if(isIP(callback.host)){
|
||||
def callback = new URI(callbackUrl)
|
||||
if (callback.port != -1) {
|
||||
def host = callback.port != -1 ? "${callback.host}:${callback.port}" : callback.host
|
||||
def path = callback.query ? "${callback.path}?${callback.query}".toString() : callback.path
|
||||
sendHubCommand(new physicalgraph.device.HubAction(
|
||||
@@ -852,25 +852,6 @@ def sendToHarmony(evt, String callbackUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isIP(String str) {
|
||||
try {
|
||||
String[] parts = str.split("\\.");
|
||||
if (parts.length != 4) return false;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int p
|
||||
try {
|
||||
p = Integer.parseInt(parts[i]);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
if (p > 255 || p < 0) return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
def listHubs() {
|
||||
location.hubs?.findAll { it.type.toString() == "PHYSICAL" }?.collect { hubItem(it) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user