mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-19 21:03:46 +00:00
Compare commits
1 Commits
MSA-2032-1
...
PROD_2017.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4c2a3ffd7 |
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bose SoundTouch
|
* Bose SoundTouch
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -108,20 +108,11 @@ def updated(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x26: 1, // SwitchMultilevel
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x70: 1, // Configuration
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
if (description != "updated") {
|
if (description != "updated") {
|
||||||
log.debug "parse() >> zwave.parse($description)"
|
log.debug "parse() >> zwave.parse($description)"
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x26: 1, 0x70: 1])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = zwaveEvent(cmd)
|
result = zwaveEvent(cmd)
|
||||||
}
|
}
|
||||||
@@ -188,16 +179,6 @@ def zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelS
|
|||||||
[createEvent(name:"switch", value:"on"), response(zwave.switchMultilevelV1.switchMultilevelGet().format())]
|
[createEvent(name:"switch", value:"on"), response(zwave.switchMultilevelV1.switchMultilevelGet().format())]
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
[:]
|
[:]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue Bloom
|
* Hue Bloom
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue Bridge
|
* Hue Bridge
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue Bulb
|
* Hue Bulb
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue Lux Bulb
|
* Hue Lux Bulb
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue White Ambiance Bulb
|
* Hue White Ambiance Bulb
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -49,6 +49,6 @@ def arrived() {
|
|||||||
|
|
||||||
|
|
||||||
def departed() {
|
def departed() {
|
||||||
log.trace "Executing 'departed'"
|
log.trace "Executing 'arrived'"
|
||||||
sendEvent(name: "presence", value: "not present")
|
sendEvent(name: "presence", value: "not present")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -66,29 +66,22 @@ def parse(String description) {
|
|||||||
else {
|
else {
|
||||||
sendEvent(event)
|
sendEvent(event)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
def descMap = zigbee.parseDescriptionAsMap(description)
|
else {
|
||||||
if (descMap && descMap.clusterInt == 0x0006 && descMap.commandInt == 0x07) {
|
def cluster = zigbee.parse(description)
|
||||||
if (descMap.data[0] == "00") {
|
|
||||||
|
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
||||||
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
}
|
}
|
||||||
} else if (device.getDataValue("manufacturer") == "sengled" && descMap && descMap.clusterInt == 0x0008 && descMap.attrInt == 0x0000) {
|
}
|
||||||
// This is being done because the sengled element touch/classic incorrectly uses the value 0xFF for the max level.
|
else {
|
||||||
// Per the ZCL spec for the UINT8 data type 0xFF is an invalid value, and 0xFE should be the max. Here we
|
|
||||||
// manually handle the invalid attribute value since it will be ignored by getEvent as an invalid value.
|
|
||||||
// We also set the level of the bulb to 0xFE so future level reports will be 0xFE until it is changed by
|
|
||||||
// something else.
|
|
||||||
if (descMap.value.toUpperCase() == "FF") {
|
|
||||||
descMap.value = "FE"
|
|
||||||
}
|
|
||||||
sendHubCommand(zigbee.command(zigbee.LEVEL_CONTROL_CLUSTER, 0x00, "FE0000").collect { new physicalgraph.device.HubAction(it) }, 0)
|
|
||||||
sendEvent(zigbee.getEventFromAttrData(descMap.clusterInt, descMap.attrInt, descMap.encoding, descMap.value))
|
|
||||||
} else {
|
|
||||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
||||||
log.debug "${descMap}"
|
log.debug "${cluster}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,20 +88,11 @@ def updated(){
|
|||||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x26: 1, // SwitchMultilevel
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x70: 1, // Configuration
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
if (description != "updated") {
|
if (description != "updated") {
|
||||||
log.debug "parse() >> zwave.parse($description)"
|
log.debug "parse() >> zwave.parse($description)"
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x26: 1, 0x70: 1])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = zwaveEvent(cmd)
|
result = zwaveEvent(cmd)
|
||||||
}
|
}
|
||||||
@@ -168,16 +159,6 @@ def zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelS
|
|||||||
[createEvent(name:"switch", value:"on"), response(zwave.switchMultilevelV1.switchMultilevelGet().format())]
|
[createEvent(name:"switch", value:"on"), response(zwave.switchMultilevelV1.switchMultilevelGet().format())]
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
[:]
|
[:]
|
||||||
|
|||||||
@@ -85,21 +85,11 @@ metadata {
|
|||||||
details(["switch", "power", "energy", "levelSliderControl", "refresh", "reset"])
|
details(["switch", "power", "energy", "levelSliderControl", "refresh", "reset"])
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x26: 3, // SwitchMultilevel
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x70: 1, // Configuration
|
|
||||||
0x32: 3, // Meter
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
if (description != "updated") {
|
if (description != "updated") {
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x26: 3, 0x70: 1, 0x32:3])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = zwaveEvent(cmd)
|
result = zwaveEvent(cmd)
|
||||||
log.debug("'$description' parsed to $result")
|
log.debug("'$description' parsed to $result")
|
||||||
@@ -134,21 +124,6 @@ def zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv3.SwitchMultilevelR
|
|||||||
dimmerEvents(cmd)
|
dimmerEvents(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
|
||||||
[:]
|
|
||||||
}
|
|
||||||
|
|
||||||
def dimmerEvents(physicalgraph.zwave.Command cmd) {
|
def dimmerEvents(physicalgraph.zwave.Command cmd) {
|
||||||
def result = []
|
def result = []
|
||||||
def value = (cmd.value ? "on" : "off")
|
def value = (cmd.value ? "on" : "off")
|
||||||
|
|||||||
@@ -89,19 +89,10 @@ def updated() {
|
|||||||
} catch (e) { log.debug e }
|
} catch (e) { log.debug e }
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x32: 1, // SwitchMultilevel
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x72: 2, // ManufacturerSpecific
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
if(description == "updated") return
|
if(description == "updated") return
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x32: 1, 0x72: 2])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = zwaveEvent(cmd)
|
result = zwaveEvent(cmd)
|
||||||
}
|
}
|
||||||
@@ -166,16 +157,6 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
log.debug "$device.displayName: Unhandled: $cmd"
|
log.debug "$device.displayName: Unhandled: $cmd"
|
||||||
[:]
|
[:]
|
||||||
|
|||||||
@@ -71,17 +71,9 @@ def updated(){
|
|||||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x70: 1, // Configuration
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = createEvent(zwaveEvent(cmd))
|
result = createEvent(zwaveEvent(cmd))
|
||||||
}
|
}
|
||||||
@@ -128,15 +120,6 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
|
|||||||
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
|
|||||||
@@ -89,17 +89,9 @@ def updated(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getCommandClassVersions() {
|
|
||||||
[
|
|
||||||
0x20: 1, // Basic
|
|
||||||
0x56: 1, // Crc16Encap
|
|
||||||
0x70: 1, // Configuration
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
def cmd = zwave.parse(description, commandClassVersions)
|
def cmd = zwave.parse(description, [0x20: 1, 0x70: 1])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = createEvent(zwaveEvent(cmd))
|
result = createEvent(zwaveEvent(cmd))
|
||||||
}
|
}
|
||||||
@@ -146,16 +138,6 @@ def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerS
|
|||||||
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd) {
|
|
||||||
def versions = commandClassVersions
|
|
||||||
def version = versions[cmd.commandClass as Integer]
|
|
||||||
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
|
||||||
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
|
||||||
if (encapsulatedCommand) {
|
|
||||||
zwaveEvent(encapsulatedCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
|
|||||||
@@ -1,317 +0,0 @@
|
|||||||
/**
|
|
||||||
* RealApplication_CA
|
|
||||||
*
|
|
||||||
* Copyright 2017 Venkata Kishore Chilakala
|
|
||||||
*
|
|
||||||
* 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: "RealApplication_CA",
|
|
||||||
namespace: "CA",
|
|
||||||
author: "Venkata Kishore Chilakala",
|
|
||||||
description: "myApp",
|
|
||||||
category: "SmartThings Labs",
|
|
||||||
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("Allow External Service to Control These Things...")
|
|
||||||
{
|
|
||||||
|
|
||||||
input "motions", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false
|
|
||||||
input "contacts", "capability.contactSensor",title: "Which Contact Sensor?", multiple: true, required: false
|
|
||||||
input "presences", "capability.presenceSensor",title: "Which Presence Sensor?", multiple: true, required: false
|
|
||||||
input "switches", "capability.switchLevel", title: "Which Switches?", multiple: true, required: false
|
|
||||||
input "levelSwitches","capability.switchLevel",title: "Which Level Switch?",multiple: true, required:false
|
|
||||||
input "relativeHumidity","capability.relativeHumidityMeasurement",title: "Humidity",multiple:true,required:false
|
|
||||||
input "temperature","capability.temperatureMeasurement",title: "Temperature Measurement",multiple:true,required:false
|
|
||||||
input "lock","capability.lock",title: "Door Lock", multiple:true,required:false
|
|
||||||
input "hubs",title: "Hubs",multiple:false,required:false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated() {
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
mappings {
|
|
||||||
|
|
||||||
path("/devices")
|
|
||||||
{
|
|
||||||
action:[
|
|
||||||
GET:"listDevices"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
path("/hubs") {
|
|
||||||
log.debug "list action"
|
|
||||||
action: [
|
|
||||||
GET: "listAll"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
path("/switches") {
|
|
||||||
action: [
|
|
||||||
GET:"listSwitches",
|
|
||||||
PUT:"updateSwitches"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/switches/:id") {
|
|
||||||
action: [
|
|
||||||
GET:"showSwitch",
|
|
||||||
PUT:"updateSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/levelSwitches") {
|
|
||||||
action: [
|
|
||||||
GET:"listLevelSwitches",
|
|
||||||
PUT:"updateLevelSwitches"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/levelSwitches/:id") {
|
|
||||||
action: [
|
|
||||||
GET:"showLevelSwitch",
|
|
||||||
PUT:"updateLevelSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/motions") {
|
|
||||||
|
|
||||||
action: [
|
|
||||||
GET:"listMotions",
|
|
||||||
PUT:"updateMotions"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/motions/:id"){
|
|
||||||
action:[
|
|
||||||
GET:"showMotion",
|
|
||||||
PUT:"updateMotion"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/presences")
|
|
||||||
{
|
|
||||||
action:[
|
|
||||||
GET:"listPresenceSensor",
|
|
||||||
PUT:"updatePresenceSensor"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/presences/:id")
|
|
||||||
{
|
|
||||||
action:[
|
|
||||||
GET:"showPresence",
|
|
||||||
PUT:"updatePresence"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/locks") {
|
|
||||||
action: [
|
|
||||||
GET:"listLocks",
|
|
||||||
PUT:"updateLocks"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
path("/locks/:id") {
|
|
||||||
action: [
|
|
||||||
GET:"showLock",
|
|
||||||
PUT:"updateLock"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/contacts")
|
|
||||||
{
|
|
||||||
action: [
|
|
||||||
GET: "listContacts",
|
|
||||||
PUP: "updateContacts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path ("/contacts/:id")
|
|
||||||
{
|
|
||||||
action:[
|
|
||||||
GET:"showContact",
|
|
||||||
PUT:"updateContact"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def listAll()
|
|
||||||
{
|
|
||||||
[location_id :location.id,hub_id:location.hubs*.id,hub_type:location.hubs*.type,hub_name:location.hubs*.name,hub_firm_ver:location.hubs*.firmwareVersionString,hub_ip:location.hubs*.localIP,hub_port:location.hubs*.localSrvPortTCP]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def listSwitches() {
|
|
||||||
switches.collect { device(it,"switch") }
|
|
||||||
}
|
|
||||||
void updateSwitches() {
|
|
||||||
updateAll(switches)
|
|
||||||
}
|
|
||||||
def showSwitch() {
|
|
||||||
show(switches, "switch")
|
|
||||||
}
|
|
||||||
void updateSwitch() {
|
|
||||||
update(switches)
|
|
||||||
}
|
|
||||||
def listLevelSwitches() {
|
|
||||||
|
|
||||||
levelSwitches.collect { device(it,"level") }
|
|
||||||
// motions.collect { device(it,"motion") }
|
|
||||||
}
|
|
||||||
void updateLevelSwitches() {
|
|
||||||
updateAll(levelSwitches)
|
|
||||||
}
|
|
||||||
def showLevelSwitch() {
|
|
||||||
show(levelSwitches, "level")
|
|
||||||
}
|
|
||||||
void updateLevelSwitch() {
|
|
||||||
update(levelSwitches)
|
|
||||||
}
|
|
||||||
|
|
||||||
def listLocks() {
|
|
||||||
lock.collect { device(it,"lock") }
|
|
||||||
}
|
|
||||||
void updateLocks() {
|
|
||||||
updateAll(lock)
|
|
||||||
}
|
|
||||||
def showLock() {
|
|
||||||
show(lock, "lock")
|
|
||||||
}
|
|
||||||
void updateLock() {
|
|
||||||
update(lock)
|
|
||||||
}
|
|
||||||
|
|
||||||
def listMotions() {
|
|
||||||
motions.collect { device(it,"motion") }
|
|
||||||
}
|
|
||||||
void updateMotions()
|
|
||||||
{
|
|
||||||
updateAll(motions)
|
|
||||||
}
|
|
||||||
def showMotion()
|
|
||||||
{
|
|
||||||
show(motions, "motion")
|
|
||||||
}
|
|
||||||
void updateMotion()
|
|
||||||
{
|
|
||||||
update(motions)
|
|
||||||
}
|
|
||||||
|
|
||||||
def listPresenceSensor()
|
|
||||||
{
|
|
||||||
presences.collect{device(it,"presence")}
|
|
||||||
}
|
|
||||||
void updatePresenceSensor()
|
|
||||||
{
|
|
||||||
updateAll(presences)
|
|
||||||
}
|
|
||||||
def showPresence()
|
|
||||||
{
|
|
||||||
show(presences,"presence")
|
|
||||||
}
|
|
||||||
void updatePresence()
|
|
||||||
{
|
|
||||||
update(presences)
|
|
||||||
}
|
|
||||||
|
|
||||||
def listContacts(){
|
|
||||||
|
|
||||||
contacts.collect{device(it,"contact")}
|
|
||||||
}
|
|
||||||
void updateContacts()
|
|
||||||
{
|
|
||||||
updateAll(contacts)
|
|
||||||
}
|
|
||||||
def showContact()
|
|
||||||
{
|
|
||||||
show(contacts,"contact")
|
|
||||||
}
|
|
||||||
void updateContact()
|
|
||||||
{
|
|
||||||
update(contacts)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private device(it, name) {
|
|
||||||
if (it) {
|
|
||||||
def s = it.currentState(name)
|
|
||||||
[
|
|
||||||
id: it.id,
|
|
||||||
name: it.displayName,
|
|
||||||
label: it.displayName,
|
|
||||||
hub_name: it.hub.name,
|
|
||||||
hub_id: it.hub.id,
|
|
||||||
hub_ip: it.hub.localIP,
|
|
||||||
hub_port: it.hub.localSrvPortTCP,
|
|
||||||
state: s
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void updateAll(devices) {
|
|
||||||
def command = request.JSON?.command
|
|
||||||
if (command) {
|
|
||||||
devices."$command"()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private show(devices, name) {
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.debug " state s :: ${s}"
|
|
||||||
log.debug "devices :: ${devices}"
|
|
||||||
log.debug "name :: ${name}"
|
|
||||||
def s = device.currentState(name)
|
|
||||||
[id: device.id, label: device.displayName, name: device.displayName,state:s]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void update(devices) {
|
|
||||||
log.debug "update, request: ${request.JSON}, params: ${params}, devices: $devices.id"
|
|
||||||
def command = request.JSON?.command
|
|
||||||
def value = request.JSON?.value
|
|
||||||
|
|
||||||
log.debug "$value"
|
|
||||||
log.debug "$command"
|
|
||||||
|
|
||||||
if (command) {
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if("$command"=="on")
|
|
||||||
{
|
|
||||||
device."$command"()
|
|
||||||
}else if("$command"=="off")
|
|
||||||
{
|
|
||||||
device."$command"()
|
|
||||||
}else if("$command"=="lock")
|
|
||||||
{
|
|
||||||
device."$command"()
|
|
||||||
}else if("$command"=="unlock")
|
|
||||||
{
|
|
||||||
device."$command"()
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
device.setLevel("$command")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def initialize() {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bose SoundTouch (Connect)
|
* Bose SoundTouch (Connect)
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hue Service Manager
|
* Hue Service Manager
|
||||||
*
|
*
|
||||||
@@ -1085,6 +1083,7 @@ def on(childDevice) {
|
|||||||
log.debug "Executing 'on'"
|
log.debug "Executing 'on'"
|
||||||
def id = getId(childDevice)
|
def id = getId(childDevice)
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/$id/state", [on: true])
|
put("lights/$id/state", [on: true])
|
||||||
return "Bulb is turning On"
|
return "Bulb is turning On"
|
||||||
}
|
}
|
||||||
@@ -1093,6 +1092,7 @@ def off(childDevice) {
|
|||||||
log.debug "Executing 'off'"
|
log.debug "Executing 'off'"
|
||||||
def id = getId(childDevice)
|
def id = getId(childDevice)
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
|
createSwitchEvent(childDevice, "off")
|
||||||
put("lights/$id/state", [on: false])
|
put("lights/$id/state", [on: false])
|
||||||
return "Bulb is turning Off"
|
return "Bulb is turning Off"
|
||||||
}
|
}
|
||||||
@@ -1108,6 +1108,8 @@ def setLevel(childDevice, percent) {
|
|||||||
else
|
else
|
||||||
level = Math.min(Math.round(percent * 254 / 100), 254)
|
level = Math.min(Math.round(percent * 254 / 100), 254)
|
||||||
|
|
||||||
|
createSwitchEvent(childDevice, level > 0, percent)
|
||||||
|
|
||||||
// For Zigbee lights, if level is set to 0 ST just turns them off without changing level
|
// For Zigbee lights, if level is set to 0 ST just turns them off without changing level
|
||||||
// that means that the light will still be on when on is called next time
|
// that means that the light will still be on when on is called next time
|
||||||
// Lets emulate that here
|
// Lets emulate that here
|
||||||
@@ -1126,6 +1128,7 @@ def setSaturation(childDevice, percent) {
|
|||||||
// 0 - 254
|
// 0 - 254
|
||||||
def level = Math.min(Math.round(percent * 254 / 100), 254)
|
def level = Math.min(Math.round(percent * 254 / 100), 254)
|
||||||
// TODO should this be done by app only or should we default to on?
|
// TODO should this be done by app only or should we default to on?
|
||||||
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/$id/state", [sat: level, on: true])
|
put("lights/$id/state", [sat: level, on: true])
|
||||||
return "Setting saturation to $percent"
|
return "Setting saturation to $percent"
|
||||||
}
|
}
|
||||||
@@ -1137,6 +1140,7 @@ def setHue(childDevice, percent) {
|
|||||||
// 0 - 65535
|
// 0 - 65535
|
||||||
def level = Math.min(Math.round(percent * 65535 / 100), 65535)
|
def level = Math.min(Math.round(percent * 65535 / 100), 65535)
|
||||||
// TODO should this be done by app only or should we default to on?
|
// TODO should this be done by app only or should we default to on?
|
||||||
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/$id/state", [hue: level, on: true])
|
put("lights/$id/state", [hue: level, on: true])
|
||||||
return "Setting hue to $percent"
|
return "Setting hue to $percent"
|
||||||
}
|
}
|
||||||
@@ -1147,6 +1151,7 @@ def setColorTemperature(childDevice, huesettings) {
|
|||||||
updateInProgress()
|
updateInProgress()
|
||||||
// 153 (6500K) to 500 (2000K)
|
// 153 (6500K) to 500 (2000K)
|
||||||
def ct = hueSettings == 6500 ? 153 : Math.round(1000000 / huesettings)
|
def ct = hueSettings == 6500 ? 153 : Math.round(1000000 / huesettings)
|
||||||
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/$id/state", [ct: ct, on: true])
|
put("lights/$id/state", [ct: ct, on: true])
|
||||||
return "Setting color temperature to $ct"
|
return "Setting color temperature to $ct"
|
||||||
}
|
}
|
||||||
@@ -1205,6 +1210,7 @@ def setColor(childDevice, huesettings) {
|
|||||||
if (huesettings.switch == "off")
|
if (huesettings.switch == "off")
|
||||||
value.on = false
|
value.on = false
|
||||||
|
|
||||||
|
createSwitchEvent(childDevice, value.on ? "on" : "off")
|
||||||
put("lights/$id/state", value)
|
put("lights/$id/state", value)
|
||||||
return "Setting color to $value"
|
return "Setting color to $value"
|
||||||
}
|
}
|
||||||
@@ -1316,6 +1322,32 @@ private List getRealHubFirmwareVersions() {
|
|||||||
return location.hubs*.firmwareVersionString.findAll { it }
|
return location.hubs*.firmwareVersionString.findAll { it }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends appropriate turningOn/turningOff state events depending on switch or level changes.
|
||||||
|
*
|
||||||
|
* @param childDevice device to send event for
|
||||||
|
* @param setSwitch The new switch state, "on" or "off"
|
||||||
|
* @param setLevel Optional, switchLevel between 0-100, used if you set level to 0 for example since
|
||||||
|
* that should generate "off" instead of level change
|
||||||
|
*/
|
||||||
|
private void createSwitchEvent(childDevice, setSwitch, setLevel = null) {
|
||||||
|
|
||||||
|
if (setLevel == null) {
|
||||||
|
setLevel = childDevice.device?.currentValue("level")
|
||||||
|
}
|
||||||
|
// Create on, off, turningOn or turningOff event as necessary
|
||||||
|
def currentState = childDevice.device?.currentValue("switch")
|
||||||
|
if ((currentState == "off" || currentState == "turningOff")) {
|
||||||
|
if (setSwitch == "on" || setLevel > 0) {
|
||||||
|
childDevice.sendEvent(name: "switch", value: "turningOn", displayed: false)
|
||||||
|
}
|
||||||
|
} else if ((currentState == "on" || currentState == "turningOn")) {
|
||||||
|
if (setSwitch == "off" || setLevel == 0) {
|
||||||
|
childDevice.sendEvent(name: "switch", value: "turningOff", displayed: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the supported color range for different Hue lights. If model is not specified
|
* Return the supported color range for different Hue lights. If model is not specified
|
||||||
* it defaults to the smallest Gamut (B) to ensure that colors set on a mix of devices
|
* it defaults to the smallest Gamut (B) to ensure that colors set on a mix of devices
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//DEPRECATED. INTEGRATION MOVED TO SUPER LAN CONNECT
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user