Adding remaining devices!
[smartthings-infrastructure.git] / Extractor / Extractor.groovy
index 2e82fb3..cf19c45 100644 (file)
@@ -78,6 +78,7 @@ import ThreeAxis.ThreeAxis
 import ThreeAxis.ThreeAxises
 import Momentary.Momentary
 import Momentary.Momentaries
+import RemainingDevices.RemainingDevices
 import Timer.SimulatedTimer
 
 //GlobalVariables
@@ -417,6 +418,15 @@ def input(LinkedHashMap metaData) {
                println "Options: "+metaData['options']
        }
        def contains = 0
+       def List = ["capability.carbonDioxideMeasurement", "capability.consumable", "capability.pHMeasurement", "capability.shockSensor", 
+                   "capability.signalStrength", "capability.soundSensor", "capability.soundPressureLevel", "capability.tamperAlert",
+                   "capability.ultravioletIndex", "capability.voltageMeasurement", "capability.windowShade", "capability.sensor"]
+       String thisCapability = ""      
+       if (metaData['type'] in List) {
+               int dot = metaData['type'].indexOf('.')
+               thisCapability = metaData['type'].substring(dot + 1)
+               metaData['type'] = "capability.remainingDevices"
+       }
        switch(metaData['type']) {
                case "capability.lock":
                        globalObjects.eachLine { line ->
@@ -2051,6 +2061,29 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsApp2.append("def "+metaData['name']+" = \""+userInput+"\"\n")
                        }
                        break
+               case "capability.remainingDevices":
+                       String nameOfObject = thisCapability+"Object"
+                       globalObjects.eachLine { line ->
+                               if(line.contains(nameOfObject)){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def $nameOfObject = new RemainingDevices(sendEvent, 1)\n")
+
+                       settings.put(metaData['name'], new RemainingDevices({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class remaining devices!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.$nameOfObject\n")               
+                       } else {
+                               extractedObjectsApp2.append("//Object for class remaining devices!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.$nameOfObject\n")
+                       }
+                       break
                default:
                        break
        }