more G-Labs products

Author Topic: Small Sample Script.  (Read 1850 times)

August 11, 2014, 05:40:27 PM
Read 1850 times

Peter1977

  • *
  • Information
  • Newbie
  • Posts: 24
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!

August 11, 2014, 06:41:04 PM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
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();
}


August 11, 2014, 08:08:37 PM
Reply #2

Peter1977

  • *
  • Information
  • Newbie
  • Posts: 24
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?

August 12, 2014, 11:34:42 AM
Reply #3

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
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.
« Last Edit: August 12, 2014, 05:50:48 PM by mvdarend »

August 12, 2014, 05:19:48 PM
Reply #4

Peter1977

  • *
  • Information
  • Newbie
  • Posts: 24