Announcement

Collapse
No announcement yet.

Global Variables in Event Logic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Global Variables in Event Logic

    All,
    I'm aware that Global Variables are reset at reboot, I have created a script that will recreate my variables daily and on startup. My question is simply, is there a way to use the values of these variables in logic when creating events? Meaning, can i check if today is a Legal Holiday or a special day in my calendar based on a global variable that I set?


    Thanks

    #2
    Unfortunately not without buying the EasyTrigger plugin. IMHO they are not that useful when you think of what you need to do with them and you may as well just have a device contain that string/value. You could however have a recurring trigger that ran a script that checked the value of the variable instead.

    Comment


      #3
      Originally posted by mrhappy View Post
      IMHO they are not that useful . . . and you may as well just have a device contain that string/value.
      +1
      If you consider HS to be a programming environment, then the concept of a global variable gets muddy. It is so easy to create virtual devices to act as repositories of information, I find it very easy to treat them exactly like global variables.
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        Virtual Devices are persistent global variables. They do not need to be recreated at restart, retain their values over a restart and are easily viewed to see their current value. They can easily be used as triggers or conditions and can easily be set by events.

        To maintain order and reduce clutter I use specific locations for "scratchpad" virtual devices and I hide most of them.

        I really don't see a thing that a global variable offers that functions better than a virtual device. They are useful for plug-in authors, but are not nearly as useful as virtual devices for most users.
        HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

        Comment


          #5
          All,
          Thanks for your response. I installed the EasyTrigger plugin but did not see anything related to global variables. My use case is that I have a script that runs calendar based logic which I initialize at startup then again at midnight daily. The script sets flags that I would like to use in events. Some are as simple as what season is it? Some are more complex relating to working schedule.

          My original project was c# based but ultimately I wrote the scripts in VB.net and call the c# dll which does all the work. I have migrated to counters though they don't work well since they do not support anything other than numbers as values.

          Does anyone have a primer on how to programatically create these virtual devices? The documentation is quite poor.

          Thanks

          Comment


            #6
            Originally posted by flatbush97 View Post
            Does anyone have a primer on how to programatically create these virtual devices? The documentation is quite poor.
            It may not be necessary to create the devices programmatically unless there are an indeterminate number of them. I was thinking that you would simply change the value and/or string of a preconfigured device in each case.
            Mike____________________________________________________________ __________________
            HS3 Pro Edition 3.0.0.548, NUC i3

            HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

            Comment

            Working...
            X