Skip to content

Commit

Permalink
PROB-2126 - Harmony activity offline fix (SmartThingsCommunity#3305)
Browse files Browse the repository at this point in the history
Quotes
  • Loading branch information
juano2310 authored and workingmonk committed Jul 26, 2018
1 parent 0af960e commit a018119
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ def poll() {
def pollResponse(response, data) {
if (response.hasError()) {
log.error "Harmony - response has error: $response.errorMessage"
def activities = getChildDevices()
// Device-Watch relies on the Logitech Harmony Cloud to get the Device state.
activities.each { activity ->
if ("${activity.deviceNetworkId}".contains("harmony-${it.key}")) {
activity.sendEvent(name: "DeviceWatch-DeviceStatus", value: "offline", displayed: false, isStateChange: true)
}
}
if (response.status == 401) { // token is expired
state.remove("HarmonyAccessToken")
log.warn "Harmony - Access token has expired"
Expand All @@ -539,10 +546,9 @@ def pollResponse(response, data) {
def activities = getChildDevices()
ResponseValues.hubs.each {
// Device-Watch relies on the Logitech Harmony Cloud to get the Device state.
def isAlive = it.value.status
activities.each { activity ->
if ("${activity.deviceNetworkId}".contains("harmony-${it.key}")) {
activity.sendEvent(name: "DeviceWatch-DeviceStatus", value: isAlive!=504? "online":"offline", displayed: false, isStateChange: true)
activity.sendEvent(name: "DeviceWatch-DeviceStatus", value: "online", displayed: false, isStateChange: true)
}
}
if (it.value.message == "OK") {
Expand Down

0 comments on commit a018119

Please sign in to comment.