mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 05:11:52 +00:00
Compare commits
41 Commits
MSA-1603-1
...
PROD_2017.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30511d74af | ||
|
|
f0f02a2c00 | ||
|
|
57d20e2fca | ||
|
|
3216f63cc0 | ||
|
|
7cbc2d1780 | ||
|
|
5ad20fbd2a | ||
|
|
a17971d68c | ||
|
|
076ffecd19 | ||
|
|
52357e4c50 | ||
|
|
03a7991279 | ||
|
|
f969027191 | ||
|
|
8db0556696 | ||
|
|
5607a3e346 | ||
|
|
bd44027038 | ||
|
|
490ec329cb | ||
|
|
3109049122 | ||
|
|
930c4ed914 | ||
|
|
259516f21f | ||
|
|
b7a08a88e0 | ||
|
|
c028515fcd | ||
|
|
751c98d123 | ||
|
|
5b874e8f3a | ||
|
|
9e10405527 | ||
|
|
32ceaff54d | ||
|
|
5b1da30a47 | ||
|
|
76e139153a | ||
|
|
a4bc248006 | ||
|
|
e7eb461b4e | ||
|
|
0a82077b24 | ||
|
|
083ed7cc9a | ||
|
|
38ef9e5c77 | ||
|
|
6a71615ca5 | ||
|
|
9939591005 | ||
|
|
d7f2bc1d79 | ||
|
|
3c5d727d4c | ||
|
|
bbad6dfa7a | ||
|
|
df6c815aa4 | ||
|
|
d16ac00eb6 | ||
|
|
1941f56007 | ||
|
|
f34df19a65 | ||
|
|
20239ca982 |
@@ -22,9 +22,10 @@ metadata {
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
|
||||
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "Z-Wave Wall Dimmer"
|
||||
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "Z-Wave Wall Dimmer"
|
||||
fingerprint mfr:"0063", prod:"5044", deviceJoinName: "Z-Wave Plug-In Dimmer"
|
||||
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "GE In-Wall Smart Dimmer "
|
||||
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "GE In-Wall Smart Dimmer "
|
||||
fingerprint mfr:"0063", prod:"5044", deviceJoinName: "GE Plug-In Smart Dimmer "
|
||||
fingerprint mfr:"0063", prod:"4944", model:"3034", deviceJoinName: "GE In-Wall Smart Fan Control"
|
||||
}
|
||||
|
||||
simulator {
|
||||
|
||||
@@ -99,7 +99,7 @@ def parse(String description) {
|
||||
|
||||
def poll() {
|
||||
def refreshCmds = [
|
||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
|
||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
|
||||
]
|
||||
|
||||
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
@@ -197,7 +197,7 @@ def off() {
|
||||
|
||||
def refresh() {
|
||||
def refreshCmds = [
|
||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
|
||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
|
||||
]
|
||||
|
||||
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig()
|
||||
|
||||
@@ -39,7 +39,7 @@ metadata {
|
||||
}
|
||||
|
||||
def generatePresenceEvent(boolean present) {
|
||||
log.debug "Here in generatePresenceEvent!"
|
||||
log.info "Life360 generatePresenceEvent($present)"
|
||||
def value = formatValue(present)
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = formatDescriptionText(linkText, present)
|
||||
|
||||
@@ -128,9 +128,9 @@ def setLevel(value) {
|
||||
|
||||
def refresh() {
|
||||
[
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 500",
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 500",
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 500"
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 2000",
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 2000",
|
||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 2000"
|
||||
]
|
||||
|
||||
}
|
||||
@@ -313,9 +313,9 @@ def isDescriptionPower(descMap) {
|
||||
|
||||
def onOffConfig() {
|
||||
[
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 200",
|
||||
"zcl global send-me-a-report 6 0 0x10 0 600 {01}",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 2000",
|
||||
"zcl global send-me-a-report 6 0 0x10 0 600 {01}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -323,9 +323,9 @@ def onOffConfig() {
|
||||
//min level change is 01
|
||||
def levelConfig() {
|
||||
[
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 200",
|
||||
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 2000",
|
||||
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -333,9 +333,10 @@ def levelConfig() {
|
||||
//min change in value is 05
|
||||
def powerConfig() {
|
||||
[
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
|
||||
"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}", //The send-me-a-report is custom to the attribute type for CentraLite
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
|
||||
"delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -344,7 +345,10 @@ def setLevelWithRate(level, rate) {
|
||||
rate = "0000"
|
||||
}
|
||||
level = convertToHexString(level * 255 / 100) //Converting the 0-100 range to 0-FF range in hex
|
||||
"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {$level $rate}"
|
||||
[
|
||||
"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {$level $rate}",
|
||||
"delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
String convertToHexString(value, width=2) {
|
||||
|
||||
@@ -51,7 +51,7 @@ def on() {
|
||||
'zcl on-off on',
|
||||
'delay 200',
|
||||
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
||||
'delay 500'
|
||||
'delay 2000'
|
||||
|
||||
]
|
||||
|
||||
@@ -62,6 +62,6 @@ def off() {
|
||||
'zcl on-off off',
|
||||
'delay 200',
|
||||
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
||||
'delay 500'
|
||||
'delay 2000'
|
||||
]
|
||||
}
|
||||
|
||||
@@ -157,9 +157,10 @@ def configure() {
|
||||
//min change in value is 01
|
||||
def powerConfig() {
|
||||
[
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
|
||||
"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}", //The send-me-a-report is custom to the attribute type for CentraLite
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
|
||||
"delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,10 @@ metadata {
|
||||
command "enrollResponse"
|
||||
|
||||
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-S", deviceJoinName: "Water Leak Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-Seu", deviceJoinName: "Water Leak Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-S", deviceJoinName: "Water Leak Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-Seu", deviceJoinName: "Water Leak Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-L", deviceJoinName: "Iris Smart Water Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500", outClusters: "0019", manufacturer: "SmartThings", model: "moisturev4", deviceJoinName: "Water Leak Sensor"
|
||||
}
|
||||
|
||||
@@ -128,7 +129,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00){
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -285,8 +286,8 @@ def ping() {
|
||||
def refresh() {
|
||||
log.debug "Refreshing Temperature and Battery"
|
||||
def refreshCmds = [
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
||||
]
|
||||
|
||||
return refreshCmds + enrollResponse()
|
||||
@@ -308,10 +309,10 @@ def enrollResponse() {
|
||||
[
|
||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
||||
//Enroll Response
|
||||
"raw 0x500 {01 23 00 00 00}",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -298,8 +298,8 @@ def ping() {
|
||||
def refresh() {
|
||||
log.debug "refresh called"
|
||||
def refreshCmds = [
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
||||
]
|
||||
|
||||
return refreshCmds + enrollResponse()
|
||||
@@ -321,10 +321,10 @@ def enrollResponse() {
|
||||
[
|
||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
||||
//Enroll Response
|
||||
"raw 0x500 {01 23 00 00 00}",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if(cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -339,7 +339,7 @@ private Map getContactResult(value) {
|
||||
log.debug "Contact: ${device.displayName} value = ${value}"
|
||||
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
||||
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
||||
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
|
||||
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
|
||||
}
|
||||
|
||||
private getAccelerationResult(numValue) {
|
||||
@@ -428,10 +428,10 @@ def enrollResponse() {
|
||||
[
|
||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
||||
//Enroll Response
|
||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07){
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -252,8 +252,8 @@ def ping() {
|
||||
def refresh() {
|
||||
log.debug "Refreshing Temperature and Battery"
|
||||
def refreshCmds = [
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
||||
]
|
||||
|
||||
return refreshCmds + enrollResponse()
|
||||
@@ -277,10 +277,10 @@ def enrollResponse() {
|
||||
[
|
||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
||||
//Enroll Response
|
||||
"raw 0x500 {01 23 00 00 00}",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00){
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -270,9 +270,9 @@ def configure() {
|
||||
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
def humidityConfigCmds = [
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
|
||||
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 2000",
|
||||
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}", "delay 200",
|
||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
||||
]
|
||||
|
||||
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||
|
||||
@@ -86,7 +86,7 @@ def parse(String description) {
|
||||
def bodyString = msg.body
|
||||
if (bodyString) {
|
||||
unschedule("setOffline")
|
||||
def body = new XmlSlurper().parseText(bodyString)
|
||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
||||
|
||||
if (body?.property?.TimeSyncRequest?.text()) {
|
||||
log.trace "Got TimeSyncRequest"
|
||||
|
||||
@@ -78,7 +78,7 @@ def parse(String description) {
|
||||
def bodyString = msg.body
|
||||
if (bodyString) {
|
||||
unschedule("setOffline")
|
||||
def body = new XmlSlurper().parseText(bodyString)
|
||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
||||
if (body?.property?.TimeSyncRequest?.text()) {
|
||||
log.trace "Got TimeSyncRequest"
|
||||
result << timeSyncResponse()
|
||||
|
||||
@@ -84,7 +84,7 @@ def parse(String description) {
|
||||
def bodyString = msg.body
|
||||
if (bodyString) {
|
||||
unschedule("setOffline")
|
||||
def body = new XmlSlurper().parseText(bodyString)
|
||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
||||
if (body?.property?.TimeSyncRequest?.text()) {
|
||||
log.trace "Got TimeSyncRequest"
|
||||
result << timeSyncResponse()
|
||||
@@ -208,7 +208,7 @@ def subscribe(ip, port) {
|
||||
def existingIp = getDataValue("ip")
|
||||
def existingPort = getDataValue("port")
|
||||
if (ip && ip != existingIp) {
|
||||
log.debug "Updating ip from $existingIp to $ip"
|
||||
log.debug "Updating ip from $existingIp to $ip"
|
||||
updateDataValue("ip", ip)
|
||||
def ipvalue = convertHexToIP(getDataValue("ip"))
|
||||
sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP changed to ${ipvalue}")
|
||||
@@ -291,4 +291,4 @@ User-Agent: CyberGarage-HTTP/1.0
|
||||
</u:GetBinaryState>
|
||||
</s:Body>
|
||||
</s:Envelope>""", physicalgraph.device.Protocol.LAN)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ metadata {
|
||||
|
||||
fingerprint inClusters: "0000, 0001, 0003, 0020, 0402, 0B05", outClusters: "0003, 0006, 0008, 0019", manufacturer: "OSRAM", model: "LIGHTIFY Dimming Switch", deviceJoinName: "OSRAM LIGHTIFY Dimming Switch"
|
||||
//fingerprint inClusters: "0000, 0001, 0003, 0020, 0500", outClusters: "0003,0019", manufacturer: "CentraLite", model: "3455-L", deviceJoinName: "Iris Care Pendant"
|
||||
//fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0402, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model: "3460-L", deviceJoinName: "Iris Smart Button"
|
||||
//fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model:"3450-L", deviceJoinName: "Iris KeyFob"
|
||||
fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0402, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model: "3460-L", deviceJoinName: "Iris Smart Button"
|
||||
fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model:"3450-L", deviceJoinName: "Iris KeyFob"
|
||||
}
|
||||
|
||||
simulator {}
|
||||
|
||||
@@ -127,8 +127,8 @@ def configureHealthCheck() {
|
||||
|
||||
def configure() {
|
||||
log.debug "configure()"
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
configureHealthCheck()
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
|
||||
@@ -24,6 +24,10 @@ metadata {
|
||||
fingerprint inClusters: "0x26", deviceJoinName: "Z-Wave Dimmer"
|
||||
fingerprint mfr:"001D", prod:"1902", deviceJoinName: "Z-Wave Dimmer"
|
||||
fingerprint mfr:"001D", prod:"1B03", model:"0334", deviceJoinName: "Leviton Universal Dimmer"
|
||||
fingerprint mfr:"011A", prod:"0102", model:"0201", deviceJoinName: "Enerwave In-Wall Dimmer"
|
||||
fingerprint mfr:"001D", prod:"1001", model:"0334", deviceJoinName: "Leviton 3-Speed Fan Controller"
|
||||
fingerprint mfr:"001D", prod:"0602", model:"0334", deviceJoinName: "Leviton Magnetic Low Voltage Dimmer"
|
||||
fingerprint mfr:"001D", prod:"0401", model:"0334", deviceJoinName: "Leviton 600W Incandescent Dimmer"
|
||||
}
|
||||
|
||||
simulator {
|
||||
|
||||
@@ -28,6 +28,7 @@ metadata {
|
||||
fingerprint mfr: "0060", prod: "0001", model: "0002", deviceJoinName: "Everspring Motion Sensor" // Everspring SP814
|
||||
fingerprint mfr: "0060", prod: "0001", model: "0003", deviceJoinName: "Everspring Motion Sensor" // Everspring HSP02
|
||||
fingerprint mfr: "011A", prod: "0601", model: "0901", deviceJoinName: "Enerwave Motion Sensor" // Enerwave ZWN-BPC
|
||||
fingerprint mfr: "0063", prod: "4953", model: "3133", deviceJoinName: "GE Smart Motion Sensor"
|
||||
}
|
||||
|
||||
simulator {
|
||||
|
||||
@@ -25,6 +25,9 @@ metadata {
|
||||
fingerprint mfr:"0063", prod:"4F50", model:"3031", deviceJoinName: "GE Plug-in Outdoor Switch"
|
||||
fingerprint mfr:"001D", prod:"1D04", model:"0334", deviceJoinName: "Leviton Outlet"
|
||||
fingerprint mfr:"001D", prod:"1C02", model:"0334", deviceJoinName: "Leviton Switch"
|
||||
fingerprint mfr:"001D", prod:"0301", model:"0334", deviceJoinName: "Leviton 15A Switch"
|
||||
fingerprint mfr:"011A", prod:"0101", model:"0102", deviceJoinName: "Enerwave On/Off Switch"
|
||||
fingerprint mfr:"011A", prod:"0101", model:"0603", deviceJoinName: "Enerwave Duplex Receptacle"
|
||||
}
|
||||
|
||||
// simulator metadata
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* Color Coordinator
|
||||
* Version 1.1.0 - 11/9/16
|
||||
* Version 1.1.1 - 11/9/16
|
||||
* By Michael Struck
|
||||
*
|
||||
* 1.0.0 - Initial release
|
||||
* 1.1.0 - Fixed issue where master can be part of slaves. This causes a loop that impacts SmartThings.
|
||||
* 1.1.1 - Fix NPE being thrown for slave/master inputs being empty.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
@@ -33,17 +34,17 @@ preferences {
|
||||
|
||||
def mainPage() {
|
||||
dynamicPage(name: "mainPage", title: "", install: true, uninstall: false) {
|
||||
def masterInList = slaves.id.find{it==master.id}
|
||||
def masterInList = slaves?.id?.find{it==master?.id}
|
||||
if (masterInList) {
|
||||
section ("**WARNING**"){
|
||||
paragraph "You have included the Master Light in the Slave Group. This will cause a loop in execution. Please remove this device from the Slave Group.", image: "https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/img/caution.png"
|
||||
}
|
||||
}
|
||||
section("Master Light") {
|
||||
input "master", "capability.colorControl", title: "Colored Light"
|
||||
input "master", "capability.colorControl", title: "Colored Light", required: true
|
||||
}
|
||||
section("Lights that follow the master settings") {
|
||||
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: false, submitOnChange: true
|
||||
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: true, submitOnChange: true
|
||||
}
|
||||
section([mobileOnly:true], "Options") {
|
||||
input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
|
||||
@@ -81,40 +82,44 @@ def init() {
|
||||
}
|
||||
//-----------------------------------
|
||||
def onOffHandler(evt){
|
||||
if (!slaves.id.find{it==master.id}){
|
||||
if (master.currentValue("switch") == "on"){
|
||||
if (randomYes) getRandomColorMaster()
|
||||
else slaves?.on()
|
||||
}
|
||||
else {
|
||||
slaves?.off()
|
||||
}
|
||||
if (slaves && master) {
|
||||
if (!slaves?.id.find{it==master?.id}){
|
||||
if (master?.currentValue("switch") == "on"){
|
||||
if (randomYes) getRandomColorMaster()
|
||||
else slaves?.on()
|
||||
}
|
||||
else {
|
||||
slaves?.off()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def colorHandler(evt) {
|
||||
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
|
||||
log.debug "Changing Slave units H,S,L"
|
||||
def dimLevel = master.currentValue("level")
|
||||
def hueLevel = master.currentValue("hue")
|
||||
def saturationLevel = master.currentValue("saturation")
|
||||
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
||||
slaves?.setColor(newValue)
|
||||
try {
|
||||
log.debug "Changing Slave color temp"
|
||||
def tempLevel = master.currentValue("colorTemperature")
|
||||
slaves?.setColorTemperature(tempLevel)
|
||||
}
|
||||
catch (e){
|
||||
log.debug "Color temp for master --"
|
||||
}
|
||||
if (slaves && master) {
|
||||
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
|
||||
log.debug "Changing Slave units H,S,L"
|
||||
def dimLevel = master?.currentValue("level")
|
||||
def hueLevel = master?.currentValue("hue")
|
||||
def saturationLevel = master.currentValue("saturation")
|
||||
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
||||
slaves?.setColor(newValue)
|
||||
try {
|
||||
log.debug "Changing Slave color temp"
|
||||
def tempLevel = master?.currentValue("colorTemperature")
|
||||
slaves?.setColorTemperature(tempLevel)
|
||||
}
|
||||
catch (e){
|
||||
log.debug "Color temp for master --"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getRandomColorMaster(){
|
||||
def hueLevel = Math.floor(Math.random() *1000)
|
||||
def saturationLevel = Math.floor(Math.random() * 100)
|
||||
def dimLevel = master.currentValue("level")
|
||||
def dimLevel = master?.currentValue("level")
|
||||
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
||||
log.debug hueLevel
|
||||
log.debug saturationLevel
|
||||
@@ -123,12 +128,14 @@ def getRandomColorMaster(){
|
||||
}
|
||||
|
||||
def tempHandler(evt){
|
||||
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
|
||||
if (evt.value != "--") {
|
||||
log.debug "Changing Slave color temp based on Master change"
|
||||
def tempLevel = master.currentValue("colorTemperature")
|
||||
slaves?.setColorTemperature(tempLevel)
|
||||
}
|
||||
if (slaves && master) {
|
||||
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
|
||||
if (evt.value != "--") {
|
||||
log.debug "Changing Slave color temp based on Master change"
|
||||
def tempLevel = master.currentValue("colorTemperature")
|
||||
slaves?.setColorTemperature(tempLevel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +146,7 @@ private def textAppName() {
|
||||
}
|
||||
|
||||
private def textVersion() {
|
||||
def text = "Version 1.1.0 (11/09/2016)"
|
||||
def text = "Version 1.1.1 (12/13/2016)"
|
||||
}
|
||||
|
||||
private def textCopyright() {
|
||||
@@ -166,4 +173,4 @@ private def textHelp() {
|
||||
"This application will allow you to control the settings of multiple colored lights with one control. " +
|
||||
"Simply choose a master control light, and then choose the lights that will follow the settings of the master, "+
|
||||
"including on/off conditions, hue, saturation, level and color temperature. Also includes a random color feature."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,461 @@
|
||||
/**
|
||||
* OpenT2T SmartApp Test
|
||||
*
|
||||
* Copyright 2016 OpenT2T
|
||||
*
|
||||
* 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: "OpenT2T SmartApp Test",
|
||||
namespace: "opent2t",
|
||||
author: "OpenT2T",
|
||||
description: "Test app to test end to end SmartThings scenarios via OpenT2T",
|
||||
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")
|
||||
|
||||
/** --------------------+---------------+-----------------------+------------------------------------
|
||||
* Device Type | Attribute Name| Commands | Attribute Values
|
||||
* --------------------+---------------+-----------------------+------------------------------------
|
||||
* switches | switch | on, off | on, off
|
||||
* motionSensors | motion | | active, inactive
|
||||
* contactSensors | contact | | open, closed
|
||||
* presenceSensors | presence | | present, 'not present'
|
||||
* temperatureSensors | temperature | | <numeric, F or C according to unit>
|
||||
* accelerationSensors | acceleration | | active, inactive
|
||||
* waterSensors | water | | wet, dry
|
||||
* lightSensors | illuminance | | <numeric, lux>
|
||||
* humiditySensors | humidity | | <numeric, percent>
|
||||
* locks | lock | lock, unlock | locked, unlocked
|
||||
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
||||
* cameras | image | take | <String>
|
||||
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
||||
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
||||
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
||||
* | | emergencyHeat, |
|
||||
* | | setThermostatMode, |
|
||||
* | | fanOn, fanAuto, |
|
||||
* | | fanCirculate, |
|
||||
* | | setThermostatFanMode |
|
||||
* --------------------+---------------+-----------------------+------------------------------------
|
||||
*/
|
||||
|
||||
//Device Inputs
|
||||
preferences {
|
||||
section("Allow <PLACEHOLDER: Your App Name> to control these things...") {
|
||||
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 "locks", "capability.lock", title: "Which Locks?", 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 "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 "thermostats", "capability.thermostat", title: "Which Thermostat?", multiple: true, required: false
|
||||
input "waterSensors", "capability.waterSensor", title: "Which Water Leak Sensors?", multiple: true, required: false
|
||||
}
|
||||
}
|
||||
|
||||
def getInputs() {
|
||||
def inputList = []
|
||||
inputList += contactSensors ?: []
|
||||
inputList += garageDoors ?: []
|
||||
inputList += locks ?: []
|
||||
inputList += cameras ?: []
|
||||
inputList += motionSensors ?: []
|
||||
inputList += presenceSensors ?: []
|
||||
inputList += switches ?: []
|
||||
inputList += thermostats ?: []
|
||||
inputList += waterSensors ?: []
|
||||
return inputList
|
||||
}
|
||||
|
||||
//API external Endpoints
|
||||
mappings {
|
||||
path("/subscriptionURL/:url") {
|
||||
action:
|
||||
[
|
||||
PUT: "updateEndpointURL"
|
||||
]
|
||||
}
|
||||
path("/connectionId/:connId") {
|
||||
action:
|
||||
[
|
||||
PUT: "updateConnectionId"
|
||||
]
|
||||
}
|
||||
path("/devices") {
|
||||
action:
|
||||
[
|
||||
GET: "getDevices"
|
||||
]
|
||||
}
|
||||
path("/devices/:id") {
|
||||
action:
|
||||
[
|
||||
GET: "getDevice"
|
||||
]
|
||||
}
|
||||
path("/update/:id") {
|
||||
action:
|
||||
[
|
||||
PUT: "updateDevice"
|
||||
]
|
||||
}
|
||||
path("/subscription/:id") {
|
||||
action:
|
||||
[
|
||||
POST : "registerDeviceChange",
|
||||
DELETE: "unregisterDeviceChange"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
unsubscribe()
|
||||
registerSubscriptions()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
state.connectionId = ""
|
||||
state.endpointURL = "https://ifs.windows-int.com/v1/cb/81C7E77B-EABC-488A-B2BF-FEC42F0DABD2/notify"
|
||||
registerSubscriptions()
|
||||
}
|
||||
|
||||
//Subscribe events for all devices
|
||||
def registerSubscriptions() {
|
||||
registerChangeHandler(inputs)
|
||||
}
|
||||
|
||||
//Subscribe to events from a list of devices
|
||||
def registerChangeHandler(myList) {
|
||||
myList.each { myDevice ->
|
||||
def theAtts = myDevice.supportedAttributes
|
||||
theAtts.each { att ->
|
||||
subscribe(myDevice, att.name, eventHandler)
|
||||
log.info "Registering ${myDevice.displayName}.${att.name}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Endpoints function: Subscribe to events from a specific device
|
||||
def registerDeviceChange() {
|
||||
def myDevice = findDevice(params.id)
|
||||
def theAtts = myDevice.supportedAttributes
|
||||
try {
|
||||
theAtts.each { att ->
|
||||
subscribe(myDevice, att.name, eventHandler)
|
||||
log.info "Registering ${myDevice.displayName}.${att.name}"
|
||||
}
|
||||
return ["succeed"]
|
||||
} catch (e) {
|
||||
httpError(500, "something went wrong: $e")
|
||||
}
|
||||
}
|
||||
|
||||
//Endpoints function: Unsubscribe to events from a specific device
|
||||
def unregisterDeviceChange() {
|
||||
def myDevice = findDevice(params.id)
|
||||
try {
|
||||
unsubscribe(myDevice)
|
||||
log.info "Unregistering ${myDevice.displayName}"
|
||||
return ["succeed"]
|
||||
} catch (e) {
|
||||
httpError(500, "something went wrong: $e")
|
||||
}
|
||||
}
|
||||
|
||||
//When events are triggered, send HTTP post to web socket servers
|
||||
def eventHandler(evt) {
|
||||
def evt_device_id = evt.deviceId
|
||||
def evt_device_value = evt.value
|
||||
def evt_name = evt.name
|
||||
def evt_device = evt.device
|
||||
def evt_deviceType = getDeviceType(evt_device);
|
||||
def params = [
|
||||
uri : "${state.endpointURL}/${state.connectionId}",
|
||||
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 {
|
||||
log.trace "POST URI: ${params.uri}"
|
||||
log.trace "Payload: ${params.body}"
|
||||
httpPostJson(params) { resp ->
|
||||
resp.headers.each {
|
||||
log.debug "${it.name} : ${it.value}"
|
||||
}
|
||||
log.trace "response status code: ${resp.status}"
|
||||
log.trace "response data: ${resp.data}"
|
||||
}
|
||||
} catch (e) {
|
||||
log.debug "something went wrong: $e"
|
||||
}
|
||||
}
|
||||
|
||||
//Endpoints function: update subcription endpoint url [state.endpoint]
|
||||
void updateEndpointURL() {
|
||||
state.endpointURL = params.url
|
||||
log.info "Updated EndpointURL to ${state.endpointURL}"
|
||||
}
|
||||
|
||||
//Endpoints function: update global variable [state.connectionId]
|
||||
void updateConnectionId() {
|
||||
def connId = params.connId
|
||||
state.connectionId = connId
|
||||
log.info "Updated ConnectionID to ${state.connectionId}"
|
||||
}
|
||||
|
||||
//Endpoints function: return all device data in json format
|
||||
def getDevices() {
|
||||
def deviceData = []
|
||||
inputs?.each {
|
||||
def deviceType = getDeviceType(it)
|
||||
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, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)]
|
||||
}
|
||||
}
|
||||
|
||||
log.debug "getDevices, return: ${deviceData}"
|
||||
return deviceData
|
||||
}
|
||||
|
||||
//Endpoints function: get device data
|
||||
def getDevice() {
|
||||
def it = findDevice(params.id)
|
||||
def deviceType = getDeviceType(it)
|
||||
def device
|
||||
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, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)]
|
||||
}
|
||||
log.debug "getDevice, return: ${device}"
|
||||
return device
|
||||
}
|
||||
|
||||
//Endpoints function: update device data
|
||||
void updateDevice() {
|
||||
def device = findDevice(params.id)
|
||||
request.JSON.each {
|
||||
def command = it.key
|
||||
def value = it.value
|
||||
if (command) {
|
||||
def commandList = mapDeviceCommands(command, value)
|
||||
command = commandList[0]
|
||||
value = commandList[1]
|
||||
|
||||
if (command == "setAwayMode") {
|
||||
log.info "Setting away mode to ${value}"
|
||||
if (location.modes?.find { it.name == value }) {
|
||||
location.setMode(value)
|
||||
}
|
||||
} else if (command == "thermostatSetpoint") {
|
||||
switch (device.currentThermostatMode) {
|
||||
case "cool":
|
||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||
device.setCoolingSetpoint(value)
|
||||
break
|
||||
case "heat":
|
||||
case "emergency heat":
|
||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||
device.setHeatingSetpoint(value)
|
||||
break
|
||||
default:
|
||||
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
||||
break
|
||||
}
|
||||
} else if (!device) {
|
||||
log.error "updateDevice, Device not found"
|
||||
httpError(404, "Device not found")
|
||||
} else if (!device.hasCommand(command)) {
|
||||
log.error "updateDevice, Device does not have the command"
|
||||
httpError(404, "Device does not have such command")
|
||||
} else {
|
||||
if (command == "setColor") {
|
||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||
device."$command"(hex: value)
|
||||
} else if (value.isNumber()) {
|
||||
def intValue = value as Integer
|
||||
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
||||
device."$command"(intValue)
|
||||
} else if (value) {
|
||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||
device."$command"(value)
|
||||
} else {
|
||||
log.info "Update: ${device.displayName}, [${command}]"
|
||||
device."$command"()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*** Private Functions ***/
|
||||
|
||||
//Return current location mode info
|
||||
private getLocationModeInfo() {
|
||||
return [mode: location.mode, supported: location.modes.name]
|
||||
}
|
||||
|
||||
//Map each device to a type given it's capabilities
|
||||
private getDeviceType(device) {
|
||||
def deviceType
|
||||
def caps = device.capabilities
|
||||
log.debug "capabilities: [${device}, ${caps}]"
|
||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
||||
caps.each {
|
||||
switch (it.name.toLowerCase()) {
|
||||
case "switch":
|
||||
deviceType = "switch"
|
||||
break
|
||||
case "switch level":
|
||||
deviceType = "light"
|
||||
break
|
||||
case "contact sensor":
|
||||
deviceType = "contactSensor"
|
||||
break
|
||||
case "garageDoorControl":
|
||||
deviceType = "garageDoor"
|
||||
break
|
||||
case "lock":
|
||||
deviceType = "lock"
|
||||
break
|
||||
case "video camera":
|
||||
deviceType = "camera"
|
||||
break
|
||||
case "motion sensor":
|
||||
deviceType = "motionSensor"
|
||||
break
|
||||
case "presence sensor":
|
||||
deviceType = "presenceSensor"
|
||||
break
|
||||
case "thermostat":
|
||||
deviceType = "thermostat"
|
||||
break
|
||||
case "water sensor":
|
||||
deviceType = "waterSensor"
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return deviceType
|
||||
}
|
||||
|
||||
//Return a specific device give the device ID.
|
||||
private findDevice(deviceId) {
|
||||
return inputs?.find { it.id == deviceId }
|
||||
}
|
||||
|
||||
//Return a list of device attributes
|
||||
private deviceAttributeList(device) {
|
||||
device.supportedAttributes.collectEntries { attribute ->
|
||||
try {
|
||||
[(attribute.name): device.currentValue(attribute.name)]
|
||||
} catch (e) {
|
||||
[(attribute.name): null]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Map device command and value.
|
||||
//input command and value are from UWP,
|
||||
//returns resultCommand and resultValue that corresponds with function and value in SmartApps
|
||||
private mapDeviceCommands(command, value) {
|
||||
log.debug "mapDeviceCommands: [${command}, ${value}]"
|
||||
def resultCommand = command
|
||||
def resultValue = value
|
||||
switch (command) {
|
||||
case "switch":
|
||||
if (value == 1 || value == "1" || value == "on") {
|
||||
resultCommand = "on"
|
||||
resultValue = ""
|
||||
} else if (value == 0 || value == "0" || value == "off") {
|
||||
resultCommand = "off"
|
||||
resultValue = ""
|
||||
}
|
||||
break
|
||||
// light attributes
|
||||
case "level":
|
||||
resultCommand = "setLevel"
|
||||
resultValue = value
|
||||
break
|
||||
case "hue":
|
||||
resultCommand = "setHue"
|
||||
resultValue = value
|
||||
break
|
||||
case "saturation":
|
||||
resultCommand = "setSaturation"
|
||||
resultValue = value
|
||||
break
|
||||
case "ct":
|
||||
resultCommand = "setColorTemperature"
|
||||
resultValue = value
|
||||
break
|
||||
case "color":
|
||||
resultCommand = "setColor"
|
||||
resultValue = value
|
||||
// thermostat attributes
|
||||
case "hvacMode":
|
||||
resultCommand = "setThermostatMode"
|
||||
resultValue = value
|
||||
break
|
||||
case "fanMode":
|
||||
resultCommand = "setThermostatFanMode"
|
||||
resultValue = value
|
||||
break
|
||||
case "awayMode":
|
||||
resultCommand = "setAwayMode"
|
||||
resultValue = value
|
||||
break
|
||||
case "coolingSetpoint":
|
||||
resultCommand = "setCoolingSetpoint"
|
||||
resultValue = value
|
||||
break
|
||||
case "heatingSetpoint":
|
||||
resultCommand = "setHeatingSetpoint"
|
||||
resultValue = value
|
||||
break
|
||||
case "thermostatSetpoint":
|
||||
resultCommand = "thermostatSetpoint"
|
||||
resultValue = value
|
||||
break
|
||||
// lock attributes
|
||||
case "locked":
|
||||
if (value == 1 || value == "1" || value == "lock") {
|
||||
resultCommand = "lock"
|
||||
resultValue = ""
|
||||
} else if (value == 0 || value == "0" || value == "unlock") {
|
||||
resultCommand = "unlock"
|
||||
resultValue = ""
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
return [resultCommand, resultValue]
|
||||
}
|
||||
|
||||
@@ -172,18 +172,34 @@ def bulbDiscovery() {
|
||||
if (existingLightsDescription.isEmpty()) {
|
||||
existingLightsDescription += it.value
|
||||
} else {
|
||||
existingLightsDescription += ", ${it.value}"
|
||||
existingLightsDescription += ", ${it.value}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||
section("Please wait while we discover your Hue Lights. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
||||
input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, submitOnChange: true, options:newLights
|
||||
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
||||
if (bulbRefreshCount > 200 && numFound == 0) {
|
||||
// Time out to avoid endless discovery
|
||||
state.inBulbDiscovery = false
|
||||
bulbRefreshCount = 0
|
||||
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Failed!", nextPage:"", refreshInterval:0, install:true, uninstall: true) {
|
||||
section("Failed to discover any lights, please try again later. Click Done to exit.") {
|
||||
//input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, submitOnChange: true, options:newLights
|
||||
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
||||
}
|
||||
section {
|
||||
href "bridgeDiscovery", title: title, description: "", state: selectedHue ? "complete" : "incomplete", params: [override: true]
|
||||
}
|
||||
}
|
||||
section {
|
||||
href "bridgeDiscovery", title: title, description: "", state: selectedHue ? "complete" : "incomplete", params: [override: true]
|
||||
|
||||
} else {
|
||||
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||
section("Please wait while we discover your Hue Lights. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
||||
input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, submitOnChange: true, options:newLights
|
||||
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
||||
}
|
||||
section {
|
||||
href "bridgeDiscovery", title: title, description: "", state: selectedHue ? "complete" : "incomplete", params: [override: true]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,7 +423,7 @@ def addBridge() {
|
||||
if(vbridge) {
|
||||
def d = getChildDevice(selectedHue)
|
||||
if(!d) {
|
||||
// compatibility with old devices
|
||||
// compatibility with old devices
|
||||
def newbridge = true
|
||||
childDevices.each {
|
||||
if (it.getDeviceDataByName("mac")) {
|
||||
@@ -593,7 +609,7 @@ def locationHandler(evt) {
|
||||
log.trace "Location: $description"
|
||||
|
||||
def hub = evt?.hubId
|
||||
def parsedEvent = parseLanMessage(description)
|
||||
def parsedEvent = parseLanMessage(description)
|
||||
parsedEvent << ["hub":hub]
|
||||
|
||||
if (parsedEvent?.ssdpTerm?.contains("urn:schemas-upnp-org:device:basic:1")) {
|
||||
@@ -819,8 +835,7 @@ def parse(childDevice, description) {
|
||||
try {
|
||||
body = new groovy.json.JsonSlurper().parseText(bodyString)
|
||||
} catch (all) {
|
||||
log.warn "Parsing Body failed - trying again..."
|
||||
poll()
|
||||
log.warn "Parsing Body failed"
|
||||
}
|
||||
if (body instanceof java.util.Map) {
|
||||
// get (poll) reponse
|
||||
@@ -844,7 +859,7 @@ private sendColorEvents(device, xy, hue, sat, ct, colormode = null) {
|
||||
|
||||
def events = [:]
|
||||
// For now, only care about changing color temperature if requested by user
|
||||
if (ct != null && (colormode == "ct" || (xy == null && hue == null && sat == null))) {
|
||||
if (ct != null && ct != 0 && (colormode == "ct" || (xy == null && hue == null && sat == null))) {
|
||||
// for some reason setting Hue to their specified minimum off 153 yields 154, dealt with below
|
||||
// 153 (6500K) to 500 (2000K)
|
||||
def temp = (ct == 154) ? 6500 : Math.round(1000000 / ct)
|
||||
@@ -1252,7 +1267,7 @@ private getBridgeIP() {
|
||||
if (d) {
|
||||
if (d.getDeviceDataByName("networkAddress"))
|
||||
host = d.getDeviceDataByName("networkAddress")
|
||||
else
|
||||
else
|
||||
host = d.latestState('networkAddress').stringValue
|
||||
}
|
||||
if (host == null || host == "") {
|
||||
|
||||
@@ -289,12 +289,12 @@ def initializeLife360Connection() {
|
||||
state.life360AccessToken = result.data.access_token
|
||||
return true;
|
||||
}
|
||||
log.debug "Response=${result.data}"
|
||||
log.info "Life360 initializeLife360Connection, response=${result.data}"
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
log.debug e
|
||||
log.error "Life360 initializeLife360Connection, error: $e"
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
|
||||
|
||||
try { // we are going to just ignore any errors
|
||||
|
||||
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
|
||||
log.info "Life360 generateInitialEvent($member, $childDevice)"
|
||||
|
||||
def place = state.places.find{it.id==settings.place}
|
||||
|
||||
@@ -677,6 +677,8 @@ def generateInitialEvent (member, childDevice) {
|
||||
// log.debug "Distance Away = ${distanceAway}"
|
||||
|
||||
boolean isPresent = (distanceAway <= placeRadius)
|
||||
|
||||
log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent"
|
||||
|
||||
// log.debug "External Id=${app.id}:${member.id}"
|
||||
|
||||
@@ -718,7 +720,7 @@ def haversine(lat1, lon1, lat2, lon2) {
|
||||
|
||||
def placeEventHandler() {
|
||||
|
||||
log.debug "In placeEventHandler method."
|
||||
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
|
||||
|
||||
// the POST to this end-point will look like:
|
||||
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
||||
@@ -729,8 +731,6 @@ def placeEventHandler() {
|
||||
def direction = params?.direction
|
||||
def timestamp = params?.timestamp
|
||||
|
||||
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
|
||||
|
||||
if (placeId == settings.place) {
|
||||
|
||||
def presenceState = (direction=="in")
|
||||
@@ -745,10 +745,10 @@ def placeEventHandler() {
|
||||
|
||||
if (deviceWrapper) {
|
||||
deviceWrapper.generatePresenceEvent(presenceState)
|
||||
log.debug "Event raised on child device: ${externalId}"
|
||||
log.debug "Life360 event raised on child device: ${externalId}"
|
||||
}
|
||||
else {
|
||||
log.debug "Couldn't find child device associated with inbound Life360 event."
|
||||
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,799 +0,0 @@
|
||||
/** * Home Remote
|
||||
*
|
||||
* Copyright 2015 The Home Remote
|
||||
*
|
||||
* 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: "Home Remote",
|
||||
namespace: "thehomeremote.homeremote",
|
||||
author: "The Home Remote",
|
||||
description: "Web service that enables communication between the Home Remote app and a SmartThings hub.",
|
||||
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",
|
||||
oauth: [displayName: "The Home Remote", displayLink: "http://thehomeremote.com/"])
|
||||
|
||||
|
||||
preferences {
|
||||
section() {
|
||||
input "accelerationSensors", "capability.accelerationSensor",title: "Acceleration Sensors", multiple: true, required: false
|
||||
input "alarms", "capability.alarm",title: "Alarms", multiple: true, required: false
|
||||
input "batteries", "capability.battery",title: "Batteries", multiple: true, required: false
|
||||
input "beacons", "capability.beacon",title: "Beacons", multiple: true, required: false
|
||||
input "buttonGroup", "capability.button",title: "Buttons", multiple: true, required: false
|
||||
input "carbonMonoxideDetectors", "capability.carbonMonoxideDetector",title: "CO Detectors", multiple: true, required: false
|
||||
input "colorControls", "capability.colorControl",title: "Color Lights", multiple: true, required: false
|
||||
input "contactSensors", "capability.contactSensor",title: "Contact Sensors", multiple: true, required: false
|
||||
input "doorControls", "capability.doorControl",title: "Door Controllers", multiple: true, required: false
|
||||
input "energyMeters", "capability.energyMeter",title: "Energy Meters", multiple: true, required: false
|
||||
input "illuminanceMeasurements", "capability.illuminanceMeasurement",title: "Illuminance Sensors", multiple: true, required: false
|
||||
input "imageCaptures", "capability.imageCapture",title: "Cameras", multiple: true, required: false
|
||||
input "locks", "capability.lock",title: "Locks", multiple: true, required: false
|
||||
input "mediaControllers", "capability.mediaController",title: "Media Controllers", multiple: true, required: false
|
||||
input "momentaries", "capability.momentary",title: "Momentary Buttons", multiple: true, required: false
|
||||
input "motionSensors", "capability.motionSensor",title: "Motion Sensors", multiple: true, required: false
|
||||
input "musicPlayers", "capability.musicPlayer",title: "Music Players", multiple: true, required: false
|
||||
input "powerMeters", "capability.powerMeter",title: "Power Meters", multiple: true, required: false
|
||||
input "presenceSensors", "capability.presenceSensor",title: "Presence Sensors", multiple: true, required: false
|
||||
input "relativeHumidityMeasurements", "capability.relativeHumidityMeasurement",title: "Humidity Sensors", multiple: true, required: false
|
||||
input "relaySwitches", "capability.relaySwitch",title: "Relays", multiple: true, required: false
|
||||
input "signalStrengths", "capability.signalStrength",title: "Signal Strengths", multiple: true, required: false
|
||||
input "sleepSensors", "capability.sleepSensor",title: "Sleep Sensors", multiple: true, required: false
|
||||
input "smokeDetectors", "capability.smokeDetector",title: "Smoke Detectors", multiple: true, required: false
|
||||
input "speechSyntheses", "capability.speechSynthesis",title: "Speech Syntheses", multiple: true, required: false
|
||||
input "stepSensors", "capability.stepSensor",title: "Step Sensors", multiple: true, required: false
|
||||
input "switches", "capability.switch",title: "Switches", multiple: true, required: false
|
||||
input "switchLevels", "capability.switchLevel",title: "Dimmers", multiple: true, required: false
|
||||
input "temperatureMeasurements", "capability.temperatureMeasurement",title: "Temperature Sensors", multiple: true, required: false
|
||||
input "thermostats", "capability.thermostat",title: "Thermostats", multiple: true, required: false
|
||||
input "threeAxes", "capability.threeAxis",title: "Three axis Sensors", multiple: true, required: false
|
||||
input "tones", "capability.tone",title: "Tones", multiple: true, required: false
|
||||
input "touchSensors", "capability.touchSensor",title: "Touch Sensors", multiple: true, required: false
|
||||
input "valves", "capability.valve",title: "Valves", multiple: true, required: false
|
||||
input "waterSensors", "capability.waterSensor",title: "Water Sensors", multiple: true, required: false
|
||||
}
|
||||
}
|
||||
|
||||
mappings {
|
||||
path("/GetCurrentValues") {
|
||||
action: [
|
||||
GET: "getCurrentValues"
|
||||
]
|
||||
}
|
||||
path("/GetCurrentValuesWithDisplayName") {
|
||||
action: [
|
||||
GET: "getCurrentValuesWithDisplayName"
|
||||
]
|
||||
}
|
||||
path("/GetRoutines") {
|
||||
action: [
|
||||
GET: "getRoutines"
|
||||
]
|
||||
}
|
||||
path("/ExecuteCommand") {
|
||||
action: [
|
||||
PUT: "executeCommand"
|
||||
]
|
||||
}
|
||||
path("/ExecuteRoutine") {
|
||||
action: [
|
||||
PUT: "executeRoutine"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
def getCurrentValues() {
|
||||
def resp = []
|
||||
|
||||
accelerationSensors.each {
|
||||
resp << [id: it.id, capability: "AccelerationSensor", attribute: "acceleration", value: it.currentValue("acceleration")]
|
||||
}
|
||||
|
||||
alarms.each {
|
||||
resp << [id: it.id, capability: "Alarm", attribute: "alarm", value: it.currentValue("alarm")]
|
||||
}
|
||||
|
||||
batteries.each {
|
||||
resp << [id: it.id, capability: "Battery", attribute: "battery", value: it.currentValue("battery")]
|
||||
}
|
||||
|
||||
beacons.each {
|
||||
resp << [id: it.id, capability: "Beacon", attribute: "presence", value: it.currentValue("presence")]
|
||||
}
|
||||
|
||||
buttonGroup.each {
|
||||
resp << [id: it.id, capability: "Button", attribute: "button", value: it.currentValue("button")]
|
||||
}
|
||||
|
||||
carbonMonoxideDetectors.each {
|
||||
resp << [id: it.id, capability: "CarbonMonoxideDetector", attribute: "carbonMonoxide", value: it.currentValue("carbonMonoxide")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, capability: "ColorControl", attribute: "hue", value: it.currentValue("hue")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, capability: "ColorControl", attribute: "saturation", value: it.currentValue("saturation")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, capability: "ColorControl", attribute: "color", value: it.currentValue("color")]
|
||||
}
|
||||
|
||||
contactSensors.each {
|
||||
resp << [id: it.id, capability: "ContactSensor", attribute: "contact", value: it.currentValue("contact")]
|
||||
}
|
||||
|
||||
doorControls.each {
|
||||
resp << [id: it.id, capability: "DoorControl", attribute: "door", value: it.currentValue("door")]
|
||||
}
|
||||
|
||||
energyMeters.each {
|
||||
resp << [id: it.id, capability: "EnergyMeter", attribute: "energy", value: it.currentValue("energy")]
|
||||
}
|
||||
|
||||
illuminanceMeasurements.each {
|
||||
resp << [id: it.id, capability: "IlluminanceMeasurement", attribute: "illuminance", value: it.currentValue("illuminance")]
|
||||
}
|
||||
|
||||
imageCaptures.each {
|
||||
resp << [id: it.id, capability: "ImageCapture", attribute: "image", value: it.currentValue("image")]
|
||||
}
|
||||
|
||||
locks.each {
|
||||
resp << [id: it.id, capability: "Lock", attribute: "lock", value: it.currentValue("lock")]
|
||||
}
|
||||
|
||||
mediaControllers.each {
|
||||
resp << [id: it.id, capability: "MediaController", attribute: "activities", value: it.currentValue("activities")]
|
||||
}
|
||||
|
||||
mediaControllers.each {
|
||||
resp << [id: it.id, capability: "MediaController", attribute: "currentActivity", value: it.currentValue("currentActivity")]
|
||||
}
|
||||
|
||||
motionSensors.each {
|
||||
resp << [id: it.id, capability: "MotionSensor", attribute: "motion", value: it.currentValue("motion")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, capability: "MusicPlayer", attribute: "status", value: it.currentValue("status")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, capability: "MusicPlayer", attribute: "level", value: it.currentValue("level")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, capability: "MusicPlayer", attribute: "trackDescription", value: it.currentValue("trackDescription")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, capability: "MusicPlayer", attribute: "trackData", value: it.currentValue("trackData")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, capability: "MusicPlayer", attribute: "mute", value: it.currentValue("mute")]
|
||||
}
|
||||
|
||||
powerMeters.each {
|
||||
resp << [id: it.id, capability: "PowerMeter", attribute: "power", value: it.currentValue("power")]
|
||||
}
|
||||
|
||||
presenceSensors.each {
|
||||
resp << [id: it.id, capability: "PresenceSensor", attribute: "presence", value: it.currentValue("presence")]
|
||||
}
|
||||
|
||||
relativeHumidityMeasurements.each {
|
||||
resp << [id: it.id, capability: "RelativeHumidityMeasurement", attribute: "humidity", value: it.currentValue("humidity")]
|
||||
}
|
||||
|
||||
relaySwitches.each {
|
||||
resp << [id: it.id, capability: "RelaySwitch", attribute: "switch", value: it.currentValue("switch")]
|
||||
}
|
||||
|
||||
signalStrengths.each {
|
||||
resp << [id: it.id, capability: "SignalStrength", attribute: "lqi", value: it.currentValue("lqi")]
|
||||
}
|
||||
|
||||
signalStrengths.each {
|
||||
resp << [id: it.id, capability: "SignalStrength", attribute: "rssi", value: it.currentValue("rssi")]
|
||||
}
|
||||
|
||||
sleepSensors.each {
|
||||
resp << [id: it.id, capability: "SleepSensor", attribute: "sleeping", value: it.currentValue("sleeping")]
|
||||
}
|
||||
|
||||
smokeDetectors.each {
|
||||
resp << [id: it.id, capability: "SmokeDetector", attribute: "smoke", value: it.currentValue("smoke")]
|
||||
}
|
||||
|
||||
stepSensors.each {
|
||||
resp << [id: it.id, capability: "StepSensor", attribute: "steps", value: it.currentValue("steps")]
|
||||
}
|
||||
|
||||
stepSensors.each {
|
||||
resp << [id: it.id, capability: "StepSensor", attribute: "goal", value: it.currentValue("goal")]
|
||||
}
|
||||
|
||||
switches.each {
|
||||
resp << [id: it.id, capability: "Switch", attribute: "switch", value: it.currentValue("switch")]
|
||||
}
|
||||
|
||||
switchLevels.each {
|
||||
resp << [id: it.id, capability: "SwitchLevel", attribute: "level", value: it.currentValue("level")]
|
||||
}
|
||||
|
||||
temperatureMeasurements.each {
|
||||
resp << [id: it.id, capability: "TemperatureMeasurement", attribute: "temperature", value: it.currentValue("temperature")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "temperature", value: it.currentValue("temperature")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "heatingSetpoint", value: it.currentValue("heatingSetpoint")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "coolingSetpoint", value: it.currentValue("coolingSetpoint")]
|
||||
}
|
||||
|
||||
//Commented out on 7/23/2016. This randomly started throwing number format exceptions with either my ecobee or Lyric thermostat.
|
||||
//thermostats.each {
|
||||
// resp << [id: it.id, capability: "Thermostat", attribute: "thermostatSetpoint", value: it.currentValue("thermostatSetpoint")]
|
||||
//}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatMode", value: it.currentValue("thermostatMode")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatFanMode", value: it.currentValue("thermostatFanMode")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatOperatingState", value: it.currentValue("thermostatOperatingState")]
|
||||
}
|
||||
|
||||
threeAxes.each {
|
||||
resp << [id: it.id, capability: "ThreeAxis", attribute: "threeAxis", value: it.currentValue("threeAxis")]
|
||||
}
|
||||
|
||||
touchSensors.each {
|
||||
resp << [id: it.id, capability: "TouchSensor", attribute: "touch", value: it.currentValue("touch")]
|
||||
}
|
||||
|
||||
valves.each {
|
||||
resp << [id: it.id, capability: "Valve", attribute: "contact", value: it.currentValue("contact")]
|
||||
}
|
||||
|
||||
waterSensors.each {
|
||||
resp << [id: it.id, capability: "WaterSensor", attribute: "water", value: it.currentValue("water")]
|
||||
}
|
||||
|
||||
//resp << [id: 0, capability: "Heartbeat", attribute: "heartbeat", value: String.valueOf(state.heartbeat)]
|
||||
|
||||
state.heartbeat = !state.heartbeat
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
def getCurrentValuesWithDisplayName() {
|
||||
def resp = []
|
||||
|
||||
accelerationSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "AccelerationSensor", attribute: "acceleration", value: it.currentValue("acceleration")]
|
||||
}
|
||||
|
||||
alarms.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Alarm", attribute: "alarm", value: it.currentValue("alarm")]
|
||||
}
|
||||
|
||||
batteries.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Battery", attribute: "battery", value: it.currentValue("battery")]
|
||||
}
|
||||
|
||||
beacons.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Beacon", attribute: "presence", value: it.currentValue("presence")]
|
||||
}
|
||||
|
||||
buttonGroup.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Button", attribute: "button", value: it.currentValue("button")]
|
||||
}
|
||||
|
||||
carbonMonoxideDetectors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "CarbonMonoxideDetector", attribute: "carbonMonoxide", value: it.currentValue("carbonMonoxide")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "hue", value: it.currentValue("hue")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "saturation", value: it.currentValue("saturation")]
|
||||
}
|
||||
|
||||
colorControls.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "color", value: it.currentValue("color")]
|
||||
}
|
||||
|
||||
contactSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ContactSensor", attribute: "contact", value: it.currentValue("contact")]
|
||||
}
|
||||
|
||||
doorControls.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "DoorControl", attribute: "door", value: it.currentValue("door")]
|
||||
}
|
||||
|
||||
energyMeters.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "EnergyMeter", attribute: "energy", value: it.currentValue("energy")]
|
||||
}
|
||||
|
||||
illuminanceMeasurements.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "IlluminanceMeasurement", attribute: "illuminance", value: it.currentValue("illuminance")]
|
||||
}
|
||||
|
||||
imageCaptures.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ImageCapture", attribute: "image", value: it.currentValue("image")]
|
||||
}
|
||||
|
||||
locks.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Lock", attribute: "lock", value: it.currentValue("lock")]
|
||||
}
|
||||
|
||||
mediaControllers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MediaController", attribute: "activities", value: it.currentValue("activities")]
|
||||
}
|
||||
|
||||
mediaControllers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MediaController", attribute: "currentActivity", value: it.currentValue("currentActivity")]
|
||||
}
|
||||
|
||||
motionSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MotionSensor", attribute: "motion", value: it.currentValue("motion")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "status", value: it.currentValue("status")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "level", value: it.currentValue("level")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "trackDescription", value: it.currentValue("trackDescription")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "trackData", value: it.currentValue("trackData")]
|
||||
}
|
||||
|
||||
musicPlayers.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "mute", value: it.currentValue("mute")]
|
||||
}
|
||||
|
||||
powerMeters.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "PowerMeter", attribute: "power", value: it.currentValue("power")]
|
||||
}
|
||||
|
||||
presenceSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "PresenceSensor", attribute: "presence", value: it.currentValue("presence")]
|
||||
}
|
||||
|
||||
relativeHumidityMeasurements.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "RelativeHumidityMeasurement", attribute: "humidity", value: it.currentValue("humidity")]
|
||||
}
|
||||
|
||||
relaySwitches.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "RelaySwitch", attribute: "switch", value: it.currentValue("switch")]
|
||||
}
|
||||
|
||||
signalStrengths.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "SignalStrength", attribute: "lqi", value: it.currentValue("lqi")]
|
||||
}
|
||||
|
||||
signalStrengths.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "SignalStrength", attribute: "rssi", value: it.currentValue("rssi")]
|
||||
}
|
||||
|
||||
sleepSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "SleepSensor", attribute: "sleeping", value: it.currentValue("sleeping")]
|
||||
}
|
||||
|
||||
smokeDetectors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "SmokeDetector", attribute: "smoke", value: it.currentValue("smoke")]
|
||||
}
|
||||
|
||||
stepSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "StepSensor", attribute: "steps", value: it.currentValue("steps")]
|
||||
}
|
||||
|
||||
stepSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "StepSensor", attribute: "goal", value: it.currentValue("goal")]
|
||||
}
|
||||
|
||||
switches.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Switch", attribute: "switch", value: it.currentValue("switch")]
|
||||
}
|
||||
|
||||
switchLevels.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "SwitchLevel", attribute: "level", value: it.currentValue("level")]
|
||||
}
|
||||
|
||||
temperatureMeasurements.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "TemperatureMeasurement", attribute: "temperature", value: it.currentValue("temperature")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "temperature", value: it.currentValue("temperature")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "heatingSetpoint", value: it.currentValue("heatingSetpoint")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "coolingSetpoint", value: it.currentValue("coolingSetpoint")]
|
||||
}
|
||||
|
||||
//Commented out on 7/23/2016. This randomly started throwing number format exceptions with either my ecobee or Lyric thermostat.
|
||||
//thermostats.each {
|
||||
// resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatSetpoint", value: it.currentValue("thermostatSetpoint")]
|
||||
//}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatMode", value: it.currentValue("thermostatMode")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatFanMode", value: it.currentValue("thermostatFanMode")]
|
||||
}
|
||||
|
||||
thermostats.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatOperatingState", value: it.currentValue("thermostatOperatingState")]
|
||||
}
|
||||
|
||||
threeAxes.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "ThreeAxis", attribute: "threeAxis", value: it.currentValue("threeAxis")]
|
||||
}
|
||||
|
||||
touchSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "TouchSensor", attribute: "touch", value: it.currentValue("touch")]
|
||||
}
|
||||
|
||||
valves.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Valve", attribute: "contact", value: it.currentValue("contact")]
|
||||
}
|
||||
|
||||
waterSensors.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "WaterSensor", attribute: "water", value: it.currentValue("water")]
|
||||
}
|
||||
|
||||
momentaries.each {
|
||||
resp << [id: it.id, displayName: it.displayName, capability: "Momentary", attribute: "", value: ""]
|
||||
}
|
||||
|
||||
//resp << [id: 0, displayName: "Heartbeat", capability: "Heartbeat", attribute: "heartbeat", value: state.heartbeat]
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
def getDevices(capability){
|
||||
|
||||
def result
|
||||
|
||||
switch (capability) {
|
||||
case "Alarm":
|
||||
result = alarms
|
||||
break
|
||||
case "ColorControl":
|
||||
result = colorControls
|
||||
break
|
||||
case "DoorControl":
|
||||
result = doorControls
|
||||
break
|
||||
case "ImageCapture":
|
||||
result = imageCaptures
|
||||
break
|
||||
case "Lock":
|
||||
result = locks
|
||||
break
|
||||
case "MediaController":
|
||||
result = mediaControllers
|
||||
break
|
||||
case "Momentary":
|
||||
result = momentaries
|
||||
break
|
||||
case "MusicPlayer":
|
||||
result = musicPlayers
|
||||
break
|
||||
case "RelaySwitch":
|
||||
result = relaySwitches
|
||||
break
|
||||
case "SpeechSynthesis":
|
||||
result = speechSyntheses
|
||||
break
|
||||
case "Switch":
|
||||
result = switches
|
||||
break
|
||||
case "SwitchLevel":
|
||||
result = switchLevels
|
||||
break
|
||||
case "Thermostat":
|
||||
result = thermostats
|
||||
break
|
||||
case "ThermostatCoolingSetpoint":
|
||||
result = thermostatCoolingSetpoints
|
||||
break
|
||||
case "ThermostatFanMode":
|
||||
result = thermostatFanModes
|
||||
break
|
||||
case "ThermostatHeatingSetpoint":
|
||||
result = thermostatHeatingSetpoints
|
||||
break
|
||||
case "ThermostatMode":
|
||||
result = thermostatModes
|
||||
break
|
||||
case "Tone":
|
||||
result = tones
|
||||
break
|
||||
case "Valve":
|
||||
result = valves
|
||||
break
|
||||
default:
|
||||
result = valves
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def getDoorControlCommand(value){
|
||||
def result
|
||||
switch (value) {
|
||||
case "closed":
|
||||
result = "close"
|
||||
break
|
||||
case "open":
|
||||
result = "open"
|
||||
break
|
||||
default:
|
||||
result = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def getLockCommand(value){
|
||||
def result
|
||||
switch (value) {
|
||||
case "locked":
|
||||
result = "lock"
|
||||
break
|
||||
case "unlocked":
|
||||
result = "unlock"
|
||||
break
|
||||
default:
|
||||
result = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def getMuteCommand(value){
|
||||
def result
|
||||
switch (value) {
|
||||
case "muted":
|
||||
result = "mute"
|
||||
break
|
||||
case "unmuted":
|
||||
result = "unmute"
|
||||
break
|
||||
default:
|
||||
result = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def getContactCommand(value){
|
||||
def result
|
||||
switch (value) {
|
||||
case "closed":
|
||||
result = "close"
|
||||
break
|
||||
case "open":
|
||||
result = "open"
|
||||
break
|
||||
default:
|
||||
result = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
def getRoutines() {
|
||||
return location.helloHome?.getPhrases()*.label
|
||||
}
|
||||
|
||||
def getThermostatFanModeCommand(value){
|
||||
def result
|
||||
switch (value) {
|
||||
case "on":
|
||||
result = "fanOn"
|
||||
break
|
||||
case "auto":
|
||||
result = "fanAuto"
|
||||
break
|
||||
case "circulate":
|
||||
result = "fanCirculate"
|
||||
break
|
||||
default:
|
||||
result = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
void executeCommand() {
|
||||
def deviceId = request.JSON?.deviceId
|
||||
def capability = request.JSON?.capability
|
||||
def attribute = request.JSON?.attribute
|
||||
def value = request.JSON?.value
|
||||
if (deviceId) {
|
||||
def devices = getDevices(capability)
|
||||
def command
|
||||
def valueIsParameter = false
|
||||
def valueIsInteger = false
|
||||
switch (attribute) {
|
||||
case "hue":
|
||||
command = "setHue"
|
||||
valueIsParameter = true
|
||||
valueIsInteger = true
|
||||
break
|
||||
case "saturation":
|
||||
command = "setSaturation"
|
||||
valueIsParameter = true
|
||||
valueIsInteger = true
|
||||
break
|
||||
case "color":
|
||||
command = "setColor"
|
||||
def rgb = hexToRgb(value)
|
||||
def hsl = rgbToHSL(rgb)
|
||||
value = [hue:hsl.h.toInteger(), saturation:hsl.s.toInteger()]
|
||||
valueIsParameter = true
|
||||
break
|
||||
case "level":
|
||||
command = "setLevel"
|
||||
valueIsParameter = true
|
||||
valueIsInteger = true
|
||||
break
|
||||
case "heatingSetpoint":
|
||||
command = "setHeatingSetpoint"
|
||||
valueIsParameter = true
|
||||
break
|
||||
case "coolingSetpoint":
|
||||
command = "setCoolingSetpoint"
|
||||
valueIsParameter = true
|
||||
break
|
||||
case "currentActivity":
|
||||
command = "startActivity"
|
||||
valueIsParameter = true
|
||||
break
|
||||
case "door":
|
||||
command = getDoorControlCommand(value)
|
||||
break
|
||||
case "lock":
|
||||
command = getLockCommand(value)
|
||||
break
|
||||
case "mute":
|
||||
command = getMuteCommand(value)
|
||||
break
|
||||
case "thermostatFanMode":
|
||||
command = getThermostatFanModeCommand(value)
|
||||
break
|
||||
case "thermostatMode":
|
||||
if (value == "emergency heat") {
|
||||
command = "emergencyHeat"
|
||||
}
|
||||
else
|
||||
{
|
||||
command = value
|
||||
}
|
||||
break
|
||||
case "contact":
|
||||
command = getContactCommand(value)
|
||||
break
|
||||
default:
|
||||
command = value
|
||||
}
|
||||
devices.each {
|
||||
if (it.id == deviceId) {
|
||||
// check that the device supports the specified command
|
||||
// If not, return an error using httpError, providing a HTTP status code.
|
||||
if (!it.hasCommand(command)) {
|
||||
httpError(501, "$command is not a valid command for the device")
|
||||
}
|
||||
if(valueIsParameter){
|
||||
if(valueIsInteger){
|
||||
it."$command"(value as int)
|
||||
}
|
||||
else{
|
||||
it."$command"(value)
|
||||
}
|
||||
}
|
||||
else{
|
||||
it."$command"()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void executeRoutine() {
|
||||
def routine = request.JSON?.routine
|
||||
location.helloHome?.execute(routine)
|
||||
}
|
||||
|
||||
def rgbToHSL(rgb) {
|
||||
def r = rgb.r / 255
|
||||
def g = rgb.g / 255
|
||||
def b = rgb.b / 255
|
||||
def h = 0
|
||||
def s = 0
|
||||
def l = 0
|
||||
|
||||
def var_min = [r,g,b].min()
|
||||
def var_max = [r,g,b].max()
|
||||
def del_max = var_max - var_min
|
||||
|
||||
l = (var_max + var_min) / 2
|
||||
|
||||
if (del_max == 0) {
|
||||
h = 0
|
||||
s = 0
|
||||
} else {
|
||||
if (l < 0.5) { s = del_max / (var_max + var_min) }
|
||||
else { s = del_max / (2 - var_max - var_min) }
|
||||
|
||||
def del_r = (((var_max - r) / 6) + (del_max / 2)) / del_max
|
||||
def del_g = (((var_max - g) / 6) + (del_max / 2)) / del_max
|
||||
def del_b = (((var_max - b) / 6) + (del_max / 2)) / del_max
|
||||
|
||||
if (r == var_max) { h = del_b - del_g }
|
||||
else if (g == var_max) { h = (1 / 3) + del_r - del_b }
|
||||
else if (b == var_max) { h = (2 / 3) + del_g - del_r }
|
||||
|
||||
if (h < 0) { h += 1 }
|
||||
if (h > 1) { h -= 1 }
|
||||
}
|
||||
def hsl = [:]
|
||||
hsl = [h: h * 100, s: s * 100, l: l]
|
||||
|
||||
hsl
|
||||
}
|
||||
|
||||
def hexToRgb(colorHex) {
|
||||
def rrInt = Integer.parseInt(colorHex.substring(1,3),16)
|
||||
def ggInt = Integer.parseInt(colorHex.substring(3,5),16)
|
||||
def bbInt = Integer.parseInt(colorHex.substring(5,7),16)
|
||||
|
||||
def colorData = [:]
|
||||
colorData = [r: rrInt, g: ggInt, b: bbInt]
|
||||
colorData
|
||||
}
|
||||
|
||||
def installed() {
|
||||
state.heartbeat = false
|
||||
}
|
||||
|
||||
def updated() {
|
||||
state.heartbeat = false
|
||||
}
|
||||
Reference in New Issue
Block a user