mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-28 21:04:16 +00:00
Compare commits
2 Commits
PROD_2017.
...
MSA-1817-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f140fe0d29 | ||
|
|
65ae2c0ddf |
@@ -9,7 +9,7 @@ apply plugin: 'smartthings-slack'
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.11"
|
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.8"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ metadata {
|
|||||||
capability "Tamper Alert"
|
capability "Tamper Alert"
|
||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
capability "Water Sensor"
|
capability "Water Sensor"
|
||||||
capability "Health Check"
|
|
||||||
|
|
||||||
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x22, 0x85, 0x59, 0x20, 0x80, 0x70, 0x56, 0x5A, 0x7A, 0x72, 0x8E, 0x71, 0x73, 0x98, 0x9C, 0x31, 0x86", outClusters: ""
|
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x22, 0x85, 0x59, 0x20, 0x80, 0x70, 0x56, 0x5A, 0x7A, 0x72, 0x8E, 0x71, 0x73, 0x98, 0x9C, 0x31, 0x86", outClusters: ""
|
||||||
}
|
}
|
||||||
@@ -229,8 +228,6 @@ def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLoca
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Executing 'configure'"
|
log.debug "Executing 'configure'"
|
||||||
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ metadata {
|
|||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Tamper Alert"
|
capability "Tamper Alert"
|
||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
capability "Health Check"
|
|
||||||
|
|
||||||
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x20, 0x86, 0x72, 0x5A, 0x59, 0x85, 0x73, 0x84, 0x80, 0x71, 0x56, 0x70, 0x31, 0x8E, 0x22, 0x30, 0x9C, 0x98, 0x7A", outClusters: ""
|
fingerprint deviceId: "0x0701", inClusters: "0x5E, 0x20, 0x86, 0x72, 0x5A, 0x59, 0x85, 0x73, 0x84, 0x80, 0x71, 0x56, 0x70, 0x31, 0x8E, 0x22, 0x30, 0x9C, 0x98, 0x7A", outClusters: ""
|
||||||
}
|
}
|
||||||
@@ -241,8 +240,6 @@ def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLoca
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Executing 'configure'"
|
log.debug "Executing 'configure'"
|
||||||
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ metadata {
|
|||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
capability "Configuration"
|
capability "Configuration"
|
||||||
capability "Battery"
|
capability "Battery"
|
||||||
capability "Health Check"
|
|
||||||
|
|
||||||
command "resetParams2StDefaults"
|
command "resetParams2StDefaults"
|
||||||
command "listCurrentParams"
|
command "listCurrentParams"
|
||||||
@@ -305,9 +304,6 @@ def lateConfigure(setConf = False) {
|
|||||||
*/
|
*/
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Device..."
|
log.debug "Configuring Device..."
|
||||||
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
// send associate to group 2 to get alarm data
|
// send associate to group 2 to get alarm data
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
capability "Illuminance Measurement"
|
capability "Illuminance Measurement"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Battery"
|
capability "Battery"
|
||||||
capability "Health Check"
|
|
||||||
|
|
||||||
command "resetParams2StDefaults"
|
command "resetParams2StDefaults"
|
||||||
command "listCurrentParams"
|
command "listCurrentParams"
|
||||||
@@ -126,9 +125,6 @@
|
|||||||
*/
|
*/
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Device For SmartThings Use"
|
log.debug "Configuring Device For SmartThings Use"
|
||||||
// Device-Watch simply pings if no device events received for 8 hrs & 2 minutes
|
|
||||||
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
// send associate to group 3 to get sensor data reported only to hub
|
// send associate to group 3 to get sensor data reported only to hub
|
||||||
|
|||||||
@@ -81,32 +81,38 @@ def getInputs() {
|
|||||||
//API external Endpoints
|
//API external Endpoints
|
||||||
mappings {
|
mappings {
|
||||||
path("/subscriptionURL/:url") {
|
path("/subscriptionURL/:url") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
PUT: "updateEndpointURL"
|
PUT: "updateEndpointURL"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/connectionId/:connId") {
|
path("/connectionId/:connId") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
PUT: "updateConnectionId"
|
PUT: "updateConnectionId"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/devices") {
|
path("/devices") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
GET: "getDevices"
|
GET: "getDevices"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/devices/:id") {
|
path("/devices/:id") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
GET: "getDevice"
|
GET: "getDevice"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/update/:id") {
|
path("/update/:id") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
PUT: "updateDevice"
|
PUT: "updateDevice"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/subscription/:id") {
|
path("/subscription/:id") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
POST : "registerDeviceChange",
|
POST : "registerDeviceChange",
|
||||||
DELETE: "unregisterDeviceChange"
|
DELETE: "unregisterDeviceChange"
|
||||||
]
|
]
|
||||||
@@ -180,20 +186,16 @@ def eventHandler(evt) {
|
|||||||
def evt_name = evt.name
|
def evt_name = evt.name
|
||||||
def evt_device = evt.device
|
def evt_device = evt.device
|
||||||
def evt_deviceType = getDeviceType(evt_device);
|
def evt_deviceType = getDeviceType(evt_device);
|
||||||
def deviceInfo
|
|
||||||
|
|
||||||
if(evt_deviceType == "thermostat")
|
|
||||||
{
|
|
||||||
deviceInfo = [name: evt_device.displayName, id: evt_device.id, status:evt_device.getStatus(), deviceType:evt_deviceType, manufacturer:evt_device.getManufacturerName(), model:evt_device.getModelName(), attributes: deviceAttributeList(evt_device), locationMode: getLocationModeInfo()]
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
deviceInfo = [name: evt_device.displayName, id: evt_device.id, status:evt_device.getStatus(), deviceType:evt_deviceType, manufacturer:evt_device.getManufacturerName(), model:evt_device.getModelName(), attributes: deviceAttributeList(evt_device)]
|
|
||||||
}
|
|
||||||
|
|
||||||
def params = [
|
def params = [
|
||||||
uri : "${state.endpointURL}/${state.connectionId}",
|
uri : "${state.endpointURL}/${state.connectionId}",
|
||||||
body: [ deviceInfo ]
|
body: [
|
||||||
|
name : evt_device.displayName,
|
||||||
|
id : evt_device.id,
|
||||||
|
deviceType : evt_deviceType,
|
||||||
|
manufacturer: evt_device.getManufacturerName(),
|
||||||
|
model : evt_device.getModelName(),
|
||||||
|
attributes : deviceAttributeList(evt_device)
|
||||||
|
]
|
||||||
]
|
]
|
||||||
try {
|
try {
|
||||||
log.trace "POST URI: ${params.uri}"
|
log.trace "POST URI: ${params.uri}"
|
||||||
@@ -228,13 +230,10 @@ def getDevices() {
|
|||||||
def deviceData = []
|
def deviceData = []
|
||||||
inputs?.each {
|
inputs?.each {
|
||||||
def deviceType = getDeviceType(it)
|
def deviceType = getDeviceType(it)
|
||||||
if(deviceType == "thermostat")
|
if (deviceType == "thermostat") {
|
||||||
{
|
deviceData << [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
} else {
|
||||||
}
|
deviceData << [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)]
|
||||||
else
|
|
||||||
{
|
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it)]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,13 +246,10 @@ def getDevice() {
|
|||||||
def it = findDevice(params.id)
|
def it = findDevice(params.id)
|
||||||
def deviceType = getDeviceType(it)
|
def deviceType = getDeviceType(it)
|
||||||
def device
|
def device
|
||||||
if(deviceType == "thermostat")
|
if (deviceType == "thermostat") {
|
||||||
{
|
device = [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
||||||
device = [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
} else {
|
||||||
}
|
device = [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)]
|
||||||
else
|
|
||||||
{
|
|
||||||
device = [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it)]
|
|
||||||
}
|
}
|
||||||
log.debug "getDevice, return: ${device}"
|
log.debug "getDevice, return: ${device}"
|
||||||
return device
|
return device
|
||||||
@@ -326,28 +322,19 @@ private getLocationModeInfo() {
|
|||||||
//Map each device to a type given it's capabilities
|
//Map each device to a type given it's capabilities
|
||||||
private getDeviceType(device) {
|
private getDeviceType(device) {
|
||||||
def deviceType
|
def deviceType
|
||||||
def capabilities = device.capabilities
|
def caps = device.capabilities
|
||||||
log.debug "capabilities: [${device}, ${capabilities}]"
|
log.debug "capabilities: [${device}, ${caps}]"
|
||||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
||||||
|
caps.each {
|
||||||
//Loop through the device capability list to determine the device type.
|
switch (it.name.toLowerCase()) {
|
||||||
capabilities.each {capability ->
|
|
||||||
switch(capability.name.toLowerCase())
|
|
||||||
{
|
|
||||||
case "switch":
|
case "switch":
|
||||||
deviceType = "switch"
|
deviceType = "switch"
|
||||||
|
if (caps.any { it.name.toLowerCase() == "power meter" }) {
|
||||||
//If the device also contains "Switch Level" capability, identify it as a "light" device.
|
|
||||||
if (capabilities.any{it.name.toLowerCase() == "switch level"}){
|
|
||||||
|
|
||||||
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
|
|
||||||
if (capabilities.any{it.name.toLowerCase() == "power meter"}){
|
|
||||||
deviceType = "dimmerSwitch"
|
|
||||||
return deviceType
|
|
||||||
} else {
|
|
||||||
deviceType = "light"
|
|
||||||
return deviceType
|
return deviceType
|
||||||
}
|
}
|
||||||
|
if (caps.any { it.name.toLowerCase() == "switch level" }) {
|
||||||
|
deviceType = "light"
|
||||||
|
return deviceType
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "contact sensor":
|
case "contact sensor":
|
||||||
@@ -427,7 +414,7 @@ private mapDeviceCommands(command, value) {
|
|||||||
resultCommand = "setSaturation"
|
resultCommand = "setSaturation"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
case "colorTemperature":
|
case "ct":
|
||||||
resultCommand = "setColorTemperature"
|
resultCommand = "setColorTemperature"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
@@ -464,8 +451,7 @@ private mapDeviceCommands(command, value) {
|
|||||||
if (value == 1 || value == "1" || value == "lock") {
|
if (value == 1 || value == "1" || value == "lock") {
|
||||||
resultCommand = "lock"
|
resultCommand = "lock"
|
||||||
resultValue = ""
|
resultValue = ""
|
||||||
}
|
} else if (value == 0 || value == "0" || value == "unlock") {
|
||||||
else if (value == 0 || value == "0" || value == "unlock") {
|
|
||||||
resultCommand = "unlock"
|
resultCommand = "unlock"
|
||||||
resultValue = ""
|
resultValue = ""
|
||||||
}
|
}
|
||||||
@@ -476,3 +462,4 @@ private mapDeviceCommands(command, value) {
|
|||||||
|
|
||||||
return [resultCommand, resultValue]
|
return [resultCommand, resultValue]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
82
smartapps/teapps/turn-off.src/turn-off.groovy
Normal file
82
smartapps/teapps/turn-off.src/turn-off.groovy
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* Turn Off
|
||||||
|
*
|
||||||
|
* Copyright 2017 Trevor
|
||||||
|
*
|
||||||
|
* 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: "Turn Off",
|
||||||
|
namespace: "TEAPPS",
|
||||||
|
author: "Trevor",
|
||||||
|
description: "Turn off a light after its been turned on.",
|
||||||
|
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("Lights") {
|
||||||
|
input "lights", "capability.switch", required: true, title: "Which lights to turn off after being turned on?", multiple: true
|
||||||
|
input "offsetHours", "number", title: "How long until the light is turned off (hours)?"
|
||||||
|
input "offsetMinutes", "number", title: "How long until the light is turned off (minutes)?"
|
||||||
|
input "offsetSeconds", "number", title: "How long until the light is turned off (seconds)?"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
log.debug "Installed with settings: ${settings}"
|
||||||
|
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
log.debug "Updated with settings: ${settings}"
|
||||||
|
|
||||||
|
unsubscribe()
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
|
// TODO: subscribe to attributes, devices, locations, etc.
|
||||||
|
|
||||||
|
//Subscribe to the light device being turned on
|
||||||
|
subscribe(lights, "switch.on", lightHandler)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: implement event handlers
|
||||||
|
def lightHandler(evt) {
|
||||||
|
|
||||||
|
if("on" == evt.value)
|
||||||
|
//Light was turned on
|
||||||
|
log.debug "Light is in ${evt.value} state"
|
||||||
|
|
||||||
|
//Get the date and time
|
||||||
|
def currentTime = new Date()
|
||||||
|
|
||||||
|
//Calculate the offset
|
||||||
|
def timeToTurnOff = new Date(currentTime.time + (offsetHours * 60 * 60 * 1000) + (offsetMinutes * 60 * 1000) + (offsetSeconds * 1000))
|
||||||
|
|
||||||
|
log.debug "Scheduling for: $timeToTurnOff"
|
||||||
|
|
||||||
|
//Schedule this to run one time
|
||||||
|
runOnce(timeToTurnOff, turnOff)
|
||||||
|
}
|
||||||
|
|
||||||
|
def turnOff() {
|
||||||
|
log.debug "turning off lights"
|
||||||
|
lights.off()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user