Solving conflicts
[smartthings-infrastructure.git] / Extractor / Extractor.groovy
index 4c90690d7266816e62564a6e679c21e3e9b30280..16038e3b078f450b6f02b7e9b7d182de96ad8751 100644 (file)
@@ -76,6 +76,8 @@ import Button.Button
 import Button.Buttons
 import ThreeAxis.ThreeAxis
 import ThreeAxis.ThreeAxises
+import Momentary.Momentary
+import Momentary.Momentaries
 import Timer.SimulatedTimer
 
 //GlobalVariables
@@ -295,6 +297,11 @@ def timeToday(String time, Object timeZone) {
 @Field def threeAxisObject0
 @Field def threeAxisObject1
 @Field def threeAxisObject2
+//Global Object for class momentary switch device!
+@Field momentaryObjects = 0
+@Field def momentaryObject0
+@Field def momentaryObject1
+@Field def momentaryObject2
 
 
 //Global variables
@@ -895,6 +902,41 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsConstructorApp2.append(metaData['name']+" = obj.accelerationSensorObject\n")
                        }
                        break
+               case "capability.momentary":
+                       globalObjects.eachLine { line ->
+                               if(line.contains("momentoryObject")){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def momentaryObject = new Momentaries(sendEvent, 1)\n")
+
+                       if (momentaryObjects == 0) {
+                               momentaryObject0 = metaData['name']
+                               this[momentaryObject0] = new Momentaries({}, 1)
+                       } else if (momentaryObjects == 1) {
+                               momentaryObject1 = metaData['name']
+                               this[momentaryObject1] = new Momentaries({}, 1)
+                       } else if (momentaryObjects == 2) {
+                               momentaryObject2 = metaData['name']
+                               this[momentaryObject2] = new Momentaries({}, 1)
+                       }
+
+                       momentaryObjects=momentaryObjects+1
+
+                       settings.put(metaData['name'], new Momentaries({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class momentory switch class!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.momentaryObject\n")             
+                       } else {
+                               extractedObjectsApp2.append("//Object for class momentory Sensor!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.momentaryObject\n")
+                       }                       
+                       break
                case "capability.motionSensor":
                        globalObjects.eachLine { line ->
                                if(line.contains("motionSensorObject")){