Please login or register.

Login with username, password and session length

Author Topic: New to Macros, Old to Programming  (Read 8405 times)

X10 Ken

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 30
New to Macros, Old to Programming
« on: February 08, 2009, 11:35:43 PM »

I just got Active Home this week, but have a lot of programming experience.

I need a macro.  If I wrote it in a programming language, it would look like this.

Turn on R-7
Delay 2 Hours
IF Flag #2 is ON
   Turn Flag #2 OFF
ELSE
   Turn off R-7
ENDIF

How is this done in Smart Macros?

Any help appreciated.

Ken
===
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: New to Macros, Old to Programming
« Reply #1 on: February 09, 2009, 08:20:16 AM »

you need 2 macros
if R7 is the trigger then
trigger is R7 ON
if flag 2 is on
delay 2 hours
clear flag 2
Second macro (automaticaly becomes an else)
trigger is R7 on
if flag 2 off
delay 2hours (if you wish this delay)
turn off R7

Hope I under stood what your trying to do?
 >!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

X10 Ken

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 30
Re: New to Macros, Old to Programming
« Reply #2 on: February 09, 2009, 11:14:03 AM »

you need 2 macros
...
Hope I under stood what your trying to do?

The trigger is "DUSK" and I need to check the flag after the 2 hour delay.  I think I can do this with 3 macros, but I would like to know if this is the best/easiest way of doing it.

Macro #1 Triggered by DUSK
Turn on R7
Delay 2 Hours
Do Macro #2
Delay 1 Second
Do Macro #3

Macro #2
IF Flag #2 is OFF, Turn off R7

Macro #3
IF Flag #2 is ON, Turn off Flag #2

How does this look?

Ken
===
Logged

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: New to Macros, Old to Programming
« Reply #3 on: February 09, 2009, 12:13:02 PM »

...Hope I under stood what your trying to do?
While I believe I'm able to follow what you're saying, it was a bit confusing to me at first.

The trigger is "DUSK" and I need to check the flag after the 2 hour delay.  I think I can do this with 3 macros, but I would like to know if this is the best/easiest way of doing it.

Macro #1 Triggered by DUSK
Turn on R7
Delay 2 Hours
Do Macro #2
Delay 1 Second
Do Macro #3

Macro #2
IF Flag #2 is OFF, Turn off R7

Macro #3
IF Flag #2 is ON, Turn off Flag #2

How does this look?
Well macros 2 & 3 could be combined as one if/else combo.

Is your DUSK trigger from a timer or a sensor? What and where is is flag 2 ever set? While I think I follow the logic  of what you're trying to do, I'm not clear yet what  you're trying to do.

Sometimes I think a programming background is a handicap to programing in AHP becuase AHP seems to have it's own set of logic rules. e.g. One known bug is that a delay at the beginning of a macro negates the if/else logic.  In addition, one must program dummy modules in order for one macro to "call" another macro. I don't think the X10 programmers ever planned to be able to do it. I believe "macro calling" was a user discovery. Also all decisions must be made before a macro starts.  i.e. No mid macro jumps or conditions. Once a macro starts, there is no conditional way to stop it.

Your best help in understanding the AHP "programming language" may be to look at some of the macro examples on the forum.

The User-Designed Working Macros section might be a good place to start.

« Last Edit: February 09, 2009, 12:43:36 PM by steven r »
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: New to Macros, Old to Programming
« Reply #4 on: February 09, 2009, 01:01:50 PM »

What steven r said! ;)
In order to have a macro trigger a macro those macros must have a tigger (phantom module) say P1.
Set P1 up as a 2 pin appliance module. Its only job is to active the second (if) macro.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

X10 Ken

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 30
Re: New to Macros, Old to Programming
« Reply #5 on: February 10, 2009, 11:42:58 PM »

Is your DUSK trigger from a timer or a sensor? What and where is is flag 2 ever set? While I think I follow the logic  of what you're trying to do, I'm not clear yet what  you're trying to do.

DUSK is a timer.

What I'm doing is turning on an outside light at dusk for 2 hours.  However, sometimes I don't want want it to turn off after 2 hours.  To do this I put in a command on a wireless pad that turns on a phantom unit, which triggers a macro that sets flag number 2.  So at the end of the two hours the light is either turned off or stays on depending on the setting of flag #2.

Thanks to your help, I think what I have now is working.  This is what I have:

Macro #1      (Triggered by DUSK timer)
Turn on K2
Delay 2 hours
Turn on P2    (Phantom)
Delay 1 second
Turn off P2   (Phantom)
Clear Flag #2

Macro #2   (Triggered by P2 on)
Conditional on Flag #2 being off
Turn off K2

As I said, I think this works, but it hasn't been fully tested.

Sometimes I think a programming background is a handicap to programing in AHP

I have found that to be true, but I'm slowly getting the hang of this.
I've been doing this less than a week and I have 15 Macros, 6 Timers, 2 Phantom modules, and 3 Flags.
It was a bit frustrating at first, but now it's getting to be fun.  My DS10A now sounds the chime if my garage door is left open more than an hour (and every hour after that).  I think I'll swap the chime for a wave file in my next experiment.

Ken
===
Logged
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.