mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 13:20:53 +00:00
Compare commits
21 Commits
MSA-1809-1
...
PROD_2017.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a605373d6 | ||
|
|
90fb9251a6 | ||
|
|
195e0babb2 | ||
|
|
065715f296 | ||
|
|
10acb76b34 | ||
|
|
4fc046f57f | ||
|
|
ff2e70b011 | ||
|
|
79e2789f68 | ||
|
|
94a87e5c7f | ||
|
|
22be8ef2e8 | ||
|
|
2f20a339c3 | ||
|
|
7e806275ce | ||
|
|
1ed57aab45 | ||
|
|
4eea7ff90f | ||
|
|
b2264538c9 | ||
|
|
f45ab69045 | ||
|
|
ab79ceb857 | ||
|
|
2151e2dd3e | ||
|
|
bfd2b6c0fa | ||
|
|
fc312286a2 | ||
|
|
0846b6f34c |
@@ -9,7 +9,7 @@ apply plugin: 'smartthings-slack'
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.8"
|
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.11"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ 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: ""
|
||||||
}
|
}
|
||||||
@@ -228,6 +229,8 @@ 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,6 +22,7 @@ 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: ""
|
||||||
}
|
}
|
||||||
@@ -240,6 +241,8 @@ 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,6 +39,7 @@ 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"
|
||||||
@@ -304,6 +305,9 @@ 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,6 +46,7 @@
|
|||||||
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"
|
||||||
@@ -125,6 +126,9 @@
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ def parse(String description) {
|
|||||||
}
|
}
|
||||||
} else if (descMap.clusterInt == 0x0406 && descMap.attrInt == 0x0000) {
|
} else if (descMap.clusterInt == 0x0406 && descMap.attrInt == 0x0000) {
|
||||||
def value = descMap.value.endsWith("01") ? "active" : "inactive"
|
def value = descMap.value.endsWith("01") ? "active" : "inactive"
|
||||||
log.warn "Doing a read attr motion event"
|
log.debug "Doing a read attr motion event"
|
||||||
resultMap = getMotionResult(value)
|
map = getMotionResult(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,103 +0,0 @@
|
|||||||
/**
|
|
||||||
* Curb Control
|
|
||||||
*
|
|
||||||
* Copyright 2016 Savanni D'Gerinel
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "Curb Control",
|
|
||||||
namespace: "curb-v2",
|
|
||||||
author: "Savanni D'Gerinel",
|
|
||||||
description: "Control point for Curb/SmartThings integration",
|
|
||||||
category: "Green Living",
|
|
||||||
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",
|
|
||||||
oauth: true)
|
|
||||||
|
|
||||||
|
|
||||||
preferences {
|
|
||||||
section("Allow Endpoint to Control These Things...") {
|
|
||||||
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mappings {
|
|
||||||
|
|
||||||
path("/switches") {
|
|
||||||
action: [
|
|
||||||
GET: "listSwitches"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/switches/:id") {
|
|
||||||
action: [
|
|
||||||
GET: "showSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/switches/:id/:command") {
|
|
||||||
action: [
|
|
||||||
PUT: "updateSwitch"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {}
|
|
||||||
|
|
||||||
def updated() {}
|
|
||||||
|
|
||||||
|
|
||||||
//switches
|
|
||||||
def listSwitches() {
|
|
||||||
switches.collect{device(it,"switch")}
|
|
||||||
}
|
|
||||||
|
|
||||||
def showSwitch() {
|
|
||||||
show(switches, "switch")
|
|
||||||
}
|
|
||||||
void updateSwitch() {
|
|
||||||
update(switches)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def deviceHandler(evt) {}
|
|
||||||
|
|
||||||
private void update(devices) {
|
|
||||||
log.debug "update, request: params: ${params}, devices: $devices.id"
|
|
||||||
|
|
||||||
|
|
||||||
//def command = request.JSON?.command
|
|
||||||
def command = params.command
|
|
||||||
//let's create a toggle option here
|
|
||||||
if (command)
|
|
||||||
{
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
} else {
|
|
||||||
if(command == "toggle")
|
|
||||||
{
|
|
||||||
if(device.currentValue('switch') == "on")
|
|
||||||
device.off();
|
|
||||||
else
|
|
||||||
device.on();;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private show(devices, type) {
|
|
||||||
def device = devices.find { it.id == params.id }
|
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
def attributeName = type == "motionSensor" ? "motion" : type
|
|
||||||
def s = device.currentState(attributeName)
|
|
||||||
[id: device.id, label: device.displayName, value: s?.value, unitTime: s?.date?.time, type: type]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private device(it, type) {
|
|
||||||
it ? [id: it.id, label: it.label, type: type] : null
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,7 @@ definition(
|
|||||||
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
||||||
* cameras | image | take | <String>
|
* cameras | image | take | <String>
|
||||||
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
||||||
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
||||||
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
||||||
* | | emergencyHeat, |
|
* | | emergencyHeat, |
|
||||||
* | | setThermostatMode, |
|
* | | setThermostatMode, |
|
||||||
@@ -55,7 +55,7 @@ preferences {
|
|||||||
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false
|
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false
|
||||||
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false
|
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false
|
||||||
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
|
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false
|
||||||
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false
|
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false
|
||||||
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false
|
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false
|
||||||
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false
|
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false
|
||||||
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false
|
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false
|
||||||
@@ -66,54 +66,48 @@ preferences {
|
|||||||
|
|
||||||
def getInputs() {
|
def getInputs() {
|
||||||
def inputList = []
|
def inputList = []
|
||||||
inputList += contactSensors ?: []
|
inputList += contactSensors?: []
|
||||||
inputList += garageDoors ?: []
|
inputList += garageDoors?: []
|
||||||
inputList += locks ?: []
|
inputList += locks?: []
|
||||||
inputList += cameras ?: []
|
inputList += cameras?: []
|
||||||
inputList += motionSensors ?: []
|
inputList += motionSensors?: []
|
||||||
inputList += presenceSensors ?: []
|
inputList += presenceSensors?: []
|
||||||
inputList += switches ?: []
|
inputList += switches?: []
|
||||||
inputList += thermostats ?: []
|
inputList += thermostats?: []
|
||||||
inputList += waterSensors ?: []
|
inputList += waterSensors?: []
|
||||||
return inputList
|
return inputList
|
||||||
}
|
}
|
||||||
|
|
||||||
//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"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -145,7 +139,7 @@ def registerSubscriptions() {
|
|||||||
def registerChangeHandler(myList) {
|
def registerChangeHandler(myList) {
|
||||||
myList.each { myDevice ->
|
myList.each { myDevice ->
|
||||||
def theAtts = myDevice.supportedAttributes
|
def theAtts = myDevice.supportedAttributes
|
||||||
theAtts.each { att ->
|
theAtts.each {att ->
|
||||||
subscribe(myDevice, att.name, eventHandler)
|
subscribe(myDevice, att.name, eventHandler)
|
||||||
log.info "Registering ${myDevice.displayName}.${att.name}"
|
log.info "Registering ${myDevice.displayName}.${att.name}"
|
||||||
}
|
}
|
||||||
@@ -157,7 +151,7 @@ def registerDeviceChange() {
|
|||||||
def myDevice = findDevice(params.id)
|
def myDevice = findDevice(params.id)
|
||||||
def theAtts = myDevice.supportedAttributes
|
def theAtts = myDevice.supportedAttributes
|
||||||
try {
|
try {
|
||||||
theAtts.each { att ->
|
theAtts.each {att ->
|
||||||
subscribe(myDevice, att.name, eventHandler)
|
subscribe(myDevice, att.name, eventHandler)
|
||||||
log.info "Registering ${myDevice.displayName}.${att.name}"
|
log.info "Registering ${myDevice.displayName}.${att.name}"
|
||||||
}
|
}
|
||||||
@@ -186,16 +180,20 @@ 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: [
|
body: [ deviceInfo ]
|
||||||
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}"
|
||||||
@@ -230,10 +228,13 @@ 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()]
|
{
|
||||||
} else {
|
deviceData << [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
||||||
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)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,10 +247,13 @@ 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()]
|
{
|
||||||
} else {
|
device = [name: it.displayName, id: it.id, status:it.getStatus(), deviceType:deviceType, manufacturer:it.getManufacturerName(), model:it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()]
|
||||||
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
|
||||||
@@ -261,18 +265,18 @@ void updateDevice() {
|
|||||||
request.JSON.each {
|
request.JSON.each {
|
||||||
def command = it.key
|
def command = it.key
|
||||||
def value = it.value
|
def value = it.value
|
||||||
if (command) {
|
if (command){
|
||||||
def commandList = mapDeviceCommands(command, value)
|
def commandList = mapDeviceCommands(command, value)
|
||||||
command = commandList[0]
|
command = commandList[0]
|
||||||
value = commandList[1]
|
value = commandList[1]
|
||||||
|
|
||||||
if (command == "setAwayMode") {
|
if (command == "setAwayMode") {
|
||||||
log.info "Setting away mode to ${value}"
|
log.info "Setting away mode to ${value}"
|
||||||
if (location.modes?.find { it.name == value }) {
|
if (location.modes?.find {it.name == value}) {
|
||||||
location.setMode(value)
|
location.setMode(value)
|
||||||
}
|
}
|
||||||
} else if (command == "thermostatSetpoint") {
|
}else if (command == "thermostatSetpoint"){
|
||||||
switch (device.currentThermostatMode) {
|
switch(device.currentThermostatMode){
|
||||||
case "cool":
|
case "cool":
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device.setCoolingSetpoint(value)
|
device.setCoolingSetpoint(value)
|
||||||
@@ -286,7 +290,7 @@ void updateDevice() {
|
|||||||
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if (!device) {
|
}else if (!device) {
|
||||||
log.error "updateDevice, Device not found"
|
log.error "updateDevice, Device not found"
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else if (!device.hasCommand(command)) {
|
} else if (!device.hasCommand(command)) {
|
||||||
@@ -296,11 +300,11 @@ void updateDevice() {
|
|||||||
if (command == "setColor") {
|
if (command == "setColor") {
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device."$command"(hex: value)
|
device."$command"(hex: value)
|
||||||
} else if (value.isNumber()) {
|
} else if(value.isNumber()) {
|
||||||
def intValue = value as Integer
|
def intValue = value as Integer
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
||||||
device."$command"(intValue)
|
device."$command"(intValue)
|
||||||
} else if (value) {
|
} else if (value){
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device."$command"(value)
|
device."$command"(value)
|
||||||
} else {
|
} else {
|
||||||
@@ -322,19 +326,28 @@ 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 caps = device.capabilities
|
def capabilities = device.capabilities
|
||||||
log.debug "capabilities: [${device}, ${caps}]"
|
log.debug "capabilities: [${device}, ${capabilities}]"
|
||||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
||||||
caps.each {
|
|
||||||
switch (it.name.toLowerCase()) {
|
//Loop through the device capability list to determine the device type.
|
||||||
|
capabilities.each {capability ->
|
||||||
|
switch(capability.name.toLowerCase())
|
||||||
|
{
|
||||||
case "switch":
|
case "switch":
|
||||||
deviceType = "switch"
|
deviceType = "switch"
|
||||||
if (caps.any { it.name.toLowerCase() == "power meter" }) {
|
|
||||||
return deviceType
|
//If the device also contains "Switch Level" capability, identify it as a "light" device.
|
||||||
}
|
if (capabilities.any{it.name.toLowerCase() == "switch level"}){
|
||||||
if (caps.any { it.name.toLowerCase() == "switch level" }) {
|
|
||||||
deviceType = "light"
|
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
|
||||||
return deviceType
|
if (capabilities.any{it.name.toLowerCase() == "power meter"}){
|
||||||
|
deviceType = "dimmerSwitch"
|
||||||
|
return deviceType
|
||||||
|
} else {
|
||||||
|
deviceType = "light"
|
||||||
|
return deviceType
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "contact sensor":
|
case "contact sensor":
|
||||||
@@ -375,11 +388,11 @@ private findDevice(deviceId) {
|
|||||||
|
|
||||||
//Return a list of device attributes
|
//Return a list of device attributes
|
||||||
private deviceAttributeList(device) {
|
private deviceAttributeList(device) {
|
||||||
device.supportedAttributes.collectEntries { attribute ->
|
device.supportedAttributes.collectEntries { attribute->
|
||||||
try {
|
try {
|
||||||
[(attribute.name): device.currentValue(attribute.name)]
|
[ (attribute.name): device.currentValue(attribute.name) ]
|
||||||
} catch (e) {
|
} catch(e) {
|
||||||
[(attribute.name): null]
|
[ (attribute.name): null ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,7 +427,7 @@ private mapDeviceCommands(command, value) {
|
|||||||
resultCommand = "setSaturation"
|
resultCommand = "setSaturation"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
case "ct":
|
case "colorTemperature":
|
||||||
resultCommand = "setColorTemperature"
|
resultCommand = "setColorTemperature"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
@@ -451,7 +464,8 @@ 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 = ""
|
||||||
}
|
}
|
||||||
@@ -460,6 +474,5 @@ private mapDeviceCommands(command, value) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
return [resultCommand, resultValue]
|
return [resultCommand,resultValue]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user