Author Topic: Basic rules  (Read 2075 times)

Aslamma

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Basic rules
« on: April 16, 2010, 10:41:51 pm »
I want to set up actions The motion sensor is tripped between 10am and 4pm on weekdays.

So my whenever is the motion sensor.  The action is a series of conditional statements for time and day 

- do the conditional statements need to be properly nested?  I seem to have a problem getting them all indented properly.
- what are the values I use when putting in time of day?  For example, is 4pm just 16?
- can I enable and disable this rule via execution of another rule?  This would essentially be an arm or disarm. 

 

mustangcoupe

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: Basic rules
« Reply #1 on: April 17, 2010, 08:17:01 am »
I can answer 2 of your three questions... and a work around for the 3rd :) if John says the answer is no

1-Yes they need to be nested properly and you can't move if - then statements because of nesting,so you need to insert them in the right place
2-yes 4 pm is 16.  it is the hour component of a 24 hr clock.
3-about arm or disarm, but you could use a global variable and contain a specific word and your 1st if could be if arm status= arm

Aslamma

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Basic rules
« Reply #2 on: April 17, 2010, 09:13:03 am »
OK, so something like this then?  I will give this a shot and see what happens.  I will need to add the "arm/disarm" variable though. 

The global variable idea is not bad, but does require some extra work.  Hoping there is just a simple way to set the enabled state of a rule via script?
« Last Edit: April 17, 2010, 09:17:50 am by Aslamma »

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Basic rules
« Reply #3 on: April 17, 2010, 10:12:04 am »
That looks good. There is an IsWeekend property on the date driver which you could use to combine your sat/sun logic.

I think MC's thought on the global variable is correct unless there is something else in your setup that you can check.

Also there is a toolbar icon in the rules (and devices) window that lets you generate a report for the current item which you can post here instead of taking screen shots.
John Hughes
Codecore Technologies

Aslamma

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: Basic rules
« Reply #4 on: April 17, 2010, 10:59:33 am »
A few more questions:

- How picky is is about setting the hour?  i.e. would either a text or numeric string work?  Reason I ask is that it would be easy to set it as text and not know the difference.

- Are global variable states remember on reboot?  In the following rule, I have a global variable that must be set to "Arm" to run.  What will happen in the event of a reboot?

- How can I prevent this rule from retriggering?  X10 likes to send multiple commands and in HomeSeer I would just set a "do not retrigger for X amount of time". 


Action List:
1.  Run the following indented actions if the current time's hour component
  is greater than  10 .
2.     Run the following indented actions if the current time's hour component
  is less than  20 .
3.        Run the following indented actions if today is a weekend
  is the same as  true .
4.           Run the following indented actions if a boolean value indicating if the variable named  Security_Auto  has been set
  is the same as  Arm .
5.              Run the following indented actions if change me  is the same as  change me .
6.                 Turn off all  X10 CM15A  units for house code  A  via PLC.
7.                 Turn on all  X10 CM15A  lights for house code  A  via PLC.
8.                 Turn off all  X10 CM15A  units for house code  A  via PLC.
9.              End of conditional list of actions.
10.           End of conditional list of actions.
11.        End of conditional list of actions.
12.     End of conditional list of actions.
13.  End of conditional list of actions.

Auto-Generated Script:
if ( dates.Hour > 10 )
{
   if ( dates.Hour < 20 )
   {
      if ( dates.IsWeekend == true )
      {
         if ( vars.IsDefined(@"Security_Auto") == @"Arm" )
         {
            lighting2.AllUnitsOffPlc(@"A");
            lighting2.AllLightsOnPlc(@"A");
            lighting2.AllUnitsOffPlc(@"A");
         }
      }
   }
}

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Basic rules
« Reply #5 on: April 17, 2010, 11:59:49 am »
It's best to set it to the appropriate datatype.  In this case it will work as a string as well because the system will detect the type difference and convert the string to a number. If you look at the script when using the string you should see the type casting... something like Number("10").

The global variable driver has a setting that allows you to choose if they should persist after a reboot.

There is currently no built-in anti-retrigger mechanism... please post a feature request.  However you could use a global variable to store the current date/time after line 8 and then do a manual date comparison... BUT it looks like the software does need better date comparison support.  I think right now you would have to calculate it manually which is certainly not ideal.
John Hughes
Codecore Technologies