Author Topic: HOW TO: Turn on/off a light at random intervals.  (Read 1869 times)

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
HOW TO: Turn on/off a light at random intervals.
« on: April 21, 2010, 09:41:44 pm »
The following rule demonstrates how to toggle a light on/off randomly during a specified day/time range.  This is useful for example when you are on vacation.

The action list below assumes you have a ZWave device named "lighting", however you can use this same principle for other actions as well.

The following report was automatically created by the Rule Report toolbar button in the Rules window.

Quote
Rule Name: Toggle kitchen light randomly
Group Name:
Description: On Saturday and Sunday when it is dark outside, toggle the Kitchen lights on/off once every two to four hours.
Enabled: Yes
Log: No

Event:
  Device Name: Date & Time  (dates)
  Event Name: At Random Intervals

Whenever Filters:
  MaximumInterval: 04:00:00
  DaysOfWeek: S-----S
  MinimumInterval: 02:00:00

Action List:
1.  Run the following indented actions if a boolean indicating if it is dark outside is the same as  true .
2.     Run the following indented actions if the  Z-Wave (ViziaRF RZC0P)  light level for light # Kitchen Cans (9) is the same as  0 .
3.        Turn on  Z-Wave (ViziaRF RZC0P)  light # Kitchen Cans (9) .
4.     Otherwise run the following indented events.
5.        Turn off  Z-Wave (ViziaRF RZC0P)  light # Kitchen Cans (9) .
6.     End of conditional list of actions.
7.  End of conditional list of actions.

Auto-Generated Script:
if ( dates.IsDarkOutside == true )
{
   if ( lighting.LightLevels[9] == 0 )
   {
      lighting.TurnOnLight(9);
   }
   else
   {
      lighting.TurnOffLight(9);
   }
}
John Hughes
Codecore Technologies