mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-05-16 22:07:24 +01:00
Modifying 'Publish a SmartApp for OpenT2T'
This commit is contained in:
@@ -322,21 +322,29 @@ private getLocationModeInfo() {
|
|||||||
//Map each device to a type given it's capabilities
|
//Map each device to a type given it's capabilities
|
||||||
private getDeviceType(device) {
|
private getDeviceType(device) {
|
||||||
def deviceType
|
def deviceType
|
||||||
def caps = device.capabilities
|
def capabilities = device.capabilities
|
||||||
log.debug "capabilities: [${device}, ${caps}]"
|
log.debug "capabilities: [${device}, ${capabilities}]"
|
||||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
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":
|
case "switch":
|
||||||
deviceType = "switch"
|
deviceType = "switch"
|
||||||
if (caps.any{it.name.toLowerCase() == "power meter"}){
|
|
||||||
|
//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
|
return deviceType
|
||||||
}
|
} else {
|
||||||
if (caps.any{it.name.toLowerCase() == "switch level"}){
|
|
||||||
deviceType = "light"
|
deviceType = "light"
|
||||||
return deviceType
|
return deviceType
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case "contact sensor":
|
case "contact sensor":
|
||||||
deviceType = "contactSensor"
|
deviceType = "contactSensor"
|
||||||
@@ -415,7 +423,7 @@ private mapDeviceCommands(command, value) {
|
|||||||
resultCommand = "setSaturation"
|
resultCommand = "setSaturation"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
case "ct":
|
case "colorTemperature":
|
||||||
resultCommand = "setColorTemperature"
|
resultCommand = "setColorTemperature"
|
||||||
resultValue = value
|
resultValue = value
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user