Adding new events.
[smartthings-infrastructure.git] / Extractor / ExtractorScript.py
index bf8471f1a41935fa0191f93f558dc31b5679966d..37c294decf2823615df580ceda7af4dfe7c76cb8 100644 (file)
@@ -44,6 +44,8 @@ eventTypeCounterMap =  {'lock': 2,
                                                'thermostatFanMode' : 5,
                                                'thermostatOperatingState' : 5,
                                                'switch' : 2,
+                                               'switch.on' : 1,
+                                               'switch.off' : 1,
                                                '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")
+                       elif capability == "capability.colorTemperature":
+                               event = open("eventSimulator/colorTemperatureSwitchOnEvent.groovy", "r")
                        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")
+                       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()