From 3c5d727d4c31b7057cef8d5d31aae5c4811b8a6d Mon Sep 17 00:00:00 2001 From: bflorian Date: Mon, 28 Nov 2016 16:00:42 -0500 Subject: [PATCH 1/2] PROB-1426 adding logging to Life360 --- .../life360-user.src/life360-user.groovy | 2 +- .../life360-connect.src/life360-connect.groovy | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/devicetypes/smartthings/life360-user.src/life360-user.groovy b/devicetypes/smartthings/life360-user.src/life360-user.groovy index d78f5c3..5b72c64 100644 --- a/devicetypes/smartthings/life360-user.src/life360-user.groovy +++ b/devicetypes/smartthings/life360-user.src/life360-user.groovy @@ -39,7 +39,7 @@ metadata { } def generatePresenceEvent(boolean present) { - log.debug "Here in generatePresenceEvent!" + log.info "Life360 generatePresenceEvent($present)" def value = formatValue(present) def linkText = getLinkText(device) def descriptionText = formatDescriptionText(linkText, present) diff --git a/smartapps/smartthings/life360-connect.src/life360-connect.groovy b/smartapps/smartthings/life360-connect.src/life360-connect.groovy index c4f2b8e..d32fc14 100644 --- a/smartapps/smartthings/life360-connect.src/life360-connect.groovy +++ b/smartapps/smartthings/life360-connect.src/life360-connect.groovy @@ -289,12 +289,12 @@ def initializeLife360Connection() { state.life360AccessToken = result.data.access_token return true; } - log.debug "Response=${result.data}" + log.info "Life360 initializeLife360Connection, response=${result.data}" return false; } catch (e) { - log.debug e + log.error "Life360 initializeLife360Connection, error: $e" return false; } @@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) { try { // we are going to just ignore any errors - log.debug "Generate Initial Event for New Device for Member = ${member.id}" + log.info "Life360 generateInitialEvent($member, $childDevice)" def place = state.places.find{it.id==settings.place} @@ -677,6 +677,8 @@ def generateInitialEvent (member, childDevice) { // log.debug "Distance Away = ${distanceAway}" boolean isPresent = (distanceAway <= placeRadius) + + log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent" // log.debug "External Id=${app.id}:${member.id}" @@ -718,7 +720,7 @@ def haversine(lat1, lon1, lat2, lon2) { def placeEventHandler() { - log.debug "In placeEventHandler method." + log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place" // the POST to this end-point will look like: // POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive @@ -729,8 +731,6 @@ def placeEventHandler() { def direction = params?.direction def timestamp = params?.timestamp - log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}" - if (placeId == settings.place) { def presenceState = (direction=="in") @@ -745,10 +745,10 @@ def placeEventHandler() { if (deviceWrapper) { deviceWrapper.generatePresenceEvent(presenceState) - log.debug "Event raised on child device: ${externalId}" + log.debug "Life360 event raised on child device: ${externalId}" } else { - log.debug "Couldn't find child device associated with inbound Life360 event." + log.warn "Life360 couldn't find child device associated with inbound Life360 event." } } From 99395910052b0230359c604616169c6b8316015c Mon Sep 17 00:00:00 2001 From: Zach Varberg Date: Tue, 29 Nov 2016 14:10:33 -0600 Subject: [PATCH 2/2] Don't use sendEvent for AppEngine parse events With the changes made for https://smartthings.atlassian.net/browse/DPROT-200 there were a few DTHs that were using sendEvent to directly send events generated during parse. However, because using sendEvent didn't result in parse returning an event AppEngine would send the description up to the cloud DTH to be handled. In some cases this resulted in multiple events for the same device trigger. This resolves: https://smartthings.atlassian.net/browse/DPROT-215 --- .../smartsense-moisture-sensor.groovy | 2 +- .../smartsense-motion-sensor.groovy | 2 +- .../smartsense-multi-sensor.groovy | 4 ++-- .../smartsense-open-closed-sensor.groovy | 2 +- .../smartsense-temp-humidity-sensor.groovy | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy index 535359a..a8cb9d5 100644 --- a/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy +++ b/devicetypes/smartthings/smartsense-moisture-sensor.src/smartsense-moisture-sensor.groovy @@ -128,7 +128,7 @@ private Map parseCatchAllMessage(String description) { if (cluster.command == 0x07) { if (cluster.data[0] == 0x00){ log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster - sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]] } else { log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}" diff --git a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy index f2f653b..fa71232 100644 --- a/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy +++ b/devicetypes/smartthings/smartsense-motion-sensor.src/smartsense-motion-sensor.groovy @@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) { if (cluster.command == 0x07) { if (cluster.data[0] == 0x00) { log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster - sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]] } else { log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}" diff --git a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy index 1183fe2..5cebcd0 100644 --- a/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy +++ b/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy @@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) { if (cluster.command == 0x07) { if(cluster.data[0] == 0x00) { log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster - sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]] } else { log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}" @@ -339,7 +339,7 @@ private Map getContactResult(value) { log.debug "Contact: ${device.displayName} value = ${value}" def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed' sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true) - sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true) + return [name: 'status', value: value, descriptionText: descriptionText, translatable: true] } private getAccelerationResult(numValue) { diff --git a/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy b/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy index 0d945cd..b8c9196 100644 --- a/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy +++ b/devicetypes/smartthings/smartsense-open-closed-sensor.src/smartsense-open-closed-sensor.groovy @@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) { if (cluster.command == 0x07){ if (cluster.data[0] == 0x00) { log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster - sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]] } else { log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}" diff --git a/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy b/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy index fe93ef3..cd9648e 100644 --- a/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy +++ b/devicetypes/smartthings/smartsense-temp-humidity-sensor.src/smartsense-temp-humidity-sensor.groovy @@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) { if (cluster.command == 0x07) { if (cluster.data[0] == 0x00){ log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster - sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) + resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]] } else { log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"