I'm sure it is just my lack of understanding of the more modern .NET stuff, but I've been spending some time updating my UpdateEvent Script and I'm not finding the pattern that I need to use in order to make everything happy.
Basically, I have 1 script file (maybe my first mistake?). That file under HS2 has 20+ functions and 10 or so subs, works without issue. Maybe my structure has always been wrong, but under HS2's lax script structure...everything seems AOK
The Functions are just helpers for performing things like isBefore or similar, where I can just ask the question and the math is taken care of / True/False returned. I use that in making decisions in my updateEvent.vb file.
The subs are representations of the rooms in my house. Used Subs as maintaining 1 script file per room was getting WAY too difficult to maintain, especially since they shared so much code (the updateEvent sub).
In each sub, you can then customize it using simple if, then, else...what I really like is that I can copy/paste logic rather simply and easily. I'm not against the normal "programming" that HS uses through their webpage, but as a low level (gate level...below ASM), it frustrates me when I want to make quick simple changes...which would be a copy/paste/edit. Again, this was under HS2.
By doing this, I tend to make the HS events VERY simple. Simply put, if I want the lights in my kitchen to go on when motion, but only after certain hours, I unequivocally call updateEvent.vb("kitchen","motion") at ANY time with a motion trigger.
Thus, the kitchen sub is called, and the trigger type is motion. Then, I can do whatever I want with logic relating to time, deviceStatus, etc. Of course this was a simple example for the sake of explaining the reason for continuing to use updateEvent. Realistically, I found adding/understanding/using the conditionals in events really cumbersome. I think in HS3 it is better, but I've already got 2000 lines of code relating to how we want the house to function...I'd like to re-use that instead of reinventing things (greater WAF when things port without issues!).
So, I played around for a while and THOUGHT I had everything figured out.
Turns out - no.
In HS2, the script would look like:
Sub updateEvent(ByVal par as object)
Sub kitchen(param as object)
.
.
.
within kitchen, after creating variables representing all the devices I wanted to work with, I had logic similar to this:
if(param = "pictureFrame") then
.
.
.
In HS3, I currently have:
Sub updateEvent(ByVal par as object)
Sub kitchen(ByVal param as String) <--I tried object, but this is the last thing I had before getting frustrated)
Which throws:
Any help is greatly appreciated...once I get this setup properly, where HS3 can call into this script, I gain 80+% of my HS3 ported over. I can't even create all my events until this is worked out, as my events are REALLY simple - just call into updateEvent with parameters (which might be where I am goofing up).
--Dan
Basically, I have 1 script file (maybe my first mistake?). That file under HS2 has 20+ functions and 10 or so subs, works without issue. Maybe my structure has always been wrong, but under HS2's lax script structure...everything seems AOK
The Functions are just helpers for performing things like isBefore or similar, where I can just ask the question and the math is taken care of / True/False returned. I use that in making decisions in my updateEvent.vb file.
The subs are representations of the rooms in my house. Used Subs as maintaining 1 script file per room was getting WAY too difficult to maintain, especially since they shared so much code (the updateEvent sub).
In each sub, you can then customize it using simple if, then, else...what I really like is that I can copy/paste logic rather simply and easily. I'm not against the normal "programming" that HS uses through their webpage, but as a low level (gate level...below ASM), it frustrates me when I want to make quick simple changes...which would be a copy/paste/edit. Again, this was under HS2.
By doing this, I tend to make the HS events VERY simple. Simply put, if I want the lights in my kitchen to go on when motion, but only after certain hours, I unequivocally call updateEvent.vb("kitchen","motion") at ANY time with a motion trigger.
Thus, the kitchen sub is called, and the trigger type is motion. Then, I can do whatever I want with logic relating to time, deviceStatus, etc. Of course this was a simple example for the sake of explaining the reason for continuing to use updateEvent. Realistically, I found adding/understanding/using the conditionals in events really cumbersome. I think in HS3 it is better, but I've already got 2000 lines of code relating to how we want the house to function...I'd like to re-use that instead of reinventing things (greater WAF when things port without issues!).
So, I played around for a while and THOUGHT I had everything figured out.
Turns out - no.
In HS2, the script would look like:
Sub updateEvent(ByVal par as object)
Sub kitchen(param as object)
.
.
.
within kitchen, after creating variables representing all the devices I wanted to work with, I had logic similar to this:
if(param = "pictureFrame") then
.
.
.
In HS3, I currently have:
Sub updateEvent(ByVal par as object)
Sub kitchen(ByVal param as String) <--I tried object, but this is the last thing I had before getting frustrated)
Which throws:
Code:
Jan-15 4:04:38 PM Error 3 Running script C:\Program Files (x86)\HomeSeer HS3\scripts\updateEvent.vb :Exception has been thrown by the target of an invocation.->Does entry point kitchen exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at A.c17b105f989efe61e5979e67bec1ef734.cffd66cb0782c50126727e3fa75582d7a() Jan-15 4:04:38 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/updateEvent.vb("kitchen","cabinet") Jan-15 4:04:38 PM Event Event Trigger "My Test Events Test12 Kitchen" Jan-15 4:04:38 PM Event Event My Test Events Test12 Kitchen triggered by the event page 'Run' button.
--Dan
Comment