From f04a9e3f7ad97e611bf0b6692b6676b8a8040851 Mon Sep 17 00:00:00 2001 From: Lars Finander Date: Mon, 29 Feb 2016 13:41:58 -0800 Subject: [PATCH] DVCSMP-1516 Hue (Connect) throws 15k groovy.lang.MissingPropertyException per day -Only parse messages with JSON if they are from Hue bridge --- smartapps/smartthings/hue-connect.src/hue-connect.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/smartapps/smartthings/hue-connect.src/hue-connect.groovy b/smartapps/smartthings/hue-connect.src/hue-connect.groovy index b8d3f54..048390f 100644 --- a/smartapps/smartthings/hue-connect.src/hue-connect.groovy +++ b/smartapps/smartthings/hue-connect.src/hue-connect.groovy @@ -455,7 +455,7 @@ def locationHandler(evt) { log.error "/description.xml returned a bridge that didn't exist" } } - } else if(headerString?.contains("json")) { + } else if(headerString?.contains("json") && isValidSource(parsedEvent.mac)) { log.trace "description.xml response (application/json)" def body = new groovy.json.JsonSlurper().parseText(parsedEvent.body) if (body.success != null) { @@ -494,6 +494,11 @@ def doDeviceSync(){ discoverBridges() } +def isValidSource(macAddress) { + def vbridges = getVerifiedHueBridges() + return (vbridges?.find {"${it.value.mac}" == macAddress}) != null +} + ///////////////////////////////////// //CHILD DEVICE METHODS /////////////////////////////////////