Adding new events.
authorrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 01:35:57 +0000 (18:35 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 5 Aug 2019 01:35:57 +0000 (18:35 -0700)
15 files changed:
ColorTemperature/ColorTemperatures.groovy
Extractor/ExtractorScript.py
eventSimulator/colorControlSwitchOffDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/colorControlSwitchOnDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/colorTemperatureSwitchOffEvent.groovy [new file with mode: 0644]
eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/colorTemperatureSwitchOnEvent.groovy [new file with mode: 0644]
eventSimulator/relaySwitchOffDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/relaySwitchOnDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/switchLevelEvent.groovy
eventSimulator/switchLevelOffDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/switchLevelOnDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/switchOffDefaultEvent.groovy [new file with mode: 0644]
eventSimulator/switchOnDefaultEvent.groovy [new file with mode: 0644]

index aea527995d14b286e5f23ca21ebca1574d0cab9b..77f01753b04f03a1f4c4892d1905ffbd82ea7e1e 100644 (file)
@@ -29,7 +29,7 @@ public class ColorTemperatures {
                this.level = initLevel 
                def initTemp = Verify.getIntFromList(10000, 15000)
                this.colorTemperature = initTemp 
                this.level = initLevel 
                def initTemp = Verify.getIntFromList(10000, 15000)
                this.colorTemperature = initTemp 
-               def init = Verify.getBoolean
+               def init = Verify.getBoolean()
                if (init) {
                        this.currentSwitch = "off"
                } else {
                if (init) {
                        this.currentSwitch = "off"
                } else {
index bf8471f1a41935fa0191f93f558dc31b5679966d..37c294decf2823615df580ceda7af4dfe7c76cb8 100644 (file)
@@ -44,6 +44,8 @@ eventTypeCounterMap =  {'lock': 2,
                                                'thermostatFanMode' : 5,
                                                'thermostatOperatingState' : 5,
                                                'switch' : 2,
                                                'thermostatFanMode' : 5,
                                                'thermostatOperatingState' : 5,
                                                'switch' : 2,
+                                               'switch.on' : 1,
+                                               'switch.off' : 1,
                                                'location' : 3,
                                                'mode' : 3,
                                                'acceleration' : 2,
                                                'location' : 3,
                                                'mode' : 3,
                                                'acceleration' : 2,
@@ -692,6 +694,8 @@ def ExtractEvents(extractedEvents):
                                event = open("eventSimulator/relaySwitchOnEvent.groovy", "r")
                        elif capability == "capability.colorControl":
                                event = open("eventSimulator/colorControlSwitchOnEvent.groovy", "r")
                                event = open("eventSimulator/relaySwitchOnEvent.groovy", "r")
                        elif capability == "capability.colorControl":
                                event = open("eventSimulator/colorControlSwitchOnEvent.groovy", "r")
+                       elif capability == "capability.colorTemperature":
+                               event = open("eventSimulator/colorTemperatureSwitchOnEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
@@ -706,6 +710,56 @@ def ExtractEvents(extractedEvents):
                                event = open("eventSimulator/relaySwitchOffEvent.groovy", "r")
                        elif capability == "capability.colorControl":
                                event = open("eventSimulator/colorControlSwitchOffEvent.groovy", "r")
                                event = open("eventSimulator/relaySwitchOffEvent.groovy", "r")
                        elif capability == "capability.colorControl":
                                event = open("eventSimulator/colorControlSwitchOffEvent.groovy", "r")
+                       elif capability == "capability.colorTemperature":
+                               event = open("eventSimulator/colorTemperatureSwitchOffEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "switch.on":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
+                       #Write two events subsequently
+                       if capability == "capability.switch":
+                               event = open("eventSimulator/switchOnDefaultEvent.groovy", "r")
+                       elif capability == "capability.switchLevel":
+                               event = open("eventSimulator/switchLevelOnDefaultEvent.groovy", "r")
+                       elif capability == "capability.relaySwitch":
+                               event = open("eventSimulator/relaySwitchOnDefaultEvent.groovy", "r")
+                       elif capability == "capability.colorControl":
+                               event = open("eventSimulator/colorControlSwitchOnDefaultEvent.groovy", "r")
+                       elif capability == "capability.colorTemperature":
+                               event = open("eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+               elif eventList[i] == "switch.off":
+                       #Check which capability
+                       variable = eventVarMap[eventList[i]]
+                       if eventList[i] not in eventVarCounterMap.keys():
+                               eventVarCounterMap[eventList[i]] = 1
+                               eventVarCount = 0
+                       else:
+                               eventVarCount = eventVarCounterMap[eventList[i]]
+                               eventVarCounterMap[eventList[i]] = eventVarCount + 1
+                       capability = capabilityMap[variable[eventVarCount]]
+                       #Write two events subsequently
+                       if capability == "capability.switch":
+                               event = open("eventSimulator/switchOffDefaultEvent.groovy", "r")
+                       elif capability == "capability.switchLevel":
+                               event = open("eventSimulator/switchLevelOffDefaultEvent.groovy", "r")
+                       elif capability == "capability.relaySwitch":
+                               event = open("eventSimulator/relaySwitchOffDefaultEvent.groovy", "r")
+                       elif capability == "capability.colorControl":
+                               event = open("eventSimulator/colorControlSwitchOffDefaultEvent.groovy", "r")
+                       elif capability == "capability.colorTemperature":
+                               event = open("eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
                        for line in event:
                                extractedEvents.write(line)
                        event.close()
diff --git a/eventSimulator/colorControlSwitchOffDefaultEvent.groovy b/eventSimulator/colorControlSwitchOffDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..0787970
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorControlObject.setValue([name: "switch.off", value: "off", deviceId: "colorControlID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/colorControlSwitchOnDefaultEvent.groovy b/eventSimulator/colorControlSwitchOnDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..9f2c849
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorControlObject.setValue([name: "switch.on", value: "on", deviceId: "colorControlID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy b/eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..b78ba5b
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorTemperatureObject.setValue([name: "switch.off", value: "off", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/colorTemperatureSwitchOffEvent.groovy b/eventSimulator/colorTemperatureSwitchOffEvent.groovy
new file mode 100644 (file)
index 0000000..add53cb
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorTemperatureObject.setValue([name: "switch", value: "off", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy b/eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..0d2a0d6
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorTemperatureObject.setValue([name: "switch.on", value: "on", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/colorTemperatureSwitchOnEvent.groovy b/eventSimulator/colorTemperatureSwitchOnEvent.groovy
new file mode 100644 (file)
index 0000000..c64a841
--- /dev/null
@@ -0,0 +1,2 @@
+                       colorTemperatureObject.setValue([name: "switch", value: "on", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/relaySwitchOffDefaultEvent.groovy b/eventSimulator/relaySwitchOffDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..4b1f86e
--- /dev/null
@@ -0,0 +1,2 @@
+                       relaySwitchObject.setValue([name: "switch.off", value: "off", deviceId: "relaySwitchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/relaySwitchOnDefaultEvent.groovy b/eventSimulator/relaySwitchOnDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..b8a63e2
--- /dev/null
@@ -0,0 +1,2 @@
+                       relaySwitchObject.setValue([name: "switch.on", value: "on", deviceId: "relaySwitchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
index 1cd0c6cced378a499a91766f44c730aae8a72be4..177164a500f36113cdced5428517032ac73406fd 100644 (file)
@@ -1,2 +1,2 @@
                        switchLevelObject.setValue([name: "level", value: "45"/*A number between 0 to 100*/, deviceId: "switchLevelID0", descriptionText: "",
                        switchLevelObject.setValue([name: "level", value: "45"/*A number between 0 to 100*/, deviceId: "switchLevelID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/switchLevelOffDefaultEvent.groovy b/eventSimulator/switchLevelOffDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..1a7d43c
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchLevelObject.setValue([name: "switch.off", value: "off", deviceId: "switchLevelID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/switchLevelOnDefaultEvent.groovy b/eventSimulator/switchLevelOnDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..bd44730
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchLevelObject.setValue([name: "switch.on", value: "on", deviceId: "switchLevelID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/switchOffDefaultEvent.groovy b/eventSimulator/switchOffDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..d10deb1
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchObject.setValue([name: "switch.off", value: "off", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
diff --git a/eventSimulator/switchOnDefaultEvent.groovy b/eventSimulator/switchOnDefaultEvent.groovy
new file mode 100644 (file)
index 0000000..a25c74f
--- /dev/null
@@ -0,0 +1,2 @@
+                       switchObject.setValue([name: "switch.on", value: "on", deviceId: "switchID0", descriptionText: "",
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file