more G-Labs products

Author Topic: Scheduled switching off... an hour long  (Read 1198 times)

January 22, 2015, 01:52:27 PM
Read 1198 times

DutchHans

  • **
  • Information
  • Jr. Member
  • Posts: 39
Hello,

I have the lights around my house switched on at sunset.. works perfect. I want to switch them off via Scheduled On/Off at 10 pm using * 22 * * * .
They are switched off but every 30 seconds after 10 pm I hear the switch click again (switching off). Is this a bug?

Regards, Hans WIllem

January 22, 2015, 03:02:02 PM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
For 10 PM it should be:

0 22 * * *

By putting an asterisk at the start you are making the CRON value valid for every minute.

January 22, 2015, 04:59:53 PM
Reply #2

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
The scheduled ON/OFF script is set up to run every 30 seconds.  The trigger you are giving it is for a specific minute (0 22 * * * = 10:00pm).  The code will execute the first time at the top of the minute and a second time at the bottom of the minute.  As a result, you will hear a relay type switch toggle 2x per CRON event.

You could modify the Scheduled ON/OFF script to look at whether the switch is ON/OFF at the time of the event.  If it is, then it won't trigger again.  BUT, if HG and the physical switch are out of sync then it won't trigger the switch again.  This modification would put HG back into the state it was a few months ago.  The change was for the reason I indicated in that HG doesn't see an update for some types of modules (X10 for certain) since they don't send a status out.

The other option is to modify the script to only run every 60 seconds.  This is perfectly acceptable and would eliminate the second trigger.  But, I would only recommend this option if you have a 100% reliable setup.  If you have missed commands at all, you may start to see the missed scheduled events where HG sends the command but due to reliability you don't see the resulting action.

My personal opinion...leave it as is so that you know everything will work as intended.  If you need to do something, modify Pause(30) to Pause(60) so that the code only runs once per minute.  Last resort (and only for reliable systems or ones where HG is the only means to control your hardware), change the code so it checks the module status prior to firing the CRON event command.