Compare commits

..

20 Commits

Author SHA1 Message Date
OpenT2T
0bcde8a1f0 Modifying 'Publish a SmartApp for OpenT2T - Remove support for multiple subscriptions to a single device.' 2017-06-19 17:28:46 -07:00
OpenT2T
9d63d0bbf9 Modifying 'Publish a SmartApp for OpenT2T - Remove support for multiple subscriptions to a single device.' 2017-06-19 17:25:53 -07:00
OpenT2T
385463772b Modifying 'Publish a SmartApp for OpenT2T - Fix register all device change handler' 2017-05-12 18:23:08 -07:00
OpenT2T
284828c42f Modifying 'Publish a SmartApp for OpenT2T - HMAC support' 2017-05-01 20:10:13 -07:00
OpenT2T
bbdc8faa93 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:02:05 -07:00
OpenT2T
48ceadcdb6 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:01:30 -07:00
OpenT2T
8e59df0de5 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:01:26 -07:00
OpenT2T
d276b80c90 Modifying 'Publish a SmartApp for OpenT2T - Update event messages.' 2017-03-06 01:02:07 -08:00
OpenT2T
8d838ead33 Modifying 'Publish a SmartApp for OpenT2T - Update event messages.' 2017-03-06 01:02:05 -08:00
OpenT2T
bf23f19af5 Modifying 'Update event messages.' 2017-03-06 00:59:48 -08:00
OpenT2T
d5bce43a99 Modifying 'Update event messages.' 2017-03-06 00:59:47 -08:00
OpenT2T
08c6f143dc Modifying 'Support device status.' 2017-03-03 03:11:10 -08:00
OpenT2T
b6f4581d6d Modifying 'Publish a SmartApp for OpenT2T' 2017-03-02 05:20:53 -08:00
OpenT2T
a56cad5e03 Modifying 'Publish a SmartApp for OpenT2T' 2017-03-02 05:20:47 -08:00
OpenT2T
4ed48c8ed4 Modifying 'Publish a SmartApp for OpenT2T' 2017-02-05 19:55:22 -08:00
OpenT2T
0bfd77745e Modifying 'Publish a SmartApp for OpenT2T' 2017-02-05 19:55:17 -08:00
OpenT2T
355f641853 Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 23:06:17 -08:00
OpenT2T
aba1f48f1f Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 23:06:16 -08:00
OpenT2T
9bf39136de Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 22:39:52 -08:00
OpenT2T
97fdc03c00 MSA-1577: This SmartApp enables the end-to-end SmartThings scenarios via OpenT2T. More information on OpenT2T can be found at http://www.opentranslatorstothings.org/#/ 2016-11-14 12:08:30 -08:00
49 changed files with 746 additions and 659 deletions

View File

@@ -1,46 +0,0 @@
/**
* Stateless On/Off Button Tile
*
* Author: Ronald Gouldner
*
* Date: 2015-05-14
*/
metadata {
// Automatically generated. Make future change here.
definition (name: "Stateless On-Off Button Tile", namespace: "gouldner", author: "Ronald Gouldner") {
capability "Actuator"
capability "Switch"
capability "Sensor"
}
// simulator metadata
simulator {
}
// UI tile definitions
tiles {
standardTile("button", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "offReady", label: 'Off', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff", nextState: "onReady"
state "onReady", label: 'On', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821", nextState: "offReady"
state "off", label: 'Off', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
state "on", label: 'On', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
}
main "button"
details "button"
}
}
def parse(String description) {
}
def on() {
log.debug "Stateless On/Off Button Tile Virtual Switch ${device.name} turned on"
sendEvent(name: "switch", value: "on")
sendEvent(name: "switch", value: "onReady")
}
def off() {
log.debug "Stateless On/Off Button Tile Virtual Switch ${device.name} turned off"
sendEvent(name: "switch", value: "off")
sendEvent(name: "switch", value: "offReady")
}

View File

@@ -120,15 +120,6 @@ def configure() {
return cmd return cmd
} }
def installed() {
initialize()
}
def updated() { def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4) sendEvent(name: "numberOfButtons", value: 4)
} }

View File

@@ -109,15 +109,6 @@ def configure() {
return cmds return cmds
} }
def installed() {
initialize()
}
def updated() { def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4) sendEvent(name: "numberOfButtons", value: 4)
} }

View File

@@ -27,7 +27,7 @@ metadata {
capability "Switch" capability "Switch"
capability "Refresh" capability "Refresh"
capability "Music Player" capability "Music Player"
capability "Health Check" capability "Polling"
/** /**
* Define all commands, ie, if you have a custom action not * Define all commands, ie, if you have a custom action not
@@ -236,33 +236,7 @@ def parse(String event) {
* @return action(s) to take or null * @return action(s) to take or null
*/ */
def installed() { def installed() {
// Notify health check about this device with timeout interval 12 minutes onAction("refresh")
sendEvent(name: "checkInterval", value: 12 * 60, data: [protocol: "lan", hubHardwareId: device.hub.hardwareID], displayed: false)
startPoll()
}
/**
* Called by health check if no events been generated in the last 12 minutes
* If device doesn't respond it will be marked offline (not available)
*/
def ping() {
TRACE("ping")
boseSendGetNowPlaying()
}
/**
* Schedule a 2 minute poll of the device to refresh the
* tiles so the user gets the correct information.
*/
def startPoll() {
TRACE("startPoll")
unschedule()
// Schedule 2 minute polling of speaker status (song average length is 3-4 minutes)
def sec = Math.round(Math.floor(Math.random() * 60))
//def cron = "$sec 0/5 * * * ?" // every 5 min
def cron = "$sec 0/2 * * * ?" // every 2 min
log.debug "schedule('$cron', boseSendGetNowPlaying)"
schedule(cron, boseSendGetNowPlaying)
} }
/** /**
@@ -342,6 +316,14 @@ def onAction(String user, data=null) {
return actions return actions
} }
/**
* Called every so often (every 5 minutes actually) to refresh the
* tiles so the user gets the correct information.
*/
def poll() {
return boseRefreshNowPlaying()
}
/** /**
* Joins this speaker into the everywhere zone * Joins this speaker into the everywhere zone
*/ */
@@ -855,10 +837,6 @@ def boseRefreshNowPlaying(delay=0) {
return boseGET("/now_playing") return boseGET("/now_playing")
} }
def boseSendGetNowPlaying() {
sendHubCommand(boseGET("/now_playing"))
}
/** /**
* Requests the list of presets * Requests the list of presets
* *
@@ -1037,7 +1015,3 @@ def boseGetDeviceID() {
def getDeviceIP() { def getDeviceIP() {
return parent.resolveDNI2Address(device.deviceNetworkId) return parent.resolveDNI2Address(device.deviceNetworkId)
} }
def TRACE(text) {
log.trace "${text}"
}

View File

@@ -81,47 +81,51 @@ metadata {
// parse events into attributes // parse events into attributes
def parse(String description) { def parse(String description) {
log.debug "Parse description $description" log.debug "Parse description $description"
List result = [] def map = [:]
def descMap = zigbee.parseDescriptionAsMap(description) if (description?.startsWith("read attr -")) {
log.debug "Desc Map: $descMap" def descMap = parseDescriptionAsMap(description)
List attrData = [[cluster: descMap.cluster ,attrId: descMap.attrId, value: descMap.value]] log.debug "Desc Map: $descMap"
descMap.additionalAttrs.each { if (descMap.cluster == "0201" && descMap.attrId == "0000") {
attrData << [cluster: descMap.cluster, attrId: it.attrId, value: it.value]
}
attrData.each {
def map = [:]
if (it.cluster == "0201" && it.attrId == "0000") {
log.debug "TEMP" log.debug "TEMP"
map.name = "temperature" map.name = "temperature"
map.value = getTemperature(it.value) map.value = getTemperature(descMap.value)
map.unit = temperatureScale map.unit = temperatureScale
} else if (it.cluster == "0201" && it.attrId == "0011") { } else if (descMap.cluster == "0201" && descMap.attrId == "0011") {
log.debug "COOLING SETPOINT" log.debug "COOLING SETPOINT"
map.name = "coolingSetpoint" map.name = "coolingSetpoint"
map.value = getTemperature(it.value) map.value = getTemperature(descMap.value)
map.unit = temperatureScale map.unit = temperatureScale
} else if (it.cluster == "0201" && it.attrId == "0012") { } else if (descMap.cluster == "0201" && descMap.attrId == "0012") {
log.debug "HEATING SETPOINT" log.debug "HEATING SETPOINT"
map.name = "heatingSetpoint" map.name = "heatingSetpoint"
map.value = getTemperature(it.value) map.value = getTemperature(descMap.value)
map.unit = temperatureScale map.unit = temperatureScale
} else if (it.cluster == "0201" && it.attrId == "001c") { } else if (descMap.cluster == "0201" && descMap.attrId == "001c") {
log.debug "MODE" log.debug "MODE"
map.name = "thermostatMode" map.name = "thermostatMode"
map.value = getModeMap()[it.value] map.value = getModeMap()[descMap.value]
} else if (it.cluster == "0202" && it.attrId == "0000") { } else if (descMap.cluster == "0202" && descMap.attrId == "0000") {
log.debug "FAN MODE" log.debug "FAN MODE"
map.name = "thermostatFanMode" map.name = "thermostatFanMode"
map.value = getFanModeMap()[it.value] map.value = getFanModeMap()[descMap.value]
} }
if (map) {
result << createEvent(map)
}
log.debug "Parse returned $map"
} }
def result = null
if (map) {
result = createEvent(map)
}
log.debug "Parse returned $map"
return result return result
} }
def parseDescriptionAsMap(description) {
(description - "read attr - ").split(",").inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
}
def getModeMap() { [ def getModeMap() { [
"00":"off", "00":"off",
"03":"cool", "03":"cool",

View File

@@ -183,15 +183,6 @@ def updateState(String name, String value) {
device.updateDataValue(name, value) device.updateDataValue(name, value)
} }
def installed() {
initialize()
}
def updated() { def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 3) sendEvent(name: "numberOfButtons", value: 3)
} }

View File

@@ -82,7 +82,7 @@ def on() {
} }
def setLevel(value) { def setLevel(value) {
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report zigbee.setLevel(value) + ["delay 500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
} }
/** /**

View File

@@ -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 {

View File

@@ -125,7 +125,7 @@ metadata {
void installed() { void installed() {
// The device refreshes every 5 minutes by default so if we miss 2 refreshes we can consider it offline // The device refreshes every 5 minutes by default so if we miss 2 refreshes we can consider it offline
// Using 12 minutes because in testing, device health team found that there could be "jitter" // Using 12 minutes because in testing, device health team found that there could be "jitter"
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud"], displayed: false) sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud", hubHardwareId: device.hub.hardwareID], displayed: false)
} }
// Device Watch will ping the device to proactively determine if the device has gone offline // Device Watch will ping the device to proactively determine if the device has gone offline

View File

@@ -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()

View File

@@ -17,7 +17,6 @@ metadata {
capability "Refresh" capability "Refresh"
capability "Sensor" capability "Sensor"
capability "Health Check" capability "Health Check"
capability "Light"
command "setAdjustedColor" command "setAdjustedColor"
command "reset" command "reset"

View File

@@ -18,7 +18,6 @@ metadata {
capability "Refresh" capability "Refresh"
capability "Sensor" capability "Sensor"
capability "Health Check" capability "Health Check"
capability "Light"
command "setAdjustedColor" command "setAdjustedColor"
command "reset" command "reset"

View File

@@ -14,8 +14,7 @@ metadata {
capability "Switch" capability "Switch"
capability "Refresh" capability "Refresh"
capability "Sensor" capability "Sensor"
capability "Health Check" capability "Health Check"
capability "Light"
command "refresh" command "refresh"
} }

View File

@@ -16,7 +16,6 @@ metadata {
capability "Switch" capability "Switch"
capability "Refresh" capability "Refresh"
capability "Health Check" capability "Health Check"
capability "Light"
command "refresh" command "refresh"
} }

View File

@@ -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)

View File

@@ -71,7 +71,7 @@ def parse(String description) {
def event = [:] def event = [:]
def finalResult = isKnownDescription(description) def finalResult = isKnownDescription(description)
if (finalResult) { if (finalResult != "false") {
log.info finalResult log.info finalResult
if (finalResult.type == "update") { if (finalResult.type == "update") {
log.info "$device updates: ${finalResult.value}" log.info "$device updates: ${finalResult.value}"
@@ -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"
] ]
} }
@@ -212,16 +212,13 @@ def isKnownDescription(description) {
else if (descMap.cluster == "0B04" || descMap.clusterId == "0B04"){ else if (descMap.cluster == "0B04" || descMap.clusterId == "0B04"){
isDescriptionPower(descMap) isDescriptionPower(descMap)
} }
else {
return [:]
}
} }
else if(description?.startsWith("on/off:")) { else if(description?.startsWith("on/off:")) {
def switchValue = description?.endsWith("1") ? "on" : "off" def switchValue = description?.endsWith("1") ? "on" : "off"
return [type: "switch", value : switchValue] return [type: "switch", value : switchValue]
} }
else { else {
return [:] return "false"
} }
} }
@@ -255,7 +252,7 @@ def isDescriptionOnOff(descMap) {
return [type: "switch", value : switchValue] return [type: "switch", value : switchValue]
} }
else { else {
return [:] return "false"
} }
} }
@@ -282,9 +279,10 @@ def isDescriptionLevel(descMap) {
if (dimmerValue != -1){ if (dimmerValue != -1){
return [type: "level", value : dimmerValue] return [type: "level", value : dimmerValue]
} }
else { else {
return [:] return "false"
} }
} }
@@ -306,16 +304,16 @@ def isDescriptionPower(descMap) {
return [type: "power", value : powerValue] return [type: "power", value : powerValue]
} }
else { else {
return [:] return "false"
} }
} }
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 +321,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 +331,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 +342,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) {

View File

@@ -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'
] ]
} }

View File

@@ -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"
] ]
} }

View File

@@ -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"
] ]
} }

View File

@@ -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"
] ]
} }

View File

@@ -57,7 +57,6 @@ def parse(String description) {
private Map parseBasicMessage(description) { private Map parseBasicMessage(description) {
def name = parseName(description) def name = parseName(description)
def results = [:]
if (name != null) { if (name != null) {
def value = parseValue(description) def value = parseValue(description)
def linkText = getLinkText(device) def linkText = getLinkText(device)
@@ -65,7 +64,7 @@ private Map parseBasicMessage(description) {
def handlerName = value def handlerName = value
def isStateChange = isStateChange(device, name, value) def isStateChange = isStateChange(device, name, value)
results = [ def results = [
name : name, name : name,
value : value, value : value,
linkText : linkText, linkText : linkText,
@@ -74,6 +73,8 @@ private Map parseBasicMessage(description) {
isStateChange : isStateChange, isStateChange : isStateChange,
displayed : displayed(description, isStateChange) displayed : displayed(description, isStateChange)
] ]
} else {
results = [:]
} }
log.debug "Parse returned $results.descriptionText" log.debug "Parse returned $results.descriptionText"
return results return results

View File

@@ -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"
] ]
} }

View File

@@ -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"
] ]
} }

View File

@@ -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

View File

@@ -126,15 +126,6 @@ private hold(button) {
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true) sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
} }
def installed() {
initialize()
}
def updated() { def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4) sendEvent(name: "numberOfButtons", value: 4)
} }

View File

@@ -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() {

View File

@@ -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"

View File

@@ -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()

View File

@@ -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()

View File

@@ -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 {}

View File

@@ -23,15 +23,9 @@ metadata {
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart A19 Soft White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FF00", outClusters: "0019", manufacturer: "MRVL", model: "MZ100", deviceJoinName: "Wemo Bulb" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FF00", outClusters: "0019", manufacturer: "MRVL", model: "MZ100", deviceJoinName: "Wemo Bulb"
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, 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) {

View File

@@ -28,8 +28,8 @@ metadata {
capability "Switch Level" capability "Switch Level"
capability "Health Check" capability "Health Check"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
} }
// UI tile definitions // UI tile definitions

View File

@@ -32,12 +32,11 @@ metadata {
attribute "colorName", "string" attribute "colorName", "string"
command "setGenericName" command "setGenericName"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "SYLVANIA Smart Flex RGBW" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "SYLVANIA Smart A19 RGBW" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED A19 RGBW"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "SYLVANIA Smart BR30 RGBW" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "OSRAM LIGHTIFY LED BR30 RGBW"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "SYLVANIA Smart RT5/6 RGBW" fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "OSRAM LIGHTIFY LED RT 5/6 RGBW"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY FLEX OUTDOOR RGBW", deviceJoinName: "SYLVANIA Smart Outdoor RGBW Flex"
} }
// UI tile definitions // UI tile definitions

View File

@@ -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

View File

@@ -32,12 +32,11 @@ metadata {
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04", outClusters: "0019" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04", outClusters: "0019"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "SYLVANIA Smart BR30 Tunable White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Flood BR30 Tunable White"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "SYLVANIA Smart RT5/6 Tunable White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "OSRAM LIGHTIFY RT5/6 Tunable White"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "SYLVANIA Smart A19 Tunable White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White" fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0702, 0B05", outClusters: "0019", manufacturer: "sengled", model: "Z01-A19NAE26", deviceJoinName: "Sengled Element plus"
} }
// UI tile definitions // UI tile definitions
@@ -84,24 +83,105 @@ def parse(String description) {
} }
} }
else { else {
def cluster = zigbee.parse(description) Map bindingTable = parseBindingTableResponse(description)
if (bindingTable) {
List<String> cmds = []
bindingTable.table_entries.inject(cmds) { acc, entry ->
// The binding entry is not for our hub and should be deleted
if (entry["dstAddr"] != zigbeeEui) {
acc.addAll(removeBinding(entry.clusterId, entry.srcAddr, entry.srcEndpoint, entry.dstAddr, entry.dstEndpoint))
}
acc
}
// There are more entries that we haven't examined yet
if (bindingTable.numTableEntries > bindingTable.startIndex + bindingTable.numEntriesReturned) {
def startPos
if (cmds) {
log.warn "Removing binding entries for other devices: $cmds"
// Since we are removing some entries, we should start in the same spot as we just read since values
// will fill in the newly vacated spots
startPos = bindingTable.startIndex
} else {
// Since we aren't removing anything we move forward to the next set of table entries
startPos = bindingTable.startIndex + bindingTable.numEntriesReturned
}
cmds.addAll(requestBindingTable(startPos))
}
sendHubCommand(cmds.collect { it ->
new physicalgraph.device.HubAction(it)
}, 2000)
} else {
def cluster = zigbee.parse(description)
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) { if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
if (cluster.data[0] == 0x00) { if (cluster.data[0] == 0x00) {
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
}
} }
else { else {
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}" log.warn "DID NOT PARSE MESSAGE for description : $description"
log.debug "${cluster}"
} }
} }
else {
log.warn "DID NOT PARSE MESSAGE for description : $description"
log.debug "${cluster}"
}
} }
} }
def parseBindingTableResponse(description) {
Map descMap = zigbee.parseDescriptionAsMap(description)
if (descMap["clusterInt"] == 0x8033) {
def header_field_lengths = ["transactionSeqNo": 1, "status": 1, "numTableEntries": 1, "startIndex": 1, "numEntriesReturned": 1]
def field_values = [:]
def data = descMap["data"]
header_field_lengths.each { k, v ->
field_values[k] = Integer.parseInt(data.take(v).join(""), 16);
data = data.drop(v);
}
List<Map> table = []
if (field_values.numEntriesReturned) {
def table_entry_lengths = ["srcAddr": 8, "srcEndpoint": 1, "clusterId": 2, "dstAddrMode": 1]
for (def i : 0..(field_values.numEntriesReturned - 1)) {
def entryMap = [:]
table_entry_lengths.each { k, v ->
def val = data.take(v).reverse().join("")
entryMap[k] = val.length() < 8 ? Integer.parseInt(val, 16) : val
data = data.drop(v)
}
switch (entryMap.dstAddrMode) {
case 0x01:
entryMap["dstAddr"] = data.take(2).reverse().join("")
data = data.drop(2)
break
case 0x03:
entryMap["dstAddr"] = data.take(8).reverse().join("")
data = data.drop(8)
entryMap["dstEndpoint"] = Integer.parseInt(data.take(1).join(""), 16)
data = data.drop(1)
break
}
table << entryMap
}
}
field_values["table_entries"] = table
return field_values
}
return [:]
}
def requestBindingTable(startPos=0) {
return ["zdo mgmt-bind 0x${zigbee.deviceNetworkId} $startPos"]
}
def removeBinding(cluster, srcAddr, srcEndpoint, destAddr, destEndpoint) {
return ["zdo unbind unicast 0x${zigbee.deviceNetworkId} {${srcAddr}} $srcEndpoint $cluster {${destAddr}} $destEndpoint"]
}
def off() { def off() {
zigbee.off() zigbee.off()
} }
@@ -131,8 +211,7 @@ def configure() {
// enrolls with default periodic reporting until newer 5 min interval is confirmed // enrolls with default periodic reporting until newer 5 min interval is confirmed
sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity refresh() + requestBindingTable(0) + ["delay 2000"]
refresh()
} }
def setColorTemperature(value) { def setColorTemperature(value) {

View File

@@ -89,7 +89,7 @@ def on() {
} }
def setLevel(value) { def setLevel(value) {
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
} }
def refresh() { def refresh() {
@@ -127,8 +127,8 @@ def configureHealthCheck() {
def configure() { def configure() {
log.debug "configure()" log.debug "configure()"
configureHealthCheck()
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
configureHealthCheck()
} }
def updated() { def updated() {

View File

@@ -115,7 +115,7 @@ def refreshAttributes() {
} }
def setLevel(value) { def setLevel(value) {
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
} }
def setColor(value){ def setColor(value){

View File

@@ -27,10 +27,6 @@ metadata {
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019" fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019" fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 RGBW" fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 RGBW"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "PAR 16 50 RGBW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY RGBW PAR 16 50"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenpole RGBW-Lightify", deviceJoinName: "OSRAM LIGHTIFY Gardenpole RGBW"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Outdoor Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Outdoor Flex RGBW"
} }
// UI tile definitions // UI tile definitions
@@ -135,7 +131,7 @@ def setColorTemperature(value) {
} }
def setLevel(value) { def setLevel(value) {
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
} }
def setColor(value){ def setColor(value){

View File

@@ -32,7 +32,6 @@ metadata {
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White" fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"PAR16 50 TW", deviceJoinName: "OSRAM LIGHTIFY LED PAR16 50 Tunable White" fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"PAR16 50 TW", deviceJoinName: "OSRAM LIGHTIFY LED PAR16 50 Tunable White"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
} }
// UI tile definitions // UI tile definitions
@@ -90,7 +89,7 @@ def on() {
} }
def setLevel(value) { def setLevel(value) {
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() zigbee.setLevel(value) + ["delay 1500"] + zigbee.levelRefresh()
} }
def refresh() { def refresh() {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -73,7 +73,7 @@ def authPage() {
return dynamicPage(name: "Credentials", title: "Authorize Connection", nextPage:"listDevices", uninstall: uninstallAllowed, install:false) { return dynamicPage(name: "Credentials", title: "Authorize Connection", nextPage:"listDevices", uninstall: uninstallAllowed, install:false) {
section() { section() {
paragraph "Tap below to log in to the netatmo and authorize SmartThings access." paragraph "Tap below to log in to the netatmo and authorize SmartThings access."
href url:redirectUrl, style:"embedded", required:false, title:"Connect to ${getVendorName()}", description:description href url:redirectUrl, style:"embedded", required:false, title:"Connect to ${getVendorName()}:", description:description
} }
} }
} else { } else {
@@ -146,24 +146,19 @@ def callback() {
// log.debug "PARAMS: ${params}" // log.debug "PARAMS: ${params}"
try { httpPost(params) { resp ->
httpPost(params) { resp ->
def slurper = new JsonSlurper() def slurper = new JsonSlurper()
resp.data.each { key, value -> resp.data.each { key, value ->
def data = slurper.parseText(key) def data = slurper.parseText(key)
log.debug "Data: $data"
state.refreshToken = data.refresh_token state.refreshToken = data.refresh_token
state.authToken = data.access_token state.authToken = data.access_token
//state.accessToken = data.access_token state.tokenExpires = now() + (data.expires_in * 1000)
state.tokenExpires = now() + (data.expires_in * 1000) // log.debug "swapped token: $resp.data"
// log.debug "swapped token: $resp.data" }
} }
}
} catch (Exception e) {
log.debug "callback: Call failed $e"
}
// Handle success and failure here, and render stuff accordingly // Handle success and failure here, and render stuff accordingly
if (state.authToken) { if (state.authToken) {
@@ -392,18 +387,18 @@ def getDeviceList() {
state.deviceDetail = [:] state.deviceDetail = [:]
state.deviceState = [:] state.deviceState = [:]
apiGet("/api/getstationsdata") { response -> apiGet("/api/devicelist") { response ->
response.data.body.devices.each { value -> response.data.body.devices.each { value ->
def key = value._id def key = value._id
deviceList[key] = "${value.station_name}: ${value.module_name}" deviceList[key] = "${value.station_name}: ${value.module_name}"
state.deviceDetail[key] = value state.deviceDetail[key] = value
state.deviceState[key] = value.dashboard_data state.deviceState[key] = value.dashboard_data
value.modules.each { value2 -> }
def key2 = value2._id response.data.body.modules.each { value ->
deviceList[key2] = "${value.station_name}: ${value2.module_name}" def key = value._id
state.deviceDetail[key2] = value2 deviceList[key] = "${state.deviceDetail[value.main_device].station_name}: ${value.module_name}"
state.deviceState[key2] = value2.dashboard_data state.deviceDetail[key] = value
} state.deviceState[key] = value.dashboard_data
} }
} }
@@ -453,7 +448,6 @@ def listDevices() {
} }
def apiGet(String path, Map query, Closure callback) { def apiGet(String path, Map query, Closure callback) {
if(now() >= state.tokenExpires) { if(now() >= state.tokenExpires) {
refreshToken(); refreshToken();
} }
@@ -473,16 +467,12 @@ def apiGet(String path, Map query, Closure callback) {
} catch (Exception e) { } catch (Exception e) {
// This is most likely due to an invalid token. Try to refresh it and try again. // This is most likely due to an invalid token. Try to refresh it and try again.
log.debug "apiGet: Call failed $e" log.debug "apiGet: Call failed $e"
if(refreshToken()) { if(refreshToken()) {
log.debug "apiGet: Trying again after refreshing token" log.debug "apiGet: Trying again after refreshing token"
try { httpGet(params) { response ->
httpGet(params) { response -> callback.call(response)
callback.call(response) }
} }
} catch (Exception f) {
log.debug "apiGet: Call failed $f"
}
}
} }
} }

View File

@@ -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() {

View File

@@ -1,3 +1,7 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
/** /**
* OpenT2T SmartApp Test * OpenT2T SmartApp Test
* *
@@ -14,14 +18,14 @@
* *
*/ */
definition( definition(
name: "OpenT2T SmartApp Test", name: "OpenT2T SmartApp Test",
namespace: "opent2t", namespace: "opent2t",
author: "OpenT2T", author: "OpenT2T",
description: "Test app to test end to end SmartThings scenarios via OpenT2T", description: "Test app to test end to end SmartThings scenarios via OpenT2T",
category: "SmartThings Labs", category: "SmartThings Labs",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.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") iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
/** --------------------+---------------+-----------------------+------------------------------------ /** --------------------+---------------+-----------------------+------------------------------------
* Device Type | Attribute Name| Commands | Attribute Values * Device Type | Attribute Name| Commands | Attribute Values
@@ -39,7 +43,7 @@ definition(
* garageDoors | door | open, close | unknown, closed, open, closing, opening * garageDoors | door | open, close | unknown, closed, open, closing, opening
* cameras | image | take | <String> * cameras | image | take | <String>
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint, * thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode, * | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState * | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
* | | emergencyHeat, | * | | emergencyHeat, |
* | | setThermostatMode, | * | | setThermostatMode, |
@@ -51,93 +55,105 @@ definition(
//Device Inputs //Device Inputs
preferences { preferences {
section("Allow <PLACEHOLDER: Your App Name> to control these things...") { section("Allow OpenT2T to control these things...") {
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false, hideWhenEmpty: true
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false, hideWhenEmpty: true
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false, hideWhenEmpty: true
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false, hideWhenEmpty: true
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false, hideWhenEmpty: true
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false, hideWhenEmpty: true
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false, hideWhenEmpty: true
input "thermostats", "capability.thermostat", title: "Which Thermostat?", multiple: true, required: false input "thermostats", "capability.thermostat", title: "Which Thermostat?", multiple: true, required: false, hideWhenEmpty: true
input "waterSensors", "capability.waterSensor", title: "Which Water Leak Sensors?", multiple: true, required: false input "waterSensors", "capability.waterSensor", title: "Which Water Leak Sensors?", multiple: true, required: false, hideWhenEmpty: true
} }
} }
def getInputs() { def getInputs() {
def inputList = [] def inputList = []
inputList += contactSensors ?: [] inputList += contactSensors?: []
inputList += garageDoors ?: [] inputList += garageDoors?: []
inputList += locks ?: [] inputList += locks?: []
inputList += cameras ?: [] inputList += cameras?: []
inputList += motionSensors ?: [] inputList += motionSensors?: []
inputList += presenceSensors ?: [] inputList += presenceSensors?: []
inputList += switches ?: [] inputList += switches?: []
inputList += thermostats ?: [] inputList += thermostats?: []
inputList += waterSensors ?: [] inputList += waterSensors?: []
return inputList return inputList
} }
//API external Endpoints //API external Endpoints
mappings { mappings {
path("/subscriptionURL/:url") {
action:
[
PUT: "updateEndpointURL"
]
}
path("/connectionId/:connId") {
action:
[
PUT: "updateConnectionId"
]
}
path("/devices") { path("/devices") {
action: action: [
[ GET: "getDevices"
GET: "getDevices"
] ]
} }
path("/devices/:id") { path("/devices/:id") {
action: action: [
[ GET: "getDevice"
GET: "getDevice"
] ]
} }
path("/update/:id") { path("/update/:id") {
action: action: [
[ PUT: "updateDevice"
PUT: "updateDevice"
] ]
} }
path("/subscription/:id") { path("/deviceSubscription") {
action: action: [
[ POST: "registerDeviceChange",
POST : "registerDeviceChange", DELETE: "unregisterDeviceChange"
DELETE: "unregisterDeviceChange" ]
}
path("/locationSubscription") {
action: [
POST: "registerDeviceGraph",
DELETE: "unregisterDeviceGraph"
] ]
} }
} }
def installed() { def installed() {
log.debug "Installed with settings: ${settings}" log.debug "Installing with settings: ${settings}"
initialize() initialize()
} }
def updated() { def updated() {
log.debug "Updated with settings: ${settings}" log.debug "Updating with settings: ${settings}"
//Initialize state variables if didn't exist.
if( state.deviceSubscriptionMap == null ){
state.deviceSubscriptionMap = [:]
log.debug "deviceSubscriptionMap created."
}
if( state.locationSubscriptionMap == null ){
state.locationSubscriptionMap = [:]
log.debug "locationSubscriptionMap created."
}
if(state.verificationKeyMap == null){
state.verificationKeyMap = [:]
log.debug "verificationKeyMap created."
}
unsubscribe() unsubscribe()
registerSubscriptions() registerAllDeviceSubscriptions()
} }
def initialize() { def initialize() {
state.connectionId = "" log.debug "Initializing with settings: ${settings}"
state.endpointURL = "https://ifs.windows-int.com/v1/cb/81C7E77B-EABC-488A-B2BF-FEC42F0DABD2/notify" state.deviceSubscriptionMap = [:]
registerSubscriptions() log.debug "deviceSubscriptionMap created."
state.locationSubscriptionMap = [:]
log.debug "locationSubscriptionMap created."
state.verificationKeyMap = [:]
log.debug "verificationKeyMap created."
registerAllDeviceSubscriptions()
} }
/*** Subscription Functions ***/
//Subscribe events for all devices //Subscribe events for all devices
def registerSubscriptions() { def registerAllDeviceSubscriptions() {
registerChangeHandler(inputs) registerChangeHandler(inputs)
} }
@@ -145,95 +161,252 @@ def registerSubscriptions() {
def registerChangeHandler(myList) { def registerChangeHandler(myList) {
myList.each { myDevice -> myList.each { myDevice ->
def theAtts = myDevice.supportedAttributes def theAtts = myDevice.supportedAttributes
theAtts.each { att -> theAtts.each {att ->
subscribe(myDevice, att.name, eventHandler) subscribe(myDevice, att.name, deviceEventHandler)
log.info "Registering ${myDevice.displayName}.${att.name}" log.info "Registering for ${myDevice.displayName}.${att.name}"
} }
} }
} }
//Endpoints function: Subscribe to events from a specific device //Endpoints function: Subscribe to events from a specific device
def registerDeviceChange() { def registerDeviceChange() {
def myDevice = findDevice(params.id) def subscriptionEndpt = params.subscriptionURL
def deviceId = params.deviceId
def myDevice = findDevice(deviceId)
if( myDevice == null ){
httpError(404, "Cannot find device with device ID ${deviceId}.")
}
def theAtts = myDevice.supportedAttributes def theAtts = myDevice.supportedAttributes
try { try {
theAtts.each { att -> theAtts.each {att ->
subscribe(myDevice, att.name, eventHandler) subscribe(myDevice, att.name, deviceEventHandler)
log.info "Registering ${myDevice.displayName}.${att.name}"
} }
return ["succeed"] log.info "Subscribing for ${myDevice.displayName}"
if(subscriptionEndpt != null){
if(state.deviceSubscriptionMap[deviceId] == null){
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
} else if (!state.deviceSubscriptionMap[deviceId].contains(subscriptionEndpt)){
// state.deviceSubscriptionMap[deviceId] << subscriptionEndpt
// For now, we will only have one subscription endpoint per device
state.deviceSubscriptionMap.remove(deviceId)
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
}
if(params.key != null){
state.verificationKeyMap[subscriptionEndpt] = params.key
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
}
}
} catch (e) { } catch (e) {
httpError(500, "something went wrong: $e") httpError(500, "something went wrong: $e")
} }
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
log.info "Current verification key map is ${state.verificationKeyMap}"
return ["succeed"]
} }
//Endpoints function: Unsubscribe to events from a specific device //Endpoints function: Unsubscribe to events from a specific device
def unregisterDeviceChange() { def unregisterDeviceChange() {
def myDevice = findDevice(params.id) def subscriptionEndpt = params.subscriptionURL
def deviceId = params.deviceId
def myDevice = findDevice(deviceId)
if( myDevice == null ){
httpError(404, "Cannot find device with device ID ${deviceId}.")
}
try { try {
unsubscribe(myDevice) if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
log.info "Unregistering ${myDevice.displayName}" if (state.deviceSubscriptionMap[deviceId]?.contains(subscriptionEndpt)){
return ["succeed"] if(state.deviceSubscriptionMap[deviceId].size() == 1){
state.deviceSubscriptionMap.remove(deviceId)
} else {
state.deviceSubscriptionMap[deviceId].remove(subscriptionEndpt)
}
state.verificationKeyMap.remove(subscriptionEndpt)
log.info "Removed subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
}
} else {
state.deviceSubscriptionMap.remove(deviceId)
log.info "Unsubscriping for ${myDevice.displayName}"
}
} catch (e) { } catch (e) {
httpError(500, "something went wrong: $e") httpError(500, "something went wrong: $e")
} }
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
log.info "Current verification key map is ${state.verificationKeyMap}"
}
//Endpoints function: Subscribe to device additiona/removal updated in a location
def registerDeviceGraph() {
def subscriptionEndpt = params.subscriptionURL
if (subscriptionEndpt != null && subscriptionEndpt != "undefined"){
subscribe(location, "DeviceCreated", locationEventHandler, [filterEvents: false])
subscribe(location, "DeviceUpdated", locationEventHandler, [filterEvents: false])
subscribe(location, "DeviceDeleted", locationEventHandler, [filterEvents: false])
if(state.locationSubscriptionMap[location.id] == null){
state.locationSubscriptionMap.put(location.id, [subscriptionEndpt])
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
}else if (!state.locationSubscriptionMap[location.id].contains(subscriptionEndpt)){
state.locationSubscriptionMap[location.id] << subscriptionEndpt
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
}
if(params.key != null){
state.verificationKeyMap[subscriptionEndpt] = params.key
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
}
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
log.info "Current verification key map is ${state.verificationKeyMap}"
return ["succeed"]
} else {
httpError(400, "missing input parameter: subscriptionURL")
}
}
//Endpoints function: Unsubscribe to events from a specific device
def unregisterDeviceGraph() {
def subscriptionEndpt = params.subscriptionURL
try {
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
if (state.locationSubscriptionMap[location.id]?.contains(subscriptionEndpt)){
if(state.locationSubscriptionMap[location.id].size() == 1){
state.locationSubscriptionMap.remove(location.id)
} else {
state.locationSubscriptionMap[location.id].remove(subscriptionEndpt)
}
state.verificationKeyMap.remove(subscriptionEndpt)
log.info "Removed subscription URL: ${subscriptionEndpt} for Location ${location.name}"
}
}else{
httpError(400, "missing input parameter: subscriptionURL")
}
} catch (e) {
httpError(500, "something went wrong: $e")
}
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
log.info "Current verification key map is ${state.verificationKeyMap}"
} }
//When events are triggered, send HTTP post to web socket servers //When events are triggered, send HTTP post to web socket servers
def eventHandler(evt) { def deviceEventHandler(evt) {
def evt_device_id = evt.deviceId def evtDevice = evt.device
def evt_device_value = evt.value def evtDeviceType = getDeviceType(evtDevice)
def evt_name = evt.name def deviceData = [];
def evt_device = evt.device
def evt_deviceType = getDeviceType(evt_device); if(evt.data != null){
def params = [ def evtData = parseJson(evt.data)
uri : "${state.endpointURL}/${state.connectionId}", log.info "Received event for ${evtDevice.displayName}, data: ${evtData}, description: ${evt.descriptionText}"
body: [ }
name : evt_device.displayName,
id : evt_device.id, if(evtDeviceType == "thermostat") {
deviceType : evt_deviceType, deviceData = [name: evtDevice.displayName, id: evtDevice.id, status:evtDevice.status, deviceType:evtDeviceType, manufacturer:evtDevice.manufacturerName, model:evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationMode: getLocationModeInfo(), locationId: location.id ]
manufacturer: evt_device.getManufacturerName(), } else {
model : evt_device.getModelName(), deviceData = [name: evtDevice.displayName, id: evtDevice.id, status:evtDevice.status, deviceType:evtDeviceType, manufacturer:evtDevice.manufacturerName, model:evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationId: location.id ]
attributes : deviceAttributeList(evt_device) }
]
] def params = [ body: deviceData ]
try {
//send event to all subscriptions urls
log.debug "Current subscription urls for ${evtDevice.displayName} is ${state.deviceSubscriptionMap[evtDevice.id]}"
state.deviceSubscriptionMap[evtDevice.id].each {
params.uri = "${it}"
if(state.verificationKeyMap[it] != null ){
def key = state.verificationKeyMap[it]
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
}
log.trace "POST URI: ${params.uri}" log.trace "POST URI: ${params.uri}"
log.trace "Header: ${params.header}"
log.trace "Payload: ${params.body}" log.trace "Payload: ${params.body}"
httpPostJson(params) { resp -> try{
resp.headers.each { httpPostJson(params) { resp ->
log.debug "${it.name} : ${it.value}" log.trace "response status code: ${resp.status}"
log.trace "response data: ${resp.data}"
} }
log.trace "response status code: ${resp.status}" } catch (e) {
log.trace "response data: ${resp.data}" log.error "something went wrong: $e"
} }
} catch (e) {
log.debug "something went wrong: $e"
} }
} }
//Endpoints function: update subcription endpoint url [state.endpoint] def locationEventHandler(evt) {
void updateEndpointURL() { log.info "Received event for location ${location.name}/${location.id}, Event: ${evt.name}, description: ${evt.descriptionText}, apiServerUrl: ${apiServerUrl("")}"
state.endpointURL = params.url switch(evt.name){
log.info "Updated EndpointURL to ${state.endpointURL}" case "DeviceCreated":
case "DeviceDeleted":
def evtDevice = evt.device
def evtDeviceType = getDeviceType(evtDevice)
def params = [ body: [ eventType:evt.name, deviceId: evtDevice.id, locationId: location.id ] ]
if (evt.name == "DeviceDeleted" && state.deviceSubscriptionMap[deviceId] != null){
state.deviceSubscriptionMap.remove(evtDevice.id)
}
state.locationSubscriptionMap[location.id].each {
params.uri = "${it}"
if(state.verificationKeyMap[it] != null ){
def key = state.verificationKeyMap[it]
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
}
log.trace "POST URI: ${params.uri}"
log.trace "Header: ${params.header}"
log.trace "Payload: ${params.body}"
try{
httpPostJson(params) { resp ->
log.trace "response status code: ${resp.status}"
log.trace "response data: ${resp.data}"
}
} catch (e) {
log.error "something went wrong: $e"
}
}
case "DeviceUpdated":
default:
break
}
} }
//Endpoints function: update global variable [state.connectionId] private ComputHMACValue(key, data){
void updateConnectionId() { try {
def connId = params.connId SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1")
state.connectionId = connId Mac mac = Mac.getInstance("HmacSHA1")
log.info "Updated ConnectionID to ${state.connectionId}" mac.init(secretKeySpec)
byte[] digest = mac.doFinal(data.getBytes("UTF-8"))
return byteArrayToString(digest)
} catch (InvalidKeyException e) {
log.error "Invalid key exception while converting to HMac SHA1"
}
} }
private def byteArrayToString(byte[] data) {
BigInteger bigInteger = new BigInteger(1, data)
String hash = bigInteger.toString(16)
return hash
}
/*** Device Query/Update Functions ***/
//Endpoints function: return all device data in json format //Endpoints function: return all device data in json format
def getDevices() { def getDevices() {
def deviceData = [] def deviceData = []
inputs?.each { inputs?.each {
def deviceType = getDeviceType(it) def deviceType = getDeviceType(it)
if (deviceType == "thermostat") { if(deviceType == "thermostat") {
deviceData << [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()] deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType), locationMode: getLocationModeInfo()]
} else { } else {
deviceData << [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)] deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
} }
} }
@@ -246,11 +419,12 @@ def getDevice() {
def it = findDevice(params.id) def it = findDevice(params.id)
def deviceType = getDeviceType(it) def deviceType = getDeviceType(it)
def device def device
if (deviceType == "thermostat") { if(deviceType == "thermostat") {
device = [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it), locationMode: getLocationModeInfo()] device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it,deviceType), locationMode: getLocationModeInfo()]
} else { } else {
device = [name: it.displayName, id: it.id, deviceType: deviceType, manufacturer: it.getManufacturerName(), model: it.getModelName(), attributes: deviceAttributeList(it)] device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
} }
log.debug "getDevice, return: ${device}" log.debug "getDevice, return: ${device}"
return device return device
} }
@@ -261,18 +435,18 @@ void updateDevice() {
request.JSON.each { request.JSON.each {
def command = it.key def command = it.key
def value = it.value def value = it.value
if (command) { if (command){
def commandList = mapDeviceCommands(command, value) def commandList = mapDeviceCommands(command, value)
command = commandList[0] command = commandList[0]
value = commandList[1] value = commandList[1]
if (command == "setAwayMode") { if (command == "setAwayMode") {
log.info "Setting away mode to ${value}" log.info "Setting away mode to ${value}"
if (location.modes?.find { it.name == value }) { if (location.modes?.find {it.name == value}) {
location.setMode(value) location.setMode(value)
} }
} else if (command == "thermostatSetpoint") { }else if (command == "thermostatSetpoint"){
switch (device.currentThermostatMode) { switch(device.currentThermostatMode){
case "cool": case "cool":
log.info "Update: ${device.displayName}, [${command}, ${value}]" log.info "Update: ${device.displayName}, [${command}, ${value}]"
device.setCoolingSetpoint(value) device.setCoolingSetpoint(value)
@@ -286,7 +460,7 @@ void updateDevice() {
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.") httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
break break
} }
} else if (!device) { }else if (!device) {
log.error "updateDevice, Device not found" log.error "updateDevice, Device not found"
httpError(404, "Device not found") httpError(404, "Device not found")
} else if (!device.hasCommand(command)) { } else if (!device.hasCommand(command)) {
@@ -296,11 +470,11 @@ void updateDevice() {
if (command == "setColor") { if (command == "setColor") {
log.info "Update: ${device.displayName}, [${command}, ${value}]" log.info "Update: ${device.displayName}, [${command}, ${value}]"
device."$command"(hex: value) device."$command"(hex: value)
} else if (value.isNumber()) { } else if(value.isNumber()) {
def intValue = value as Integer def intValue = value as Integer
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]" log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
device."$command"(intValue) device."$command"(intValue)
} else if (value) { } else if (value){
log.info "Update: ${device.displayName}, [${command}, ${value}]" log.info "Update: ${device.displayName}, [${command}, ${value}]"
device."$command"(value) device."$command"(value)
} else { } else {
@@ -322,41 +496,49 @@ private getLocationModeInfo() {
//Map each device to a type given it's capabilities //Map each device to a type given it's capabilities
private getDeviceType(device) { private getDeviceType(device) {
def deviceType def deviceType
def caps = device.capabilities def capabilities = device.capabilities
log.debug "capabilities: [${device}, ${caps}]" log.debug "capabilities: [${device}, ${capabilities}]"
log.debug "supported commands: [${device}, ${device.supportedCommands}]" log.debug "supported commands: [${device}, ${device.supportedCommands}]"
caps.each {
switch (it.name.toLowerCase()) { //Loop through the device capability list to determine the device type.
capabilities.each {capability ->
switch(capability.name.toLowerCase())
{
case "switch": case "switch":
deviceType = "switch" deviceType = "switch"
break
case "switch level": //If the device also contains "Switch Level" capability, identify it as a "light" device.
deviceType = "light" if (capabilities.any{it.name.toLowerCase() == "switch level"}){
break
case "contact sensor": //If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
deviceType = "contactSensor" if (capabilities.any{it.name.toLowerCase() == "power meter"}){
deviceType = "dimmerSwitch"
return deviceType
} else {
deviceType = "light"
return deviceType
}
}
break break
case "garageDoorControl": case "garageDoorControl":
deviceType = "garageDoor" deviceType = "garageDoor"
break return deviceType
case "lock": case "lock":
deviceType = "lock" deviceType = "lock"
break return deviceType
case "video camera": case "video camera":
deviceType = "camera" deviceType = "camera"
break return deviceType
case "motion sensor":
deviceType = "motionSensor"
break
case "presence sensor":
deviceType = "presenceSensor"
break
case "thermostat": case "thermostat":
deviceType = "thermostat" deviceType = "thermostat"
break return deviceType
case "acceleration sensor":
case "contact sensor":
case "motion sensor":
case "presence sensor":
case "water sensor": case "water sensor":
deviceType = "waterSensor" deviceType = "genericSensor"
break return deviceType
default: default:
break break
} }
@@ -370,14 +552,33 @@ private findDevice(deviceId) {
} }
//Return a list of device attributes //Return a list of device attributes
private deviceAttributeList(device) { private deviceAttributeList(device, deviceType) {
device.supportedAttributes.collectEntries { attribute -> def attributeList = [:]
try { def allAttributes = device.supportedAttributes
[(attribute.name): device.currentValue(attribute.name)] allAttributes.each { attribute ->
} catch (e) { try {
[(attribute.name): null] def currentState = device.currentState(attribute.name)
if(currentState != null ){
switch(attribute.name){
case 'temperature':
attributeList.putAll([ (attribute.name): currentState.value, 'temperatureScale':location.temperatureScale ])
break;
default:
attributeList.putAll([(attribute.name): currentState.value ])
break;
}
if( deviceType == "genericSensor" ){
def key = attribute.name + "_lastUpdated"
attributeList.putAll([ (key): currentState.isoDate ])
}
} else {
attributeList.putAll([ (attribute.name): null ]);
}
} catch(e) {
attributeList.putAll([ (attribute.name): null ]);
} }
} }
return attributeList
} }
//Map device command and value. //Map device command and value.
@@ -397,7 +598,7 @@ private mapDeviceCommands(command, value) {
resultValue = "" resultValue = ""
} }
break break
// light attributes // light attributes
case "level": case "level":
resultCommand = "setLevel" resultCommand = "setLevel"
resultValue = value resultValue = value
@@ -410,14 +611,14 @@ private mapDeviceCommands(command, value) {
resultCommand = "setSaturation" resultCommand = "setSaturation"
resultValue = value resultValue = value
break break
case "ct": case "colorTemperature":
resultCommand = "setColorTemperature" resultCommand = "setColorTemperature"
resultValue = value resultValue = value
break break
case "color": case "color":
resultCommand = "setColor" resultCommand = "setColor"
resultValue = value resultValue = value
// thermostat attributes // thermostat attributes
case "hvacMode": case "hvacMode":
resultCommand = "setThermostatMode" resultCommand = "setThermostatMode"
resultValue = value resultValue = value
@@ -442,20 +643,20 @@ private mapDeviceCommands(command, value) {
resultCommand = "thermostatSetpoint" resultCommand = "thermostatSetpoint"
resultValue = value resultValue = value
break break
// lock attributes // lock attributes
case "locked": case "locked":
if (value == 1 || value == "1" || value == "lock") { if (value == 1 || value == "1" || value == "lock") {
resultCommand = "lock" resultCommand = "lock"
resultValue = "" resultValue = ""
} else if (value == 0 || value == "0" || value == "unlock") { }
else if (value == 0 || value == "0" || value == "unlock") {
resultCommand = "unlock" resultCommand = "unlock"
resultValue = "" resultValue = ""
} }
break break
default: default:
break break
} }
return [resultCommand, resultValue] return [resultCommand,resultValue]
} }

View File

@@ -57,7 +57,7 @@ def authPage(){
atomicState.accessToken = state.accessToken atomicState.accessToken = state.accessToken
} }
def redirectUrl = oauthInitUrl() def redirectUrl = oauthInitUrl()
def uninstallAllowed = false def uninstallAllowed = false
def oauthTokenProvided = false def oauthTokenProvided = false
if(atomicState.authToken){ if(atomicState.authToken){
@@ -78,9 +78,9 @@ def authPage(){
} }
}else{ }else{
return dynamicPage(name: "auth", title: "Step 1 of 2 - Completed", nextPage:"deviceList", uninstall:uninstallAllowed) { return dynamicPage(name: "auth", title: "Step 1 of 2 - Completed", nextPage:"deviceList", uninstall:uninstallAllowed) {
section(){ section(){
paragraph "You are logged in to myplantlink.com, tap next to continue", image: iconUrl paragraph "You are logged in to myplantlink.com, tap next to continue", image: iconUrl
href(url:redirectUrl, title:"Or", description:"tap to switch accounts") href(url:redirectUrl, title:"Or", description:"tap to switch accounts")
} }
} }
} }
@@ -137,44 +137,36 @@ def dock_sensor(device_serial, expected_plant_name) {
contentType: "application/json", contentType: "application/json",
] ]
log.debug "Creating new plant on myplantlink.com - ${expected_plant_name}" log.debug "Creating new plant on myplantlink.com - ${expected_plant_name}"
try { httpPost(docking_params) { docking_response ->
httpPost(docking_params) { docking_response -> if (parse_api_response(docking_response, "Docking a link")) {
if (parse_api_response(docking_response, "Docking a link")) { if (docking_response.data.plants.size() == 0) {
if (docking_response.data.plants.size() == 0) { log.debug "creating plant for - ${expected_plant_name}"
log.debug "creating plant for - ${expected_plant_name}" plant_post_body_map["name"] = expected_plant_name
plant_post_body_map["name"] = expected_plant_name plant_post_body_map['links_key'] = [docking_response.data.key]
plant_post_body_map['links_key'] = [docking_response.data.key] def plant_post_body_json_builder = new JsonBuilder(plant_post_body_map)
def plant_post_body_json_builder = new JsonBuilder(plant_post_body_map) plant_post_params["body"] = plant_post_body_json_builder.toString()
plant_post_params["body"] = plant_post_body_json_builder.toString() httpPost(plant_post_params) { plant_post_response ->
try { if(parse_api_response(plant_post_response, 'creating plant')){
httpPost(plant_post_params) { plant_post_response -> def attached_map = atomicState.attached_sensors
if(parse_api_response(plant_post_response, 'creating plant')){ attached_map[device_serial] = plant_post_response.data
def attached_map = atomicState.attached_sensors atomicState.attached_sensors = attached_map
attached_map[device_serial] = plant_post_response.data
atomicState.attached_sensors = attached_map
}
}
} catch (Exception f) {
log.debug "call failed $f"
} }
} else {
def plant = docking_response.data.plants[0]
def attached_map = atomicState.attached_sensors
attached_map[device_serial] = plant
atomicState.attached_sensors = attached_map
checkAndUpdatePlantIfNeeded(plant, expected_plant_name)
} }
} else {
def plant = docking_response.data.plants[0]
def attached_map = atomicState.attached_sensors
attached_map[device_serial] = plant
atomicState.attached_sensors = attached_map
checkAndUpdatePlantIfNeeded(plant, expected_plant_name)
} }
} }
} catch (Exception e) {
log.debug "call failed $e"
} }
return true return true
} }
def checkAndUpdatePlantIfNeeded(plant, expected_plant_name){ def checkAndUpdatePlantIfNeeded(plant, expected_plant_name){
def plant_put_params = [ def plant_put_params = [
uri : appSettings.https_plantLinkServer, uri : appSettings.https_plantLinkServer,
headers : ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"], headers : ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"],
contentType : "application/json" contentType : "application/json"
] ]
@@ -182,16 +174,12 @@ def checkAndUpdatePlantIfNeeded(plant, expected_plant_name){
log.debug "updating plant for - ${expected_plant_name}" log.debug "updating plant for - ${expected_plant_name}"
plant_put_params["path"] = "/api/v1/plants/${plant.key}" plant_put_params["path"] = "/api/v1/plants/${plant.key}"
def plant_put_body_map = [ def plant_put_body_map = [
name: expected_plant_name name: expected_plant_name
] ]
def plant_put_body_json_builder = new JsonBuilder(plant_put_body_map) def plant_put_body_json_builder = new JsonBuilder(plant_put_body_map)
plant_put_params["body"] = plant_put_body_json_builder.toString() plant_put_params["body"] = plant_put_body_json_builder.toString()
try { httpPut(plant_put_params) { plant_put_response ->
httpPut(plant_put_params) { plant_put_response -> parse_api_response(plant_put_response, 'updating plant name')
parse_api_response(plant_put_response, 'updating plant name')
}
} catch (Exception e) {
log.debug "call failed $e"
} }
} }
} }
@@ -210,29 +198,25 @@ def moistureHandler(event){
contentType: "application/json", contentType: "application/json",
body: event.value body: event.value
] ]
try { httpPost(measurement_post_params) { measurement_post_response ->
httpPost(measurement_post_params) { measurement_post_response -> if (parse_api_response(measurement_post_response, 'creating moisture measurement') &&
if (parse_api_response(measurement_post_response, 'creating moisture measurement') && measurement_post_response.data.size() >0){
measurement_post_response.data.size() >0){ def measurement = measurement_post_response.data[0]
def measurement = measurement_post_response.data[0] def plant = measurement.plant
def plant = measurement.plant log.debug plant
log.debug plant checkAndUpdatePlantIfNeeded(plant, expected_plant_name)
checkAndUpdatePlantIfNeeded(plant, expected_plant_name) plantlinksensors.each{ sensor_device ->
plantlinksensors.each{ sensor_device -> if (sensor_device.id == event.deviceId){
if (sensor_device.id == event.deviceId){ sensor_device.setStatusIcon(plant.status)
sensor_device.setStatusIcon(plant.status) if (plant.last_measurements && plant.last_measurements[0].moisture){
if (plant.last_measurements && plant.last_measurements[0].moisture){ sensor_device.setPlantFuelLevel(plant.last_measurements[0].moisture * 100 as int)
sensor_device.setPlantFuelLevel(plant.last_measurements[0].moisture * 100 as int) }
} if (plant.last_measurements && plant.last_measurements[0].battery){
if (plant.last_measurements && plant.last_measurements[0].battery){ sensor_device.setBatteryLevel(plant.last_measurements[0].battery * 100 as int)
sensor_device.setBatteryLevel(plant.last_measurements[0].battery * 100 as int)
}
} }
} }
} }
} }
} catch (Exception e) {
log.debug "call failed $e"
} }
} }
} }
@@ -251,12 +235,8 @@ def batteryHandler(event){
contentType: "application/json", contentType: "application/json",
body: event.value body: event.value
] ]
try { httpPost(measurement_post_params) { measurement_post_response ->
httpPost(measurement_post_params) { measurement_post_response -> parse_api_response(measurement_post_response, 'creating battery measurement')
parse_api_response(measurement_post_response, 'creating battery measurement')
}
} catch (Exception e) {
log.debug "call failed $e"
} }
} }
} }
@@ -268,7 +248,7 @@ def getDeviceSerialFromEvent(event){
} }
def oauthInitUrl(){ def oauthInitUrl(){
atomicState.oauthInitState = UUID.randomUUID().toString() atomicState.oauthInitState = UUID.randomUUID().toString()
def oauthParams = [ def oauthParams = [
response_type: "code", response_type: "code",
client_id: appSettings.client_id, client_id: appSettings.client_id,
@@ -295,12 +275,8 @@ def swapToken(){
] ]
def jsonMap def jsonMap
try { httpPost(postParams) { resp ->
httpPost(postParams) { resp -> jsonMap = resp.data
jsonMap = resp.data
}
} catch (Exception e) {
log.debug "call failed $e"
} }
atomicState.refreshToken = jsonMap.refresh_token atomicState.refreshToken = jsonMap.refresh_token
@@ -311,33 +287,33 @@ def swapToken(){
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<style> <style>
.container { .container {
padding:25px; padding:25px;
} }
.flex1 { .flex1 {
width:33%; width:33%;
float:left; float:left;
text-align: center; text-align: center;
} }
p { p {
font-size: 2em; font-size: 2em;
font-family: Verdana, Geneva, sans-serif; font-family: Verdana, Geneva, sans-serif;
text-align: center; text-align: center;
color: #777; color: #777;
} }
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="flex1"><img src="https://dashboard.myplantlink.com/images/PLlogo.png" alt="PlantLink" height="75"/></div> <div class="flex1"><img src="https://dashboard.myplantlink.com/images/PLlogo.png" alt="PlantLink" height="75"/></div>
<div class="flex1"><img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/connected-device-icn%402x.png" alt="connected to" height="25" style="padding-top:25px;" /></div> <div class="flex1"><img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/connected-device-icn%402x.png" alt="connected to" height="25" style="padding-top:25px;" /></div>
<div class="flex1"><img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/st-logo%402x.png" alt="SmartThings" height="75"/></div> <div class="flex1"><img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/st-logo%402x.png" alt="SmartThings" height="75"/></div>
<br clear="all"> <br clear="all">
</div> </div>
<div class="container"> <div class="container">
<p>Your PlantLink Account is now connected to SmartThings!</p> <p>Your PlantLink Account is now connected to SmartThings!</p>
<p style="color:green;">Click <strong>Done</strong> at the top right to finish setup.</p> <p style="color:green;">Click <strong>Done</strong> at the top right to finish setup.</p>
</div> </div>
</body> </body>
</html> </html>
""" """

View File

@@ -19,9 +19,9 @@
author: "SmartThings", author: "SmartThings",
description: "Control your Bose SoundTouch speakers", description: "Control your Bose SoundTouch speakers",
category: "SmartThings Labs", category: "SmartThings Labs",
iconUrl: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon.png", iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x.png", iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x-1.png", iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
singleInstance: true singleInstance: true
) )
@@ -104,7 +104,7 @@ def deviceDiscovery()
return dynamicPage(name:"deviceDiscovery", title:"Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) { return dynamicPage(name:"deviceDiscovery", title:"Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
section("Please wait while we discover your ${getDeviceName()}. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") { section("Please wait while we discover your ${getDeviceName()}. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices, submitOnChange: true input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices
} }
} }
} }
@@ -196,8 +196,6 @@ def addDevice(){
d = addChildDevice(getNameSpace(), getDeviceName(), dni, newDevice?.value.hub, [label:"${deviceName}"]) d = addChildDevice(getNameSpace(), getDeviceName(), dni, newDevice?.value.hub, [label:"${deviceName}"])
d.boseSetDeviceID(newDevice.value.deviceID) d.boseSetDeviceID(newDevice.value.deviceID)
log.trace "Created ${d.displayName} with id $dni" log.trace "Created ${d.displayName} with id $dni"
// sync DTH with device, done here as it currently don't work from the DTH's installed() method
d.refresh()
} else { } else {
log.trace "${d.displayName} with id $dni already exists" log.trace "${d.displayName} with id $dni already exists"
} }

View File

@@ -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 == "") {

View File

@@ -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."
} }
} }