From 2f20a339c3cfcc44fa62328fe58c537b1b74edf1 Mon Sep 17 00:00:00 2001 From: Lars Finander Date: Thu, 2 Mar 2017 12:16:03 -0700 Subject: [PATCH] DVCSMP-2487 OpenT2T: Update to 3/2 submission --- .../opent2t-smartapp-test.groovy | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy b/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy index 9951cfa..da82ae2 100644 --- a/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy +++ b/smartapps/opent2t/opent2t-smartapp-test.src/opent2t-smartapp-test.groovy @@ -322,19 +322,27 @@ private getLocationModeInfo() { //Map each device to a type given it's capabilities private getDeviceType(device) { def deviceType - def caps = device.capabilities - log.debug "capabilities: [${device}, ${caps}]" + def capabilities = device.capabilities + log.debug "capabilities: [${device}, ${capabilities}]" log.debug "supported commands: [${device}, ${device.supportedCommands}]" - caps.each { - switch (it.name.toLowerCase()) { + + //Loop through the device capability list to determine the device type. + capabilities.each { capability -> + switch (capability.name.toLowerCase()) { case "switch": deviceType = "switch" - if (caps.any { it.name.toLowerCase() == "power meter" }) { - return deviceType - } - if (caps.any { it.name.toLowerCase() == "switch level" }) { - deviceType = "light" - return deviceType + + //If the device also contains "Switch Level" capability, identify it as a "light" device. + if (capabilities.any { it.name.toLowerCase() == "switch level" }) { + + //If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device. + if (capabilities.any { it.name.toLowerCase() == "power meter" }) { + deviceType = "dimmerSwitch" + return deviceType + } else { + deviceType = "light" + return deviceType + } } break case "contact sensor": @@ -384,7 +392,7 @@ private deviceAttributeList(device) { } } -//Map device command and value. +//Map device command and value. //input command and value are from UWP, //returns resultCommand and resultValue that corresponds with function and value in SmartApps private mapDeviceCommands(command, value) { @@ -414,7 +422,7 @@ private mapDeviceCommands(command, value) { resultCommand = "setSaturation" resultValue = value break - case "ct": + case "colorTemperature": resultCommand = "setColorTemperature" resultValue = value break