From 7d07b93694f4f1fd6f4fa7ad19931f111277a796 Mon Sep 17 00:00:00 2001 From: Juan Pablo Risso Date: Tue, 16 Feb 2016 14:38:37 -0500 Subject: [PATCH] PROB-870 - Harmony fails to save credentials It seams like the user removed some activities on Harmony side without removing them from SmartThings. This is causing an issue when adding new activities. This fix checks if the activity still exists before creating a new device. --- .../logitech-harmony-connect.groovy | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy b/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy index 03c5ccc..9fc1a5d 100644 --- a/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy +++ b/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy @@ -419,9 +419,11 @@ def addDevice() { def d = getChildDevice(dni) if(!d) { def newAction = state.HarmonyActivities.find { it.key == dni } - d = addChildDevice("smartthings", "Harmony Activity", dni, null, [label:"${newAction.value} [Harmony Activity]"]) - log.trace "created ${d.displayName} with id $dni" - poll() + if (newAction) { + d = addChildDevice("smartthings", "Harmony Activity", dni, null, [label:"${newAction.value} [Harmony Activity]"]) + log.trace "created ${d.displayName} with id $dni" + poll() + } } else { log.trace "found ${d.displayName} with id $dni already exists" }