From dc5d1b42adf216c20a0efa7b209c3bb97b84b69b Mon Sep 17 00:00:00 2001 From: rtrimana Date: Sun, 4 Aug 2019 18:35:57 -0700 Subject: [PATCH] Adding new events. --- ColorTemperature/ColorTemperatures.groovy | 2 +- Extractor/ExtractorScript.py | 54 +++++++++++++++++++ .../colorControlSwitchOffDefaultEvent.groovy | 2 + .../colorControlSwitchOnDefaultEvent.groovy | 2 + ...lorTemperatureSwitchOffDefaultEvent.groovy | 2 + .../colorTemperatureSwitchOffEvent.groovy | 2 + ...olorTemperatureSwitchOnDefaultEvent.groovy | 2 + .../colorTemperatureSwitchOnEvent.groovy | 2 + .../relaySwitchOffDefaultEvent.groovy | 2 + .../relaySwitchOnDefaultEvent.groovy | 2 + eventSimulator/switchLevelEvent.groovy | 2 +- .../switchLevelOffDefaultEvent.groovy | 2 + .../switchLevelOnDefaultEvent.groovy | 2 + eventSimulator/switchOffDefaultEvent.groovy | 2 + eventSimulator/switchOnDefaultEvent.groovy | 2 + 15 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 eventSimulator/colorControlSwitchOffDefaultEvent.groovy create mode 100644 eventSimulator/colorControlSwitchOnDefaultEvent.groovy create mode 100644 eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy create mode 100644 eventSimulator/colorTemperatureSwitchOffEvent.groovy create mode 100644 eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy create mode 100644 eventSimulator/colorTemperatureSwitchOnEvent.groovy create mode 100644 eventSimulator/relaySwitchOffDefaultEvent.groovy create mode 100644 eventSimulator/relaySwitchOnDefaultEvent.groovy create mode 100644 eventSimulator/switchLevelOffDefaultEvent.groovy create mode 100644 eventSimulator/switchLevelOnDefaultEvent.groovy create mode 100644 eventSimulator/switchOffDefaultEvent.groovy create mode 100644 eventSimulator/switchOnDefaultEvent.groovy diff --git a/ColorTemperature/ColorTemperatures.groovy b/ColorTemperature/ColorTemperatures.groovy index aea5279..77f0175 100644 --- a/ColorTemperature/ColorTemperatures.groovy +++ b/ColorTemperature/ColorTemperatures.groovy @@ -29,7 +29,7 @@ public class ColorTemperatures { 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 { diff --git a/Extractor/ExtractorScript.py b/Extractor/ExtractorScript.py index bf8471f..37c294d 100644 --- a/Extractor/ExtractorScript.py +++ b/Extractor/ExtractorScript.py @@ -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() diff --git a/eventSimulator/colorControlSwitchOffDefaultEvent.groovy b/eventSimulator/colorControlSwitchOffDefaultEvent.groovy new file mode 100644 index 0000000..0787970 --- /dev/null +++ b/eventSimulator/colorControlSwitchOffDefaultEvent.groovy @@ -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 index 0000000..9f2c849 --- /dev/null +++ b/eventSimulator/colorControlSwitchOnDefaultEvent.groovy @@ -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 index 0000000..b78ba5b --- /dev/null +++ b/eventSimulator/colorTemperatureSwitchOffDefaultEvent.groovy @@ -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 index 0000000..add53cb --- /dev/null +++ b/eventSimulator/colorTemperatureSwitchOffEvent.groovy @@ -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 index 0000000..0d2a0d6 --- /dev/null +++ b/eventSimulator/colorTemperatureSwitchOnDefaultEvent.groovy @@ -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 index 0000000..c64a841 --- /dev/null +++ b/eventSimulator/colorTemperatureSwitchOnEvent.groovy @@ -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 index 0000000..4b1f86e --- /dev/null +++ b/eventSimulator/relaySwitchOffDefaultEvent.groovy @@ -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 index 0000000..b8a63e2 --- /dev/null +++ b/eventSimulator/relaySwitchOnDefaultEvent.groovy @@ -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 diff --git a/eventSimulator/switchLevelEvent.groovy b/eventSimulator/switchLevelEvent.groovy index 1cd0c6c..177164a 100644 --- a/eventSimulator/switchLevelEvent.groovy +++ b/eventSimulator/switchLevelEvent.groovy @@ -1,2 +1,2 @@ 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 index 0000000..1a7d43c --- /dev/null +++ b/eventSimulator/switchLevelOffDefaultEvent.groovy @@ -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 index 0000000..bd44730 --- /dev/null +++ b/eventSimulator/switchLevelOnDefaultEvent.groovy @@ -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 index 0000000..d10deb1 --- /dev/null +++ b/eventSimulator/switchOffDefaultEvent.groovy @@ -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 index 0000000..a25c74f --- /dev/null +++ b/eventSimulator/switchOnDefaultEvent.groovy @@ -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 -- 2.34.1