Please login or register.

Login with username, password and session length

Author Topic: How to interpret user-submitted macros?  (Read 6577 times)

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
How to interpret user-submitted macros?
« on: February 05, 2011, 10:40:13 AM »

I'm having a stupid moment apparently.  I can't seem to understand how to take the conditions specified in any of the user defined macros forum and turn them into working AHP macros and timers.  B:(

Could someone help explain how to do this once (or point me to a thread where that's already been done) so I can properly interpret them in the future?

The one I'm currently trying to implement is a dusk-to-dawn motion sensor.

http://forums.x10.com/index.php?topic=21892.0

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: How to interpret user-submitted macros?
« Reply #1 on: February 07, 2011, 01:30:08 AM »

Not to push because I'm grateful for any help that I can get here, but I'm really just stuck on what P1 and P3 are.  I don't know for sure if P1 is the motion sensor and P3 is a phantom module (although that's my suspicion).  I just don't understand how to set this one up.  I'll keep playing around, but I just feel like an idiot at the moment.   B:(

troll334

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 159
Re: How to interpret user-submitted macros?
« Reply #2 on: February 07, 2011, 09:12:55 AM »

Looks to me like P1 is a macro triggered on the Motion Sensor's RF On
and
P3 is a phantom (that appears to call macro P1 under the right conditions).
Logged
AHP 3.236. CM15A. XTB-IIR. XTBM. Hauppauge 950Q.

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: How to interpret user-submitted macros?
« Reply #3 on: February 07, 2011, 10:38:25 AM »

How do you call a macro from a macro?  I built the same set of macros several times yesterday trying to figure out what I was missing, but I still don't see how to call a different macro.  The only thing I can think of is that P1 and P3 are both phantom modules and they are used to trigger the macros.  I guess I'll have to try that this evening unless anyone has a better suggestion.

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: How to interpret user-submitted macros?
« Reply #4 on: February 07, 2011, 10:41:07 AM »

I replied in the other thread. It looks like P1 and P3 are macros.
P1 is initially triggered by the motion sensor, but can also be triggered by the P3 Macro.
Therefore, BOTH will need a phantom module (an appliance module works best), which is how you call one macro from another (you tell it to turn the phantom module on, and that "P3 On" command triggers the macro, too).
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: How to interpret user-submitted macros?
« Reply #5 on: February 10, 2011, 12:17:53 PM »

I realized that I was making things far too complicated.  I wrote some pseudo-code the other day that would do exactly what I wanted rather than trying to implement a set of macros that do kinda what I want (that I don't fully understand).  Anyway, my setup uses 6 macros and 4 timers to turn on/off the lights between certain hours and utilize the motion sensor the way I wanted.  In case anyone wants to use this in the future, here's what I came up with:

Code: [Select]
Light control logic

flag 1
on = light should be on per timer
off = light should be off per timer
flag 2
on = motion detected
off = no motion detected

Pseudo-code:
if time = timer on time then
if light already on then
set flag 1 (light should be on per timer)
if light not on then
turn on light
set flag 1 (light should be on per timer)

if time = timer off time then
if no motion detected then
turn off light
clear flag 1 (light should be off per timer)
if motion detected then
clear flag 1 (ligth should be off per timer)

if motion detected then
if flag 1 set then (timer on)
set flag 2 (motion detected)
if flag 2 not set then (timer off)
set flag 2 (motion detected)
turn on light

if motion stopped then
if flag 1 set then (timer on)
clear flag 2 (no motion detected)
if flag 1 not set then (timer off)
clear flag 2 (no motion detected)
turn off light



AHP:
Trigger: timer on
Macro name: light on - timer
Condition: (optional: check if light is on to avoid sending extra commands)
Action:
set flag 1
turn light on

Trigger: timer off
Macro name: light off - timer
Condition: flag 2 off
Action:
turn light off
clear flag 1
Macro name: Clear light timer flag
Condition: flag 2 on
Action:
clear flag 1

Trigger: O1 on (motion detected)
Macro name: light on - motion
Condition: (optional: check if light is on to avoid sending extra commands)
Action:
set flag 2
turn light on

Trigger: O1 off (motion stopped and timed out)
Macro name: Clear light motion flag
Condition: flag 1 off
Action:
clear flag 2
turn light off
Macro name: light off - motion
Condition: flag 1 on
Action:
clear flag 2

NOTE: There is some optional code that checks for lights current state that I have not implemented.  As I see it, since the light modules I am using are not 2-way, AHP/CM15A might not know what state the lights are really in so trying to use that in a Smart Macro is of questionable usefulness.
 

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