mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-20 21:03:46 +00:00
Compare commits
1 Commits
PROD_2017.
...
MSA-1638-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8925e133c7 |
@@ -22,10 +22,9 @@ metadata {
|
|||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
|
||||||
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "GE In-Wall Smart Dimmer "
|
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "Z-Wave Wall Dimmer"
|
||||||
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "GE In-Wall Smart Dimmer "
|
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "Z-Wave Wall Dimmer"
|
||||||
fingerprint mfr:"0063", prod:"5044", deviceJoinName: "GE Plug-In Smart Dimmer "
|
fingerprint mfr:"0063", prod:"5044", deviceJoinName: "Z-Wave Plug-In Dimmer"
|
||||||
fingerprint mfr:"0063", prod:"4944", model:"3034", deviceJoinName: "GE In-Wall Smart Fan Control"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def parse(String description) {
|
|||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
def refreshCmds = [
|
def refreshCmds = [
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
|
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
|
||||||
]
|
]
|
||||||
|
|
||||||
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
@@ -197,7 +197,7 @@ def off() {
|
|||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
def refreshCmds = [
|
def refreshCmds = [
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
|
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
|
||||||
]
|
]
|
||||||
|
|
||||||
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig()
|
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def generatePresenceEvent(boolean present) {
|
def generatePresenceEvent(boolean present) {
|
||||||
log.info "Life360 generatePresenceEvent($present)"
|
log.debug "Here in generatePresenceEvent!"
|
||||||
def value = formatValue(present)
|
def value = formatValue(present)
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
def descriptionText = formatDescriptionText(linkText, present)
|
def descriptionText = formatDescriptionText(linkText, present)
|
||||||
|
|||||||
@@ -128,9 +128,9 @@ def setLevel(value) {
|
|||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
[
|
[
|
||||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 2000",
|
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 500",
|
||||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 2000",
|
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 500",
|
||||||
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 2000"
|
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 500"
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -313,9 +313,9 @@ def isDescriptionPower(descMap) {
|
|||||||
|
|
||||||
def onOffConfig() {
|
def onOffConfig() {
|
||||||
[
|
[
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 2000",
|
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 200",
|
||||||
"zcl global send-me-a-report 6 0 0x10 0 600 {01}", "delay 200",
|
"zcl global send-me-a-report 6 0 0x10 0 600 {01}",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,9 +323,9 @@ def onOffConfig() {
|
|||||||
//min level change is 01
|
//min level change is 01
|
||||||
def levelConfig() {
|
def levelConfig() {
|
||||||
[
|
[
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 2000",
|
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 200",
|
||||||
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}", "delay 200",
|
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,10 +333,9 @@ def levelConfig() {
|
|||||||
//min change in value is 05
|
//min change in value is 05
|
||||||
def powerConfig() {
|
def powerConfig() {
|
||||||
[
|
[
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
|
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
|
||||||
"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
|
"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
|
||||||
"delay 200",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,10 +344,7 @@ def setLevelWithRate(level, rate) {
|
|||||||
rate = "0000"
|
rate = "0000"
|
||||||
}
|
}
|
||||||
level = convertToHexString(level * 255 / 100) //Converting the 0-100 range to 0-FF range in hex
|
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) {
|
String convertToHexString(value, width=2) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def on() {
|
|||||||
'zcl on-off on',
|
'zcl on-off on',
|
||||||
'delay 200',
|
'delay 200',
|
||||||
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
||||||
'delay 2000'
|
'delay 500'
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -62,6 +62,6 @@ def off() {
|
|||||||
'zcl on-off off',
|
'zcl on-off off',
|
||||||
'delay 200',
|
'delay 200',
|
||||||
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
|
||||||
'delay 2000'
|
'delay 500'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,10 +157,9 @@ def configure() {
|
|||||||
//min change in value is 01
|
//min change in value is 01
|
||||||
def powerConfig() {
|
def powerConfig() {
|
||||||
[
|
[
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
|
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
|
||||||
"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
|
"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
|
||||||
"delay 200",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,9 @@ metadata {
|
|||||||
command "enrollResponse"
|
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-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"
|
||||||
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-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"
|
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500", outClusters: "0019", manufacturer: "SmartThings", model: "moisturev4", deviceJoinName: "Water Leak Sensor"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -286,8 +285,8 @@ def ping() {
|
|||||||
def refresh() {
|
def refresh() {
|
||||||
log.debug "Refreshing Temperature and Battery"
|
log.debug "Refreshing Temperature and Battery"
|
||||||
def refreshCmds = [
|
def refreshCmds = [
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||||
]
|
]
|
||||||
|
|
||||||
return refreshCmds + enrollResponse()
|
return refreshCmds + enrollResponse()
|
||||||
@@ -309,10 +308,10 @@ def enrollResponse() {
|
|||||||
[
|
[
|
||||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||||
//Enroll Response
|
//Enroll Response
|
||||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
"raw 0x500 {01 23 00 00 00}",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -298,8 +298,8 @@ def ping() {
|
|||||||
def refresh() {
|
def refresh() {
|
||||||
log.debug "refresh called"
|
log.debug "refresh called"
|
||||||
def refreshCmds = [
|
def refreshCmds = [
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||||
]
|
]
|
||||||
|
|
||||||
return refreshCmds + enrollResponse()
|
return refreshCmds + enrollResponse()
|
||||||
@@ -321,10 +321,10 @@ def enrollResponse() {
|
|||||||
[
|
[
|
||||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||||
//Enroll Response
|
//Enroll Response
|
||||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
"raw 0x500 {01 23 00 00 00}",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if(cluster.data[0] == 0x00) {
|
if(cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
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}"
|
log.debug "Contact: ${device.displayName} value = ${value}"
|
||||||
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
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: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
||||||
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
|
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAccelerationResult(numValue) {
|
private getAccelerationResult(numValue) {
|
||||||
@@ -428,10 +428,10 @@ def enrollResponse() {
|
|||||||
[
|
[
|
||||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||||
//Enroll Response
|
//Enroll Response
|
||||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07){
|
if (cluster.command == 0x07){
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -252,8 +252,8 @@ def ping() {
|
|||||||
def refresh() {
|
def refresh() {
|
||||||
log.debug "Refreshing Temperature and Battery"
|
log.debug "Refreshing Temperature and Battery"
|
||||||
def refreshCmds = [
|
def refreshCmds = [
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
|
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
|
||||||
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
|
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
|
||||||
]
|
]
|
||||||
|
|
||||||
return refreshCmds + enrollResponse()
|
return refreshCmds + enrollResponse()
|
||||||
@@ -277,10 +277,10 @@ def enrollResponse() {
|
|||||||
[
|
[
|
||||||
//Resending the CIE in case the enroll request is sent before CIE is written
|
//Resending the CIE in case the enroll request is sent before CIE is written
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||||
//Enroll Response
|
//Enroll Response
|
||||||
"raw 0x500 {01 23 00 00 00}", "delay 200",
|
"raw 0x500 {01 23 00 00 00}",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -270,9 +270,9 @@ def configure() {
|
|||||||
|
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
def humidityConfigCmds = [
|
def humidityConfigCmds = [
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 2000",
|
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
|
||||||
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}", "delay 200",
|
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
||||||
]
|
]
|
||||||
|
|
||||||
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse(description) {
|
def parse(String description) {
|
||||||
|
def pair = description.split(":")
|
||||||
|
createEvent(name: pair[0].trim(), value: pair[1].trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
def on() {
|
def on() {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ def parse(String description) {
|
|||||||
def bodyString = msg.body
|
def bodyString = msg.body
|
||||||
if (bodyString) {
|
if (bodyString) {
|
||||||
unschedule("setOffline")
|
unschedule("setOffline")
|
||||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
def body = new XmlSlurper().parseText(bodyString)
|
||||||
|
|
||||||
if (body?.property?.TimeSyncRequest?.text()) {
|
if (body?.property?.TimeSyncRequest?.text()) {
|
||||||
log.trace "Got TimeSyncRequest"
|
log.trace "Got TimeSyncRequest"
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def parse(String description) {
|
|||||||
def bodyString = msg.body
|
def bodyString = msg.body
|
||||||
if (bodyString) {
|
if (bodyString) {
|
||||||
unschedule("setOffline")
|
unschedule("setOffline")
|
||||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
def body = new XmlSlurper().parseText(bodyString)
|
||||||
if (body?.property?.TimeSyncRequest?.text()) {
|
if (body?.property?.TimeSyncRequest?.text()) {
|
||||||
log.trace "Got TimeSyncRequest"
|
log.trace "Got TimeSyncRequest"
|
||||||
result << timeSyncResponse()
|
result << timeSyncResponse()
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def parse(String description) {
|
|||||||
def bodyString = msg.body
|
def bodyString = msg.body
|
||||||
if (bodyString) {
|
if (bodyString) {
|
||||||
unschedule("setOffline")
|
unschedule("setOffline")
|
||||||
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", ""))
|
def body = new XmlSlurper().parseText(bodyString)
|
||||||
if (body?.property?.TimeSyncRequest?.text()) {
|
if (body?.property?.TimeSyncRequest?.text()) {
|
||||||
log.trace "Got TimeSyncRequest"
|
log.trace "Got TimeSyncRequest"
|
||||||
result << timeSyncResponse()
|
result << timeSyncResponse()
|
||||||
|
|||||||
@@ -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, 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, 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, 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, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model:"3450-L", deviceJoinName: "Iris KeyFob"
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {}
|
simulator {}
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0702, 0B05", outClusters: "0019", manufacturer: "sengled", model: "E11-G13", deviceJoinName: "Sengled Element Classic"
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL6HD", deviceJoinName: "Leviton Dimmer Switch"
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL3HL", deviceJoinName: "Leviton Lumina RF Plug-In Dimmer"
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL1KD", deviceJoinName: "Leviton Lumina RF Dimmer Switch"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15A", deviceJoinName: "Leviton Lumina RF Plug-In Appliance Module"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulator metadata
|
// simulator metadata
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ metadata {
|
|||||||
fingerprint inClusters: "0x26", deviceJoinName: "Z-Wave Dimmer"
|
fingerprint inClusters: "0x26", deviceJoinName: "Z-Wave Dimmer"
|
||||||
fingerprint mfr:"001D", prod:"1902", 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:"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 {
|
simulator {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ metadata {
|
|||||||
fingerprint mfr: "0060", prod: "0001", model: "0002", deviceJoinName: "Everspring Motion Sensor" // Everspring SP814
|
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: "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: "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 {
|
simulator {
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ metadata {
|
|||||||
fingerprint mfr:"0063", prod:"4F50", model:"3031", deviceJoinName: "GE Plug-in Outdoor Switch"
|
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:"1D04", model:"0334", deviceJoinName: "Leviton Outlet"
|
||||||
fingerprint mfr:"001D", prod:"1C02", model:"0334", deviceJoinName: "Leviton Switch"
|
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
|
// simulator metadata
|
||||||
|
|||||||
@@ -26,23 +26,44 @@ definition(
|
|||||||
|
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
|
section("Control these contact sensors...") {
|
||||||
|
input "contact", "capability.contactSensor", multiple:true, required:false
|
||||||
|
}
|
||||||
section("Control these switches...") {
|
section("Control these switches...") {
|
||||||
input "switches", "capability.switch", multiple:true
|
input "switches", "capability.switch", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these smoke alarms...") {
|
||||||
|
input "smoke_alarms", "capability.smokeDetector", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these window shades...") {
|
||||||
|
input "shades", "capability.windowShade", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these garage doors...") {
|
||||||
|
input "garage", "capability.garageDoorControl", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these water sensors...") {
|
||||||
|
input "water_sensors", "capability.waterSensor", multiple:true, required:false
|
||||||
}
|
}
|
||||||
section("Control these motion sensors...") {
|
section("Control these motion sensors...") {
|
||||||
input "motions", "capability.motionSensor", multiple:true
|
input "motions", "capability.motionSensor", multiple:true, required:false
|
||||||
}
|
}
|
||||||
section("Control these presence sensors...") {
|
section("Control these presence sensors...") {
|
||||||
input "presence_sensors", "capability.presenceSensor", multiple:true
|
input "presence_sensors", "capability.presenceSensor", multiple:true, required:false
|
||||||
}
|
}
|
||||||
section("Control these outlets...") {
|
section("Control these outlets...") {
|
||||||
input "outlets", "capability.switch", multiple:true
|
input "outlets", "capability.switch", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these power meters...") {
|
||||||
|
input "meters", "capability.powerMeter", multiple:true, required:false
|
||||||
}
|
}
|
||||||
section("Control these locks...") {
|
section("Control these locks...") {
|
||||||
input "locks", "capability.lock", multiple:true
|
input "locks", "capability.lock", multiple:true, required:false
|
||||||
}
|
}
|
||||||
section("Control these locks...") {
|
section("Control these temperature sensors...") {
|
||||||
input "temperature_sensors", "capability.temperatureMeasurement"
|
input "temperature_sensors", "capability.temperatureMeasurement", multiple:true, required:false
|
||||||
|
}
|
||||||
|
section("Control these batteries...") {
|
||||||
|
input "batteries", "capability.battery", multiple:true, required:false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +82,13 @@ def updated() {
|
|||||||
|
|
||||||
def initialize() {
|
def initialize() {
|
||||||
// TODO: subscribe to attributes, devices, locations, etc.
|
// TODO: subscribe to attributes, devices, locations, etc.
|
||||||
subscribe(outlet, "energy", outletHandler)
|
//subscribe(outlet, "energy", outletHandler)
|
||||||
subscribe(outlet, "switch", outletHandler)
|
//subscribe(outlet, "switch", outletHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement event handlers
|
// TODO: implement event handlers
|
||||||
def outletHandler(evt) {
|
def outletHandler(evt) {
|
||||||
log.debug "$outlet.currentEnergy"
|
//log.debug "$outlet.currentEnergy"
|
||||||
//TODO call G API
|
//TODO call G API
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,9 +104,14 @@ mappings {
|
|||||||
GET: "getAllDevices"
|
GET: "getAllDevices"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/doorlocks/:id/:command") {
|
path("/doorlocks/lock/:id") {
|
||||||
action: [
|
action: [
|
||||||
GET: "updateDoorLock"
|
GET: "lockDoorLock"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/doorlocks/unlock/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "unlockDoorLock"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/doorlocks/:id") {
|
path("/doorlocks/:id") {
|
||||||
@@ -93,10 +119,70 @@ mappings {
|
|||||||
GET: "getDoorLockStatus"
|
GET: "getDoorLockStatus"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
path("/contacts/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getContactStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/smoke/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getSmokeStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/shades/open/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "openShade"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/shades/preset/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "presetShade"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/shades/close/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "closeShade"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/shades/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getShadeStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/garage/open/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "openGarage"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/garage/close/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "closeGarage"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/garage/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getGarageStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/watersensors/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getWaterSensorStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
path("/tempsensors/:id") {
|
path("/tempsensors/:id") {
|
||||||
action: [
|
action: [
|
||||||
GET: "getTempSensorsStatus"
|
GET: "getTempSensorsStatus"
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
path("/meters/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getMeterStatus"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/batteries/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getBatteryStatus"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
path("/presences/:id") {
|
path("/presences/:id") {
|
||||||
action: [
|
action: [
|
||||||
@@ -113,14 +199,29 @@ mappings {
|
|||||||
GET: "getOutletStatus"
|
GET: "getOutletStatus"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/outlets/:id/:command") {
|
path("/outlets/turnon/:id") {
|
||||||
action: [
|
action: [
|
||||||
GET: "updateOutlet"
|
GET: "turnOnOutlet"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/switches/:command") {
|
path("/outlets/turnoff/:id") {
|
||||||
action: [
|
action: [
|
||||||
PUT: "updateSwitch"
|
GET: "turnOffOutlet"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/switches/turnon/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "turnOnSwitch"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/switches/turnoff/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "turnOffSwitch"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/switches/:id") {
|
||||||
|
action: [
|
||||||
|
GET: "getSwitchStatus"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,12 +229,149 @@ mappings {
|
|||||||
//API Methods
|
//API Methods
|
||||||
def getAllDevices() {
|
def getAllDevices() {
|
||||||
def locks_list = locks.collect{device(it,"Lock")}
|
def locks_list = locks.collect{device(it,"Lock")}
|
||||||
|
def contact_list = contact.collect{device(it,"Contact Sensor")}
|
||||||
|
def smokes_list = smoke_alarms.collect{device(it,"Smoke Alarm")}
|
||||||
|
def shades_list = shades.collect{device(it,"Window Shade")}
|
||||||
|
def garage_list = garage.collect{device(it,"Garage Door")}
|
||||||
|
def water_sensors_list = water_sensors.collect{device(it,"Water Sensor")}
|
||||||
def presences_list = presence_sensors.collect{device(it,"Presence")}
|
def presences_list = presence_sensors.collect{device(it,"Presence")}
|
||||||
def motions_list = motions.collect{device(it,"Motion")}
|
def motions_list = motions.collect{device(it,"Motion")}
|
||||||
def outlets_list = outlets.collect{device(it,"Outlet")}
|
def outlets_list = outlets.collect{device(it,"Outlet")}
|
||||||
def switches_list = switches.collect{device(it,"Switch")}
|
def switches_list = switches.collect{device(it,"Switch")}
|
||||||
def temp_list = temperature_sensors.collect{device(it,"Temperature")}
|
def temp_list = temperature_sensors.collect{device(it,"Temperature")}
|
||||||
return [Locks: locks_list, Presences: presences_list, Motions: motions_list, Outlets: outlets_list, Switches: switches_list, Temperatures: temp_list]
|
def meters_list = meters.collect{device(it,"Power Meters")}
|
||||||
|
def battery_list = batteries.collect{device(it,"Batteries")}
|
||||||
|
return smokes_list + contact_list + water_sensors_list + shades_list + garage_list + locks_list + presences_list + motions_list + outlets_list + switches_list + temp_list + meters_list + battery_list
|
||||||
|
}
|
||||||
|
|
||||||
|
//contact sensors
|
||||||
|
def getContactStatus() {
|
||||||
|
def device = contact.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
def args = getTempSensorsStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('contact')] + args
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//smoke detectors
|
||||||
|
def getSmokeStatus() {
|
||||||
|
def device = smoke_alarms.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('smoke')] + bat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//garage
|
||||||
|
def getGarageStatus() {
|
||||||
|
def device = garage.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
return [Device_state: device.currentValue('door')]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def openGarage() {
|
||||||
|
def device = garage.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.open();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def closeGarage() {
|
||||||
|
def device = garage.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.close();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//shades
|
||||||
|
def getShadeStatus() {
|
||||||
|
def device = shades.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
return [Device_state: device.currentValue('windowShade')]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def openShade() {
|
||||||
|
def device = shades.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.open();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def presetShade() {
|
||||||
|
def device = shades.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.presetPosition();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def closeShade() {
|
||||||
|
def device = shades.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.close();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//water sensor
|
||||||
|
def getWaterSensorStatus() {
|
||||||
|
def device = water_sensors.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('water')] + bat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//batteries
|
||||||
|
def getBatteryStatus() {
|
||||||
|
def device = batteries.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
return [Device_state: device.latestValue("battery")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getBatteryStatus(id) {
|
||||||
|
def device = batteries.find { it.id == id }
|
||||||
|
if (!device) {
|
||||||
|
return []
|
||||||
|
} else {
|
||||||
|
return [battery_state: device.latestValue("battery")]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//LOCKS
|
//LOCKS
|
||||||
@@ -142,30 +380,34 @@ def getDoorLockStatus() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
return [Device_state: device.currentValue('lock')]
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('lock')] + bat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateDoorLock() {
|
def lockDoorLock() {
|
||||||
def command = params.command
|
|
||||||
def device = locks.find { it.id == params.id }
|
def device = locks.find { it.id == params.id }
|
||||||
if (command){
|
if (!device) {
|
||||||
if (!device) {
|
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
if(command == "toggle")
|
|
||||||
{
|
|
||||||
if(device.currentValue('lock') == "locked")
|
|
||||||
device.unlock();
|
|
||||||
else
|
|
||||||
device.lock();
|
|
||||||
|
|
||||||
return [Device_id: params.id, result_action: "200"]
|
device.lock();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
def unlockDoorLock() {
|
||||||
|
def device = locks.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.unlock();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
//PRESENCE
|
//PRESENCE
|
||||||
def getPresenceStatus() {
|
def getPresenceStatus() {
|
||||||
|
|
||||||
@@ -173,7 +415,8 @@ def getPresenceStatus() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
return [Device_state: device.currentValue('presence')]
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('presence')] + bat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +427,8 @@ def getMotionStatus() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
return [Device_state: device.currentValue('motion')]
|
def args = getTempSensorsStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('motion')] + args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,52 +439,98 @@ def getOutletStatus() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
return [Device_state: device.currentSwitch, Current_watt: device.currentValue("energy")]
|
def watt = getMeterStatus(device.id)
|
||||||
|
return [Device_state: device.currentSwitch] + watt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateOutlet() {
|
def getMeterStatus() {
|
||||||
|
|
||||||
def command = params.command
|
def device = meters.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
return [Device_id: device.id, Device_type: device.type, Current_watt: device.currentValue("power")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getMeterStatus(id) {
|
||||||
|
|
||||||
|
def device = meters.find { it.id == id }
|
||||||
|
if (!device) {
|
||||||
|
return []
|
||||||
|
} else {
|
||||||
|
return [Current_watt: device.currentValue("power")]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def turnOnOutlet() {
|
||||||
def device = outlets.find { it.id == params.id }
|
def device = outlets.find { it.id == params.id }
|
||||||
if (command){
|
if (command){
|
||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
if(command == "toggle")
|
|
||||||
{
|
|
||||||
if(device.currentSwitch == "on")
|
|
||||||
device.off();
|
|
||||||
else
|
|
||||||
device.on();
|
|
||||||
|
|
||||||
return [Device_id: params.id, result_action: "200"]
|
device.on();
|
||||||
}
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def turnOffOutlet() {
|
||||||
|
def device = outlets.find { it.id == params.id }
|
||||||
|
if (command){
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.off();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//SWITCH
|
//SWITCH
|
||||||
def updateSwitch() {
|
def getSwitchStatus() {
|
||||||
def command = params.command
|
def device = switches.find { it.id == params.id }
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
return [Device_state: device.currentValue('switch')]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def turnOnSwitch() {
|
||||||
def device = switches.find { it.id == params.id }
|
def device = switches.find { it.id == params.id }
|
||||||
if (command){
|
if (command){
|
||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
if(command == "toggle")
|
|
||||||
{
|
|
||||||
if(device.currentSwitch == "on")
|
|
||||||
device.off();
|
|
||||||
else
|
|
||||||
device.on();
|
|
||||||
|
|
||||||
return [Device_id: params.id, result_action: "200"]
|
device.on();
|
||||||
}
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def turnOffSwitch() {
|
||||||
|
def device = switches.find { it.id == params.id }
|
||||||
|
if (command){
|
||||||
|
if (!device) {
|
||||||
|
httpError(404, "Device not found")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
device.on();
|
||||||
|
|
||||||
|
return [Device_id: params.id, result_action: "200"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//TEMPERATURE
|
//TEMPERATURE
|
||||||
def getTempSensorsStatus() {
|
def getTempSensorsStatus() {
|
||||||
|
|
||||||
@@ -248,6 +538,17 @@ def getTempSensorsStatus() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else {
|
} else {
|
||||||
return [Device_state: device.currentValue('temperature')]
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [Device_state: device.currentValue('temperature')] + bat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getTempSensorsStatus(id) {
|
||||||
|
def device = temperature_sensors.find { it.id == id }
|
||||||
|
if (!device) {
|
||||||
|
return []
|
||||||
|
} else {
|
||||||
|
def bat = getBatteryStatus(device.id)
|
||||||
|
return [temperature: device.currentValue('temperature')] + bat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Color Coordinator
|
* Color Coordinator
|
||||||
* Version 1.1.1 - 11/9/16
|
* Version 1.1.0 - 11/9/16
|
||||||
* By Michael Struck
|
* By Michael Struck
|
||||||
*
|
*
|
||||||
* 1.0.0 - Initial release
|
* 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.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
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||||
@@ -34,17 +33,17 @@ preferences {
|
|||||||
|
|
||||||
def mainPage() {
|
def mainPage() {
|
||||||
dynamicPage(name: "mainPage", title: "", install: true, uninstall: false) {
|
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) {
|
if (masterInList) {
|
||||||
section ("**WARNING**"){
|
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"
|
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") {
|
section("Master Light") {
|
||||||
input "master", "capability.colorControl", title: "Colored Light", required: true
|
input "master", "capability.colorControl", title: "Colored Light"
|
||||||
}
|
}
|
||||||
section("Lights that follow the master settings") {
|
section("Lights that follow the master settings") {
|
||||||
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: true, submitOnChange: true
|
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: false, submitOnChange: true
|
||||||
}
|
}
|
||||||
section([mobileOnly:true], "Options") {
|
section([mobileOnly:true], "Options") {
|
||||||
input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
|
input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
|
||||||
@@ -82,44 +81,40 @@ def init() {
|
|||||||
}
|
}
|
||||||
//-----------------------------------
|
//-----------------------------------
|
||||||
def onOffHandler(evt){
|
def onOffHandler(evt){
|
||||||
if (slaves && master) {
|
if (!slaves.id.find{it==master.id}){
|
||||||
if (!slaves?.id.find{it==master?.id}){
|
if (master.currentValue("switch") == "on"){
|
||||||
if (master?.currentValue("switch") == "on"){
|
if (randomYes) getRandomColorMaster()
|
||||||
if (randomYes) getRandomColorMaster()
|
else slaves?.on()
|
||||||
else slaves?.on()
|
}
|
||||||
}
|
else {
|
||||||
else {
|
slaves?.off()
|
||||||
slaves?.off()
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def colorHandler(evt) {
|
def colorHandler(evt) {
|
||||||
if (slaves && master) {
|
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
|
||||||
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
|
log.debug "Changing Slave units H,S,L"
|
||||||
log.debug "Changing Slave units H,S,L"
|
def dimLevel = master.currentValue("level")
|
||||||
def dimLevel = master?.currentValue("level")
|
def hueLevel = master.currentValue("hue")
|
||||||
def hueLevel = master?.currentValue("hue")
|
def saturationLevel = master.currentValue("saturation")
|
||||||
def saturationLevel = master.currentValue("saturation")
|
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
||||||
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
slaves?.setColor(newValue)
|
||||||
slaves?.setColor(newValue)
|
try {
|
||||||
try {
|
log.debug "Changing Slave color temp"
|
||||||
log.debug "Changing Slave color temp"
|
def tempLevel = master.currentValue("colorTemperature")
|
||||||
def tempLevel = master?.currentValue("colorTemperature")
|
slaves?.setColorTemperature(tempLevel)
|
||||||
slaves?.setColorTemperature(tempLevel)
|
}
|
||||||
}
|
catch (e){
|
||||||
catch (e){
|
log.debug "Color temp for master --"
|
||||||
log.debug "Color temp for master --"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getRandomColorMaster(){
|
def getRandomColorMaster(){
|
||||||
def hueLevel = Math.floor(Math.random() *1000)
|
def hueLevel = Math.floor(Math.random() *1000)
|
||||||
def saturationLevel = Math.floor(Math.random() * 100)
|
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]
|
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
|
||||||
log.debug hueLevel
|
log.debug hueLevel
|
||||||
log.debug saturationLevel
|
log.debug saturationLevel
|
||||||
@@ -128,14 +123,12 @@ def getRandomColorMaster(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
def tempHandler(evt){
|
def tempHandler(evt){
|
||||||
if (slaves && master) {
|
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
|
||||||
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
|
if (evt.value != "--") {
|
||||||
if (evt.value != "--") {
|
log.debug "Changing Slave color temp based on Master change"
|
||||||
log.debug "Changing Slave color temp based on Master change"
|
def tempLevel = master.currentValue("colorTemperature")
|
||||||
def tempLevel = master.currentValue("colorTemperature")
|
slaves?.setColorTemperature(tempLevel)
|
||||||
slaves?.setColorTemperature(tempLevel)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +139,7 @@ private def textAppName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def textVersion() {
|
private def textVersion() {
|
||||||
def text = "Version 1.1.1 (12/13/2016)"
|
def text = "Version 1.1.0 (11/09/2016)"
|
||||||
}
|
}
|
||||||
|
|
||||||
private def textCopyright() {
|
private def textCopyright() {
|
||||||
|
|||||||
@@ -1,461 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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,34 +172,18 @@ def bulbDiscovery() {
|
|||||||
if (existingLightsDescription.isEmpty()) {
|
if (existingLightsDescription.isEmpty()) {
|
||||||
existingLightsDescription += it.value
|
existingLightsDescription += it.value
|
||||||
} else {
|
} else {
|
||||||
existingLightsDescription += ", ${it.value}"
|
existingLightsDescription += ", ${it.value}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bulbRefreshCount > 200 && numFound == 0) {
|
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||||
// Time out to avoid endless discovery
|
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.") {
|
||||||
state.inBulbDiscovery = false
|
input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, submitOnChange: true, options:newLights
|
||||||
bulbRefreshCount = 0
|
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
||||||
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 {
|
||||||
} else {
|
href "bridgeDiscovery", title: title, description: "", state: selectedHue ? "complete" : "incomplete", params: [override: true]
|
||||||
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]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +407,7 @@ def addBridge() {
|
|||||||
if(vbridge) {
|
if(vbridge) {
|
||||||
def d = getChildDevice(selectedHue)
|
def d = getChildDevice(selectedHue)
|
||||||
if(!d) {
|
if(!d) {
|
||||||
// compatibility with old devices
|
// compatibility with old devices
|
||||||
def newbridge = true
|
def newbridge = true
|
||||||
childDevices.each {
|
childDevices.each {
|
||||||
if (it.getDeviceDataByName("mac")) {
|
if (it.getDeviceDataByName("mac")) {
|
||||||
@@ -609,7 +593,7 @@ def locationHandler(evt) {
|
|||||||
log.trace "Location: $description"
|
log.trace "Location: $description"
|
||||||
|
|
||||||
def hub = evt?.hubId
|
def hub = evt?.hubId
|
||||||
def parsedEvent = parseLanMessage(description)
|
def parsedEvent = parseLanMessage(description)
|
||||||
parsedEvent << ["hub":hub]
|
parsedEvent << ["hub":hub]
|
||||||
|
|
||||||
if (parsedEvent?.ssdpTerm?.contains("urn:schemas-upnp-org:device:basic:1")) {
|
if (parsedEvent?.ssdpTerm?.contains("urn:schemas-upnp-org:device:basic:1")) {
|
||||||
@@ -835,7 +819,8 @@ def parse(childDevice, description) {
|
|||||||
try {
|
try {
|
||||||
body = new groovy.json.JsonSlurper().parseText(bodyString)
|
body = new groovy.json.JsonSlurper().parseText(bodyString)
|
||||||
} catch (all) {
|
} catch (all) {
|
||||||
log.warn "Parsing Body failed"
|
log.warn "Parsing Body failed - trying again..."
|
||||||
|
poll()
|
||||||
}
|
}
|
||||||
if (body instanceof java.util.Map) {
|
if (body instanceof java.util.Map) {
|
||||||
// get (poll) reponse
|
// get (poll) reponse
|
||||||
@@ -859,7 +844,7 @@ private sendColorEvents(device, xy, hue, sat, ct, colormode = null) {
|
|||||||
|
|
||||||
def events = [:]
|
def events = [:]
|
||||||
// For now, only care about changing color temperature if requested by user
|
// For now, only care about changing color temperature if requested by user
|
||||||
if (ct != null && ct != 0 && (colormode == "ct" || (xy == null && hue == null && sat == null))) {
|
if (ct != null && (colormode == "ct" || (xy == null && hue == null && sat == null))) {
|
||||||
// for some reason setting Hue to their specified minimum off 153 yields 154, dealt with below
|
// for some reason setting Hue to their specified minimum off 153 yields 154, dealt with below
|
||||||
// 153 (6500K) to 500 (2000K)
|
// 153 (6500K) to 500 (2000K)
|
||||||
def temp = (ct == 154) ? 6500 : Math.round(1000000 / ct)
|
def temp = (ct == 154) ? 6500 : Math.round(1000000 / ct)
|
||||||
@@ -1267,7 +1252,7 @@ private getBridgeIP() {
|
|||||||
if (d) {
|
if (d) {
|
||||||
if (d.getDeviceDataByName("networkAddress"))
|
if (d.getDeviceDataByName("networkAddress"))
|
||||||
host = d.getDeviceDataByName("networkAddress")
|
host = d.getDeviceDataByName("networkAddress")
|
||||||
else
|
else
|
||||||
host = d.latestState('networkAddress').stringValue
|
host = d.latestState('networkAddress').stringValue
|
||||||
}
|
}
|
||||||
if (host == null || host == "") {
|
if (host == null || host == "") {
|
||||||
|
|||||||
@@ -289,12 +289,12 @@ def initializeLife360Connection() {
|
|||||||
state.life360AccessToken = result.data.access_token
|
state.life360AccessToken = result.data.access_token
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.info "Life360 initializeLife360Connection, response=${result.data}"
|
log.debug "Response=${result.data}"
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
log.error "Life360 initializeLife360Connection, error: $e"
|
log.debug e
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
|
|
||||||
try { // we are going to just ignore any errors
|
try { // we are going to just ignore any errors
|
||||||
|
|
||||||
log.info "Life360 generateInitialEvent($member, $childDevice)"
|
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
|
||||||
|
|
||||||
def place = state.places.find{it.id==settings.place}
|
def place = state.places.find{it.id==settings.place}
|
||||||
|
|
||||||
@@ -678,8 +678,6 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
|
|
||||||
boolean isPresent = (distanceAway <= placeRadius)
|
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}"
|
// log.debug "External Id=${app.id}:${member.id}"
|
||||||
|
|
||||||
// def childDevice2 = getChildDevice("${app.id}.${member.id}")
|
// def childDevice2 = getChildDevice("${app.id}.${member.id}")
|
||||||
@@ -720,7 +718,7 @@ def haversine(lat1, lon1, lat2, lon2) {
|
|||||||
|
|
||||||
def placeEventHandler() {
|
def placeEventHandler() {
|
||||||
|
|
||||||
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
|
log.debug "In placeEventHandler method."
|
||||||
|
|
||||||
// the POST to this end-point will look like:
|
// the POST to this end-point will look like:
|
||||||
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
||||||
@@ -731,6 +729,8 @@ def placeEventHandler() {
|
|||||||
def direction = params?.direction
|
def direction = params?.direction
|
||||||
def timestamp = params?.timestamp
|
def timestamp = params?.timestamp
|
||||||
|
|
||||||
|
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
|
||||||
|
|
||||||
if (placeId == settings.place) {
|
if (placeId == settings.place) {
|
||||||
|
|
||||||
def presenceState = (direction=="in")
|
def presenceState = (direction=="in")
|
||||||
@@ -745,10 +745,10 @@ def placeEventHandler() {
|
|||||||
|
|
||||||
if (deviceWrapper) {
|
if (deviceWrapper) {
|
||||||
deviceWrapper.generatePresenceEvent(presenceState)
|
deviceWrapper.generatePresenceEvent(presenceState)
|
||||||
log.debug "Life360 event raised on child device: ${externalId}"
|
log.debug "Event raised on child device: ${externalId}"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
|
log.debug "Couldn't find child device associated with inbound Life360 event."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user