Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / Extractor / Extractor.groovy
index b049f61..96fb55f 100644 (file)
@@ -70,6 +70,10 @@ import Valve.Valve
 import Valve.Valves
 import MobilePresence.MobilePresence
 import MobilePresence.MobilePresences
+import ColorTemperature.ColorTemperature
+import ColorTemperature.ColorTemperatures
+import Button.Button
+import Button.Buttons
 import Timer.SimulatedTimer
 
 //GlobalVariables
@@ -244,7 +248,7 @@ def timeToday(String time, Object timeZone) {
 @Field def sleepSensorObject0
 @Field def sleepSensorObject1
 @Field def sleepSensorObject2
-//Global Object for class sleep sensor!
+//Global Object for class step sensor!
 @Field stepSensorObjects = 0
 @Field def stepSensorObject0
 @Field def stepSensorObject1
@@ -259,7 +263,7 @@ def timeToday(String time, Object timeZone) {
 @Field def temperatureMeasurementObject0
 @Field def temperatureMeasurementObject1
 @Field def temperatureMeasurementObject2
-//Global Object for class temperature measurement!
+//Global Object for class water sensor!
 @Field waterSensorObjects = 0
 @Field def waterSensorObject0
 @Field def waterSensorObject1
@@ -269,12 +273,21 @@ def timeToday(String time, Object timeZone) {
 @Field def valveObject0
 @Field def valveObject1
 @Field def valveObject2
-//Global Object for class valve!
+//Global Object for class mobile presence!
 @Field mobilePresenceObjects = 0
 @Field def mobilePresenceObject0
 @Field def mobilePresenceObject1
 @Field def mobilePresenceObject2
-
+//Global Object for class color temperature!
+@Field colorTemperatureObjects = 0
+@Field def colorTemperatureObject0
+@Field def colorTemperatureObject1
+@Field def colorTemperatureObject2
+//Global Object for class button!
+@Field buttonObjects = 0
+@Field def buttonObject0
+@Field def buttonObject1
+@Field def buttonObject2
 
 
 //Global variables
@@ -455,6 +468,41 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsConstructorApp2.append(metaData['name']+" = obj.alarmObject\n")
                        }
                        break
+               case "capability.button":
+                       globalObjects.eachLine { line ->
+                               if(line.contains("buttonObject")){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def buttonObject = new Buttons(sendEvent, 1)\n")
+
+                       if (buttonObjects == 0) {
+                               buttonObject0 = metaData['name']
+                               this[buttonObject0] = new Buttons({}, 1)
+                       } else if (buttonObjects == 1) {
+                               buttonObject1 = metaData['name']
+                               this[buttonObject1] = new Buttons({}, 1)
+                       } else if (buttonObjects == 2) {
+                               buttonObject2 = metaData['name']
+                               this[buttonObject2] = new Buttons({}, 1)
+                       }
+
+                       buttonObjects=buttonObjects+1
+
+                       settings.put(metaData['name'], new Buttons({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class Button!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.buttonObject\n")                
+                       } else {
+                               extractedObjectsApp2.append("//Object for class Button!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.buttonObject\n")
+                       }
+                       break
                case "capability.battery":
                        globalObjects.eachLine { line ->
                                if(line.contains("batteryObject")){
@@ -560,6 +608,41 @@ def input(LinkedHashMap metaData) {
                                extractedObjectsConstructorApp2.append(metaData['name']+" = obj.carbonMonoxideDetectorObject\n")
                        }
                        break
+               case "capability.colorTemperature":
+                       globalObjects.eachLine { line ->
+                               if(line.contains("colorTemperatureObject")){
+                                       contains = 1
+                               }
+                       }
+
+                       if (contains == 0)
+                               globalObjects.append("@Field def colorTemperatureObject = new ColorTemperatures(sendEvent, 1)\n")
+
+                       if (colorTemperatureObjects == 0) {
+                               colorTemperatureObject0 = metaData['name']
+                               this[colorTemperatureObject0] = new ColorTemperatures({}, 1)
+                       } else if (colorTemperatureObjects == 1) {
+                               colorTemperatureObject1 = metaData['name']
+                               this[colorTemperatureObject1] = new ColorTemperatures({}, 1)
+                       } else if (colorTemperatureObjects == 2) {
+                               colorTemperatureObject2 = metaData['name']
+                               this[colorTemperatureObject2] = new ColorTemperatures({}, 1)
+                       }
+
+                       colorTemperatureObjects=colorTemperatureObjects+1
+
+                       settings.put(metaData['name'], new ColorTemperatures({}, 1))
+
+                       if (App == "App1") {
+                               extractedObjectsApp1.append("//Object for class color temperature!\n")
+                               extractedObjectsApp1.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp1.append(metaData['name']+" = obj.colorTemperatureObject\n")              
+                       } else {
+                               extractedObjectsApp2.append("//Object for class color control!\n")
+                               extractedObjectsApp2.append("def "+metaData['name']+"\n")
+                               extractedObjectsConstructorApp2.append(metaData['name']+" = obj.colorTemperatureObject\n")
+                       }
+                       break
                case "capability.colorControl":
                        globalObjects.eachLine { line ->
                                if(line.contains("colorControlObject")){