Value filtering finished
[smartthings-infrastructure.git] / Methods / eventHandler.groovy
1 /////////////////////////////////////////////////////////////////////
2 def eventHandler(LinkedHashMap eventDataMap) {
3         def value = eventDataMap["value"]
4         def name = eventDataMap["name"]
5         def deviceId = eventDataMap["deviceId"]
6         def descriptionText = eventDataMap["descriptionText"]
7         def displayed = eventDataMap["displayed"]
8         def linkText = eventDataMap["linkText"]
9         def isStateChange = eventDataMap["isStateChange"]
10         def unit = eventDataMap["unit"]
11         def data = eventDataMap["data"]
12
13         for (int i = 0;i < app2.eventList.size();i++) {
14                 if (app2.eventList[i] == name &&
15                    (app2.valueList[i] == "" || app2.valueList == value)) {
16                         def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
17                         if (app2.functionList[i] instanceof String) {
18                                 String toCall = app2.functionList[i]
19                                 app2."$toCall"(event)
20                         }
21                         else
22                                 app2.functionList[i](event)
23                 }
24         }
25
26         for (int i = 0;i < app1.eventList.size();i++) {
27                 if (app1.eventList[i] == name &&
28                    (app1.valueList[i] == "" || app1.valueList == value)) {
29                         def event = new Event(value, name, deviceId, descriptionText, displayed, linkText, linkText, isStateChange, unit, data)
30                         if (app1.functionList[i] instanceof String) {
31                                 String toCall = app1.functionList[i]
32                                 app1."$toCall"(event)
33                         }
34                         else
35                                 app1.functionList[i](event)
36                 }
37         }
38 }