From 95f08aeb3d9719f4aced16b6256b4600538dbca2 Mon Sep 17 00:00:00 2001 From: spurohit1 Date: Wed, 6 Jul 2016 06:40:29 -0700 Subject: [PATCH] Update logitech-harmony-connect.groovy (#1009) If port is present in the callbackUrl then send command to hub else post the request through http. Removed isIP function since it is no longer required. --- .../logitech-harmony-connect.groovy | 23 ++----------------- 1 file changed, 2 insertions(+), 21 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 e3dda08..250eb58 100644 --- a/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy +++ b/smartapps/smartthings/logitech-harmony-connect.src/logitech-harmony-connect.groovy @@ -823,8 +823,8 @@ def deviceHandler(evt) { } def sendToHarmony(evt, String callbackUrl) { - def callback = new URI(callbackUrl) - if(isIP(callback.host)){ + def callback = new URI(callbackUrl) + if (callback.port != -1) { def host = callback.port != -1 ? "${callback.host}:${callback.port}" : callback.host def path = callback.query ? "${callback.path}?${callback.query}".toString() : callback.path sendHubCommand(new physicalgraph.device.HubAction( @@ -852,25 +852,6 @@ def sendToHarmony(evt, String callbackUrl) { } } -public static boolean isIP(String str) { - try { - String[] parts = str.split("\\."); - if (parts.length != 4) return false; - for (int i = 0; i < 4; ++i) { - int p - try { - p = Integer.parseInt(parts[i]); - } catch (Exception e) { - return false; - } - if (p > 255 || p < 0) return false; - } - return true; - } catch (Exception e) { - return false; - } -} - def listHubs() { location.hubs?.findAll { it.type.toString() == "PHYSICAL" }?.collect { hubItem(it) } }