HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: bkenobi on December 26, 2014, 05:41:32 PM
-
My topic "Multiple 'When.ModuleParameterIsChanging' events?" was an incorrect assessment, but it did locate an issue within HG that I has been added to github (#80). That said, I can fix my order of operation issues by adding the parameters to the HG core code. I don't know if these properties would be ones you would want to include, but I think they could be valuable for others.
Attached is my ModuleParameter.cs variant for your consideration. I don't know how to use the pull/fork system in github, so I'm submitting my code here for you to consider.
-
I realized there were some poor naming choices and unneeded values being stored. I removed and LastOn, LastOff and renamed LastEvent to LastEventValue for consistency. I compiled the new code and it appears that my new exe works but the script compiler complains:
Line 96, Column 49 (Code):
Type `HomeGenie.Automation.Scripting.ModuleHelper' does not contain a definition for `LastEventDecimalValue' and no extension method `LastEventDecimalValue' of type `HomeGenie.Automation.Scripting.ModuleHelper' could be found. Are you missing an assembly reference?
/usr/local/bin/homegenie/HomeGenie.exe (Location of the symbol related to previous error)
I assume there must be another file that I should have replaced when I copied HomeGenie.exe over. I'll try to locate it and continue testing.
-
I believe adding these Last Event values is needed in the main code. I conducted a quick test to determine timing of when each script sees the event occur. In this example, I turned a switch off from the HG web interface which caused my Advanced Smart Lights code to turn off the Light.
homegenie log:
2014-12-31T10:19:06.8624780-08:00 HomeAutomation.X10 B6 - Status.Level 0
2014-12-31T10:19:08.3730990-08:00 HomeAutomation.X10 A6 - Status.Level 0
Activity log (records module activity):
20141231 10:19:06.8673380 ; Entry switch ; Status.Level ; 0
20141231 10:19:08.3766130 ; Entry Lights ; Status.Level ; 0
Advanced Smart Lights log:
20141231 10:19:07.3510100 ; 2-Entry switch ; Status.Level ; 0
20141231 10:19:08.3757570 ; 3.1-Entry Lights ; OFF
20141231 10:19:08.3827950 ; Entry Lights
20141231 10:19:08.4380060 ; 8.5-event=0 ; 20141231 10:19:06.8621750 ; LAST_EVENT=0 ; 20141231 10:13:01.3043760 ; double timer=TRUE
20141231 10:19:08.4422430 ; 12-Entry switch ; Consecutine OFF detected
Last Event:
20141231 10:19:08.4807700 ; Entry switch CURRENT_EVENT=0 ; 20141231 10:19:06.8621750 LAST_EVENT=0 ; 20141231 10:15:53.3142040 ; LAST_ON=20141231 10:09:05.8583090 ; LAST_OFF=20141231 10:15:53.3142040
The important thing to note is that the homegenie log which is generated by HG's core code indicates that the switch was turned off at 10:19:06.8624780. The Smart Lights code saw the switch turn off at 10:19:07.3510100 (~0.5 seconds delayed). The Last Event code saw the switch turn off at 10:19:08.4807700 (~1.6 seconds delayed). This means that if I want to have the code run in a reasonable time (not inserting a bunch of delay statements), I need the code to be internal I think.
When I try to run the HomeGenie.exe compiled from my modified code, but when I try to access the stored values, I get an error in my script.
-
All right,
I'll add these new fields to ModuleParameter.cs.
Cheers,
g.
-
Great, thanks Gene!
-
Hi bkenobi,
see my reply to https://github.com/genielabs/HomeGenie/issues/80
can you make some testing?
Cheers,
g.
-
Yes, I'll take a look today. Btw, I like the history array. That will actually help make another capability possible (disable motion control if it's too windy).