Adding 2 events for temperature sensors: above and below thresholds.
[smartthings-infrastructure.git] / Extractor / ExtractorScript.py
index c8786e6..b274e4d 100644 (file)
@@ -56,7 +56,7 @@ eventTypeCounterMap =  {'lock': 2,
                                                'trackDescription' : 1,
                                                'trackData' : 1,
                                                'mute' : 2,
-                                               'temperature' : 1,
+                                               'temperature' : 2,
                                                'heatingSetpoint' : 1,
                                                'coolingSetpoint' : 1,
                                                'thermostatSetpoint' : 1}
@@ -951,10 +951,21 @@ def ExtractEvents(extractedEvents):
                                eventVarCount = eventVarCounterMap[eventList[i]]
                                eventVarCounterMap[eventList[i]] = eventVarCount + 1
                        capability = capabilityMap[variable[eventVarCount]]
+                       #Write two events subsequently
+                       if capability == "capability.thermostat":
+                               event = open("eventSimulator/temperatureHighEvent.groovy", "r")
+                       elif capability == "capability.temperatureMeasurement":
+                               event = open("eventSimulator/temperatureHighMeasurementEvent.groovy", "r")
+                       for line in event:
+                               extractedEvents.write(line)
+                       event.close()
+                       extractedEvents.write("\n\t\t\tbreak\n")
+                       counter = counter + 1
+                       extractedEvents.write("\t\tcase %d:\n" % counter)
                        if capability == "capability.thermostat":
-                               event = open("eventSimulator/temperatureEvent.groovy", "r")
+                               event = open("eventSimulator/temperatureLowEvent.groovy", "r")
                        elif capability == "capability.temperatureMeasurement":
-                               event = open("eventSimulator/temperatureMeasurementEvent.groovy", "r")
+                               event = open("eventSimulator/temperatureLowMeasurementEvent.groovy", "r")
                        for line in event:
                                extractedEvents.write(line)
                        event.close()