Compare commits
3 Commits
MSA-2434-1
...
user186_3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e3abd8590 | ||
|
|
73d8f4787e | ||
|
|
f82ff2ba03 |
@@ -18,7 +18,6 @@ metadata {
|
||||
capability "Actuator"
|
||||
capability "Switch"
|
||||
capability "Configuration"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
@@ -167,10 +166,6 @@ def setLevel(value, duration) {
|
||||
zwave.switchMultilevelV2.switchMultilevelSet(value: value, dimmingDuration: dimmingDuration).format()
|
||||
}
|
||||
|
||||
def poll() {
|
||||
zwave.switchMultilevelV1.switchMultilevelGet().format()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
zwave.switchMultilevelV1.switchMultilevelGet().format()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ metadata {
|
||||
capability "Actuator"
|
||||
capability "Switch"
|
||||
capability "Configuration"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
@@ -122,13 +121,6 @@ def off() {
|
||||
])
|
||||
}
|
||||
|
||||
def poll() {
|
||||
delayBetween([
|
||||
zwave.switchBinaryV1.switchBinaryGet().format(),
|
||||
zwave.meterV2.meterGet().format()
|
||||
])
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
zwave.switchBinaryV1.switchBinaryGet().format()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ metadata {
|
||||
capability "Actuator"
|
||||
capability "Indicator"
|
||||
capability "Switch"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
@@ -242,10 +241,6 @@ def setLevel(value, duration) {
|
||||
zwave.switchMultilevelV1.switchMultilevelGet().format()], getStatusDelay)
|
||||
}
|
||||
|
||||
def poll() {
|
||||
zwave.switchMultilevelV1.switchMultilevelGet().format()
|
||||
}
|
||||
|
||||
/**
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
|
||||
@@ -17,7 +17,6 @@ metadata {
|
||||
capability "Actuator"
|
||||
capability "Switch"
|
||||
capability "Power Meter"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Configuration"
|
||||
capability "Sensor"
|
||||
@@ -201,14 +200,6 @@ def off() {
|
||||
]
|
||||
}
|
||||
|
||||
def poll() {
|
||||
delayBetween([
|
||||
zwave.switchBinaryV1.switchBinaryGet().format(),
|
||||
zwave.meterV2.meterGet(scale: 0).format(),
|
||||
zwave.meterV2.meterGet(scale: 2).format()
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
|
||||
@@ -16,7 +16,6 @@ metadata {
|
||||
capability "Actuator"
|
||||
capability "Indicator"
|
||||
capability "Switch"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
@@ -177,13 +176,6 @@ def off() {
|
||||
])
|
||||
}
|
||||
|
||||
def poll() {
|
||||
delayBetween([
|
||||
zwave.switchBinaryV1.switchBinaryGet().format(),
|
||||
zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
**/
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
definition(
|
||||
name: "My First SmartApp",
|
||||
namespace: "mygithubusername",
|
||||
author: "Peter Gregory",
|
||||
description: "This is my first SmartApp. Woot!",
|
||||
category: "My Apps",
|
||||
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("Turn on when motion detected:") {
|
||||
input "themotion", "capability.motionSensor", required: true, title: "Where?"
|
||||
}
|
||||
section("Turn off when there's been no movement for") {
|
||||
input "minutes", "number", required: true, title: "Minutes?"
|
||||
}
|
||||
section("Turn on this light") {
|
||||
input "theswitch", "capability.switch", required: true
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
subscribe(themotion, "motion.active", motionDetectedHandler)
|
||||
subscribe(themotion, "motion.inactive", motionStoppedHandler)
|
||||
}
|
||||
|
||||
def motionDetectedHandler(evt) {
|
||||
log.debug "motionDetectedHandler called: $evt"
|
||||
theswitch.on()
|
||||
}
|
||||
|
||||
def motionStoppedHandler(evt) {
|
||||
log.debug "motionStoppedHandler called: $evt"
|
||||
runIn(60 * minutes, checkMotion)
|
||||
}
|
||||
|
||||
def checkMotion() {
|
||||
log.debug "In checkMotion scheduled method"
|
||||
|
||||
def motionState = themotion.currentState("motion")
|
||||
|
||||
if (motionState.value == "inactive") {
|
||||
// get the time elapsed between now and when the motion reported inactive
|
||||
def elapsed = now() - motionState.date.time
|
||||
|
||||
// elapsed time is in milliseconds, so the threshold must be converted to milliseconds too
|
||||
def threshold = 1000 * 60 * minutes
|
||||
|
||||
if (elapsed >= threshold) {
|
||||
log.debug "Motion has stayed inactive long enough since last check ($elapsed ms): turning switch off"
|
||||
theswitch.off()
|
||||
} else {
|
||||
log.debug "Motion has not stayed inactive long enough since last check ($elapsed ms): doing nothing"
|
||||
}
|
||||
} else {
|
||||
// Motion active; just log it and do nothing
|
||||
log.debug "Motion is active, do nothing and wait for inactive"
|
||||
}
|
||||
}
|
||||
121
smartapps/smartthings/thermostats.src/thermostats.groovy
Normal file
121
smartapps/smartthings/thermostats.src/thermostats.groovy
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* Copyright 2017 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.
|
||||
*
|
||||
* Thermostats
|
||||
*
|
||||
* Author: Juan Pablo Risso
|
||||
* Date: 2017-12-05
|
||||
*
|
||||
*/
|
||||
|
||||
definition(
|
||||
name: "Thermostats",
|
||||
namespace: "smartthings",
|
||||
author: "SmartThings",
|
||||
description: "Receive notifications when anything happens in your home.",
|
||||
category: "SmartSolutions",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/SafetyAndSecurity/Cat-SafetyAndSecurity.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/SafetyAndSecurity/Cat-SafetyAndSecurity@2x.png",
|
||||
singleInstance: true
|
||||
)
|
||||
|
||||
preferences {
|
||||
section("Choose one or more, when..."){
|
||||
input "smokeDevices", "capability.smokeDetector", title: "Smoke Detected", required: false, multiple: true
|
||||
input "carbonMonoxideDevices", "capability.carbonMonoxideDetector", title: "Carbon Monoxide Detected", required: false, multiple: true
|
||||
}
|
||||
section("Turn off these thermostats"){
|
||||
input "thermostatDevices", "capability.thermostat", title: "Thermostats", required: true, multiple: true
|
||||
}
|
||||
section("Send this message (optional, sends standard status message if not specified)"){
|
||||
input "messageText", "text", title: "Message Text", required: false
|
||||
}
|
||||
section("Via a push notification and/or an SMS message"){
|
||||
input("recipients", "contact", title: "Send notifications to") {
|
||||
input "phone", "phone", title: "Enter a phone number to get SMS", required: false
|
||||
paragraph "If outside the US please make sure to enter the proper country code"
|
||||
input "pushAndPhone", "enum", title: "Notify me via Push Notification", required: false, options: ["Yes", "No"]
|
||||
}
|
||||
}
|
||||
section("Minimum time between messages (optional, defaults to every message)") {
|
||||
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(smokeDevices, "smoke.detected", eventHandler)
|
||||
subscribe(smokeDevices, "smoke.tested", eventHandler)
|
||||
subscribe(smokeDevices, "carbonMonoxide.detected", eventHandler)
|
||||
subscribe(carbonMonoxideDevices, "carbonMonoxide.detected", eventHandler)
|
||||
}
|
||||
|
||||
def eventHandler(evt) {
|
||||
log.debug "Notify got evt ${evt}"
|
||||
// Turn off thermostat
|
||||
thermostatDevices*.setThermostatMode("off")
|
||||
if (frequency) {
|
||||
def lastTime = state[evt.deviceId]
|
||||
if (lastTime == null || now() - lastTime >= frequency * 60000) {
|
||||
sendMessage(evt)
|
||||
}
|
||||
}
|
||||
else {
|
||||
sendMessage(evt)
|
||||
}
|
||||
}
|
||||
|
||||
private sendMessage(evt) {
|
||||
String msg = messageText
|
||||
Map options = [:]
|
||||
|
||||
if (!messageText) {
|
||||
msg = '{{ triggerEvent.descriptionText }}'
|
||||
options = [translatable: true, triggerEvent: evt]
|
||||
}
|
||||
log.debug "$evt.name:$evt.value, pushAndPhone:$pushAndPhone, '$msg'"
|
||||
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts(msg, recipients, options)
|
||||
} else {
|
||||
if (phone) {
|
||||
options.phone = phone
|
||||
if (pushAndPhone != 'No') {
|
||||
log.debug 'Sending push and SMS'
|
||||
options.method = 'both'
|
||||
} else {
|
||||
log.debug 'Sending SMS'
|
||||
options.method = 'phone'
|
||||
}
|
||||
} else if (pushAndPhone != 'No') {
|
||||
log.debug 'Sending push'
|
||||
options.method = 'push'
|
||||
} else {
|
||||
log.debug 'Sending nothing'
|
||||
options.method = 'none'
|
||||
}
|
||||
sendNotification(msg, options)
|
||||
}
|
||||
if (frequency) {
|
||||
state[evt.deviceId] = now()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user