HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: Ossi_Jr on April 20, 2015, 10:48:47 AM

Title: Wizard Scripting: Setting a globally available variable
Post by: Ossi_Jr on April 20, 2015, 10:48:47 AM
Hi,

I am thinking about some kind of absence mode. Where different nodes in my network behave differently based on the fact I am absent or not. Therefore I'd like to create a global variable which can be used in the triggering section (sth like isAbsent = false).
But I have to idea if there is a way to create such a variable to be available in every program?

Is it achievable? If not via scripting, is it possible to create such a variable with one of the language programming?

Cheers and thanks
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: Ossi_Jr on April 22, 2015, 11:38:34 AM
Am I really the first one thinking about such a requirement?
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: Peter1977 on April 22, 2015, 12:23:39 PM
I don't think its posible but i would love that feature.
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: bkenobi on April 22, 2015, 05:02:41 PM
You can access the value of a parameter from any program by properly referencing it.  There is no easy way to add such a global variable to the main HG code, but there is really no need for it either.
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: kevin1 on April 22, 2015, 05:40:08 PM

There is a PingMe.AtHome app/program in the Security group which would give you a good starting point of using an event/parameter:
Code: [Select]
//setup
  Program.Parameter("PingMe.AtHome").Value = "1";
//code
    if (pinging_buddies > 0 && Program.Parameter("PingMe.AtHome").Value != "1")
    {
        Program.RaiseEvent("PingMe.AtHome", "1", "Ping Me At Home");     

If I understand how this particular app works, you would need to have your router assign a fixed IP to your cellphone so the app could ping it reliably.  Also would require WiFi on cellphone to be on as  you arrived home.
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: bkenobi on April 23, 2015, 04:28:49 PM
Forgot about that script, but that would definitely get the OP ~95% of the way to where he wants to be.  It might require tweaking the script a little to do his task or just writing another script that uses the PingMeAtHome parameters.
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: jshan on May 06, 2015, 02:57:29 PM
Another option to have a variable that sticks around and is globally accessible is to write to a file, then read when needed.  May be useful, for example, if one wanted to remember if the alarm system was on or not across a reboot/power outage.
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: bkenobi on May 06, 2015, 08:40:35 PM
That would certainly work.  If you are writing a value that doesn't change much or need to be accessed quickly, that would work well.  If it's being written all the time and/or needs fast access time, that might not be the best option.  Good suggestion!
Title: Re: Wizard Scripting: Setting a globally available variable
Post by: dani on May 07, 2015, 12:04:41 AM
Global variable can be access by program. You can create therm by calling :

Setting.Parameter("VariableX").Value = "Any value" ;

It's can be called by any program. Only we cannot access from UI.