HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: Peter1977 on August 11, 2014, 05:40:27 PM

Title: Small Sample Script.
Post by: Peter1977 on August 11, 2014, 05:40:27 PM
Hello All!,

Can someone help me with a small simple code sample ? (c# or java)

I want a trigger when the current time is greater than a schedulerevent (eg. SolarAltitude.Day.Start).
And in the runcode i just want to turn on a zwave lamp.

I know this is easily done with the wizardscript but i want to do it in c# or javascript so i can learn from there on. (i had some programming experience long time ago and i want to refresh it :))

I also would like to thank the creators of this wonderful program!!!

Thanks in advance!
Title: Re: Small Sample Script.
Post by: mvdarend on August 11, 2014, 06:41:04 PM
Here's a simple example, there might be a more efficient way of doing it, but this works for me:

Trigger code (javascript):
Code: [Select]
var dayStart = hg.Scheduler.WithName("SolarAltitude.Day.Start");

if (dayStart.IsScheduling())
{
  hg.SetConditionTrue();
}

Title: Re: Small Sample Script.
Post by: Peter1977 on August 11, 2014, 08:08:37 PM
Thanks mvdarend!

I've tried your code and it works! I suppose i put it in the trigger section of the code ?

The only problem is that i get the following error code "Runtime.Error = "TC: hg is not defined""

Do you know what it means?
Title: Re: Small Sample Script.
Post by: mvdarend on August 12, 2014, 11:34:42 AM
The only problem is that i get the following error code "Runtime.Error = "TC: hg is not defined""

Do you know what it means?
I get that message quite often, I just ignore it and the script seems to work fine. Not sure if it's a bug or something I'm doing wrong.
Title: Re: Small Sample Script.
Post by: Peter1977 on August 12, 2014, 05:19:48 PM
thanks!!