}
////subscribe(obj, event, func)
def subscribe(Object obj, String event, Closure FunctionToCall) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
+ if ((event == "alarm.both")||(event == "alarm.siren")||(event == "alarm.strobe")||(event == "alarm.off")||(event == "alarm")) {
+ objectList.add(obj)
+ eventList.add("alarm")
+ functionList.add(FunctionToCall)
+ } else if ((event == "contact.open")||(event == "contact.closed")||(event == "contact")||(event == "tamper.tampered")) {
+ objectList.add(obj)
+ eventList.add("contact")
+ functionList.add(FunctionToCall)
+ } else if ((event == "doorState.open")||(event == "doorState.closed")||(event == "doorState")) {
+ objectList.add(obj)
+ eventList.add("doorState")
+ functionList.add(FunctionToCall)
+ } else if ((event == "mode")||(event == "mode.away")||(event == "mode.home")||(event == "mode.night")) {
+ objectList.add(obj)
+ eventList.add("Location")
+ functionList.add(FunctionToCall)
+ } else if ((event == "lock.locked")||(event == "lock.unlocked")||(event == "lock")) {
+ objectList.add(obj)
+ eventList.add("lock")
+ functionList.add(FunctionToCall)
+ } else if ((event == "motion.active")||(event == "motion.inactive")||(event == "motion")) {
+ objectList.add(obj)
+ eventList.add("motion")
+ functionList.add(FunctionToCall)
+ } else if ((event == "status")||(event == "status.playing")||(event == "status.stopped")||(event == "status.paused")) {
+ objectList.add(obj)
+ eventList.add("status")
+ functionList.add(FunctionToCall)
+ } else if ((event == "mute")||(event == "mute.muted")||(event == "mute.unmuted")) {
+ objectList.add(obj)
+ eventList.add("mute")
+ functionList.add(FunctionToCall)
+ } else if ((event == "presence")||(event == "presence.present")||(event == "presence.not present")) {
+ objectList.add(obj)
+ eventList.add("presence")
+ functionList.add(FunctionToCall)
+ } else if ((event == "smoke")||(event == "smoke.detected")||(event == "smoke.clear")||(event == "smoke.tested")) {
+ objectList.add(obj)
+ eventList.add("smoke")
+ functionList.add(FunctionToCall)
+ } else if ((event == "carbonMonoxide")||(event == "carbonMonoxide.detected")||(event == "carbonMonoxide.clear")||(event == "carbonMonoxide.tested")) {
+ objectList.add(obj)
+ eventList.add("carbonMonoxide")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatMode")||(event == "thermostatMode.cool")||(event == "thermostatMode.auto")||(event == "thermostatMode.emergencyHeat")||(event == "thermostatMode.heat")||(event == "thermostatMode.off")) {
+ objectList.add(obj)
+ eventList.add("thermostatMode")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatFanMode")||(event == "thermostatFanMode.auto")||(event == "thermostatFanMode.fanCirculate")||(event == "thermostatFanMode.circulate")||(event == "thermostatFanMode.fanOn")||(event == "thermostatFanMode.on")
+ ||(event == "fanMode")||(event == "fanMode.auto")||(event == "fanMode.fanCirculate")||(event == "fanMode.circulate")||(event == "fanMode.fanOn")||(event == "fanMode.on")) {
+ objectList.add(obj)
+ eventList.add("thermostatFanMode")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatOperatingState")||(event == "thermostatOperatingState.cooling")||(event == "thermostatOperatingState.fan only")||(event == "thermostatOperatingState.heating")||(event == "thermostatOperatingState.idle")
+ ||(event == "thermostatOperatingState.pending cool")||(event == "thermostatOperatingState.pending heat")||(event == "thermostatOperatingState.vent economizer")) {
+ objectList.add(obj)
+ eventList.add("thermostatOperatingState")
+ functionList.add(FunctionToCall)
+ } else if ((event == "switch")||(event == "switch.on")||(event == "switch.off")) {
+ objectList.add(obj)
+ eventList.add("switch")
+ functionList.add(FunctionToCall)
+ } else if ((event == "button")||(event == "button.pushed")||(event == "button.held")) {
+ objectList.add(obj)
+ eventList.add("button")
+ functionList.add(FunctionToCall)
+ } else if ((event == "acceleration")||(event == "acceleration.active")||(event == "acceleration.inactive")) {
+ objectList.add(obj)
+ eventList.add("acceleration")
+ functionList.add(FunctionToCall)
+ } else if ((event == "sleeping")||(event == "sleeping.sleeping")||(event == "sleeping.not sleeping")) {
+ objectList.add(obj)
+ eventList.add("sleeping")
+ functionList.add(FunctionToCall)
+ } else if ((event == "water")||(event == "water.dry")||(event == "water.wet")) {
+ objectList.add(obj)
+ eventList.add("water")
+ functionList.add(FunctionToCall)
+ } else {
+ objectList.add(obj)
+ eventList.add(event)
+ functionList.add(FunctionToCall)
+ }
}
////subscribe(obj, event, nameOfFunc)
-def subscribe(Object obj, String event, String nameOfFunction) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(nameOfFunction)
+def subscribe(Object obj, String event, String FunctionToCall) {
+ if ((event == "alarm.both")||(event == "alarm.siren")||(event == "alarm.strobe")||(event == "alarm.off")||(event == "alarm")) {
+ objectList.add(obj)
+ eventList.add("alarm")
+ functionList.add(FunctionToCall)
+ } else if ((event == "contact.open")||(event == "contact.closed")||(event == "contact")||(event == "tamper.tampered")) {
+ objectList.add(obj)
+ eventList.add("contact")
+ functionList.add(FunctionToCall)
+ } else if ((event == "doorState.open")||(event == "doorState.closed")||(event == "doorState")) {
+ objectList.add(obj)
+ eventList.add("doorState")
+ functionList.add(FunctionToCall)
+ } else if ((event == "mode")||(event == "mode.away")||(event == "mode.home")||(event == "mode.night")) {
+ objectList.add(obj)
+ eventList.add("Location")
+ functionList.add(FunctionToCall)
+ } else if ((event == "lock.locked")||(event == "lock.unlocked")||(event == "lock")) {
+ objectList.add(obj)
+ eventList.add("lock")
+ functionList.add(FunctionToCall)
+ } else if ((event == "motion.active")||(event == "motion.inactive")||(event == "motion")) {
+ objectList.add(obj)
+ eventList.add("motion")
+ functionList.add(FunctionToCall)
+ } else if ((event == "status")||(event == "status.playing")||(event == "status.stopped")||(event == "status.paused")) {
+ objectList.add(obj)
+ eventList.add("status")
+ functionList.add(FunctionToCall)
+ } else if ((event == "mute")||(event == "mute.muted")||(event == "mute.unmuted")) {
+ objectList.add(obj)
+ eventList.add("mute")
+ functionList.add(FunctionToCall)
+ } else if ((event == "presence")||(event == "presence.present")||(event == "presence.not present")) {
+ objectList.add(obj)
+ eventList.add("presence")
+ functionList.add(FunctionToCall)
+ } else if ((event == "smoke")||(event == "smoke.detected")||(event == "smoke.clear")||(event == "smoke.tested")) {
+ objectList.add(obj)
+ eventList.add("smoke")
+ functionList.add(FunctionToCall)
+ } else if ((event == "carbonMonoxide")||(event == "carbonMonoxide.detected")||(event == "carbonMonoxide.clear")||(event == "carbonMonoxide.tested")) {
+ objectList.add(obj)
+ eventList.add("carbonMonoxide")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatMode")||(event == "thermostatMode.cool")||(event == "thermostatMode.auto")||(event == "thermostatMode.emergencyHeat")||(event == "thermostatMode.heat")||(event == "thermostatMode.off")) {
+ objectList.add(obj)
+ eventList.add("thermostatMode")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatFanMode")||(event == "thermostatFanMode.auto")||(event == "thermostatFanMode.fanCirculate")||(event == "thermostatFanMode.circulate")||(event == "thermostatFanMode.fanOn")||(event == "thermostatFanMode.on")
+ ||(event == "fanMode")||(event == "fanMode.auto")||(event == "fanMode.fanCirculate")||(event == "fanMode.circulate")||(event == "fanMode.fanOn")||(event == "fanMode.on")) {
+ objectList.add(obj)
+ eventList.add("thermostatFanMode")
+ functionList.add(FunctionToCall)
+ } else if ((event == "thermostatOperatingState")||(event == "thermostatOperatingState.cooling")||(event == "thermostatOperatingState.fan only")||(event == "thermostatOperatingState.heating")||(event == "thermostatOperatingState.idle")
+ ||(event == "thermostatOperatingState.pending cool")||(event == "thermostatOperatingState.pending heat")||(event == "thermostatOperatingState.vent economizer")) {
+ objectList.add(obj)
+ eventList.add("thermostatOperatingState")
+ functionList.add(FunctionToCall)
+ } else if ((event == "switch")||(event == "switch.on")||(event == "switch.off")) {
+ objectList.add(obj)
+ eventList.add("switch")
+ functionList.add(FunctionToCall)
+ } else if ((event == "button")||(event == "button.pushed")||(event == "button.held")) {
+ objectList.add(obj)
+ eventList.add("button")
+ functionList.add(FunctionToCall)
+ } else if ((event == "acceleration")||(event == "acceleration.active")||(event == "acceleration.inactive")) {
+ objectList.add(obj)
+ eventList.add("acceleration")
+ functionList.add(FunctionToCall)
+ } else if ((event == "sleeping")||(event == "sleeping.sleeping")||(event == "sleeping.not sleeping")) {
+ objectList.add(obj)
+ eventList.add("sleeping")
+ functionList.add(FunctionToCall)
+ } else if ((event == "water")||(event == "water.dry")||(event == "water.wet")) {
+ objectList.add(obj)
+ eventList.add("water")
+ functionList.add(FunctionToCall)
+ } else {
+ objectList.add(obj)
+ eventList.add(event)
+ functionList.add(FunctionToCall)
+ }
}
////subscribe(obj, event, func, data)
def subscribe(Object obj, String event, Closure FunctionToCall, LinkedHashMap metaData) {
- objectList.add(obj)
- eventList.add(event)
- functionList.add(FunctionToCall)
+ subscribe(obj, event, FunctionToCall)
}