more G-Labs products

Author Topic: Another 'New' Scheduler question  (Read 873 times)

October 04, 2016, 10:52:40 AM
Read 873 times

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
I've finally moved house and have installed HG v525. Decided on a clean install as a lot needs to change, and I'd like to make more use of new features in HG.

One thing I'm hoping the new Scheduler can do is the following, for example:

07:00 - Porch light on, but only if Sunrise is after 07:00

Currently I'm firing a program at 07:00, in the program I'm checking to see if Sunrise time is after 07:00 or not, but I'm hoping that there is a better way to do this with only the scheduler.

Anyone have an idea?
« Last Edit: October 04, 2016, 11:22:34 AM by mvdarend »

October 04, 2016, 04:38:42 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
Yes, use a compound statement.  I don't know the syntax currently, but you will want to do a statement like:

scheduler.day AND 07:00

The new scheduler has lots of things for sunrise/sunset so there should be one for day and night (haven't looked).  If not, you could always easily add a program to update a scheduler item based on when sunrise/sunset occur to trip the day/night scheduler item.  I believe this is built in now though.

October 04, 2016, 06:37:42 PM
Reply #2

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Thanks Bkenobi, that pointed me in the right direction :)

Basically I ended up with something like this:
Code: [Select]
(0 7 * * *) % (@Sunrise > @Sunset)Now to test if it works

October 05, 2016, 11:38:37 AM
Reply #3

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
If I've understood correctly I should be able to 'stack' scheduler rules?

For example, if I create a new scheduler event 'MyCustom.Daytime' with the rule (@Sunrise > @Sunset)

Could I then use the newly created event in a new one? eg:

(0 7 * * *) % (@MyCustom.Daytime)


October 05, 2016, 05:08:28 PM
Reply #4

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I know the second part will work.  I'm not sure about the custom rule's syntax.  I am still using the old scheduler so haven't tried the new capabilities.  I'm excited about being able to easily have an offset (e.g., 15 minutes before sunrise) but not so much about possibly breaking a 100% functional setup.  I simply need to clone my current setup and update one of these days.

October 06, 2016, 07:21:58 AM
Reply #5

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
The above example seems to be working, I've done what I described above, but with SolarAltitude, here is an example:

New rule: Scheduler.Daytime
Code: [Select]
@SolarAltitude.Morning.Sunrise.End > @SolarAltitude.Evening.Sunset.Start
New rule: Scheduler.Nighttime
Code: [Select]
@SolarAltitude.Evening.Sunset.End > @SolarAltitude.Morning.Sunrise.Start
And for the front porch light, which should switch on an 07:00 but only before sunrise, I have the following rule:
Code: [Select]
(0 7 * * *) ; @Scheduler.Nighttime
This morning it worked perfectly, very happy :)

October 06, 2016, 07:28:15 AM
Reply #6

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
Not sure if this is a bug, but with my Philips Hue lights I have to set a different value for level, If I set it to the described values (between 0 and 1) the Hue light gets a value of 1%. I need to set the actual percentage.

So for a light intensity of 50% I need to set the level to 50 instead of 0.5, eg.

Code: [Select]
// level is a decimal value between 0 and 1 (eg. 0.5 = 50%)
level = 50;
// set the level
$$.boundModules.level = level;