more G-Labs products

Author Topic: ON only from sunset to sunrise  (Read 969 times)

September 10, 2016, 12:39:42 AM
Read 969 times

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
I need to create one shenario (made with program) where I do something and turn on one linght only if dark (from sunset to sunrise)
which is the best way?
can I use the wizard script or I must write code?
can the schedule help me?

Thank you in advance
   MArco

September 10, 2016, 02:03:20 PM
Reply #1

mchias13

  • **
  • Information
  • Jr. Member
  • Posts: 45
For 1 light so it on the new scheduler page.

Instructions:. (hope easy to follow)
1) go to scheduler page
2) click add new event (bottom right of screen)
3) name event.  For a light I would do Lights.<description of light>.On
(The "Lights." will put it in the group for lights)
4) click on the clock icon on the end of your new event
5) in pull down menu select "custom script"
6) This is where your code could differ.
For a light to always turn on:
@Solartimes.Sunset > @Solartimes.Sunrise (this will turn a light back on even if someone turns it off)
For a light to turn on once
@Solartimes.Sunset
7) go to modules (I think that's the wording between code>xxx>script)
8) select your light
9) go to script and from pull down select "turn on"
10) repeat all steps for a new event to turn light off.

Hope this helps.  Gene has a good code example under developer docs of his website too.

September 10, 2016, 06:28:20 PM
Reply #2

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
Thank You mchias13 good tutorial...
I didn't know this system and I haven't find documentation on Gene's web site.
here do not talk http://genielabs.github.io/HomeGenie/scheduler.html there are other developer documentation on sheduler?

but unfortunatly my needs are differents.

I do not want the light turn on/off automatically, I need to run one program (shenario) by API or from other program that switch on the light ONLY IF is dark (from sunset to sunrise)

with program wizard I find the posibility with trigger code to make contiction on sunrise/sunset but what i must put in condiction? astronomy.sunrise lessthan WHAT??

   MArco


September 10, 2016, 09:04:32 PM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
in the "script" code of a scheduler item, you can use the command:

Code: [Select]
$$.program.run('name or id');

almost all hg helpers can be used. There's no docs at the moment but you can look here to get an idea of what can be used:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Automation/Scheduler/SchedulerScriptingEngine.cs#L44

so for example you could use the SerialPort helper with $$.serial or the NetHelper with $$.net and so on.