It's both easy and dangerous to build and start a loop. e.g. I use one as a panic that flashes the lights.
The most basic endless loop can be created as follows.
Create a Dummy module with the same address as your macro.
Macro M1 ON - Trigger on an M1 signal
<execute commands>
delay 10 min
M1 On
The above will continue to execute indefinitely and if triggered again each additional loop will continue till purged. I strongly recommend using flags, elses, and/or time conditions to give one an exit point.
Without a way to exit, the macro will go into an endless loop causing multiple possible problems including possibly having the CM15A lock up!This is a the looping macro I use to test check my X10 signal as well as switches and modules on my test jig before installing. It gives an example of how to program an exit for a macro.
Narrative:AHP 3.204 (should work on 3.206 as well)
This is an example on a looping macro using a flag to exit it. I use a similar one to flash the lights.
It requires a dummy lamp module set to
HC/UC P1. Macros can't directly call themselves! A macro can trigger a dummy module with the same HC/UC, however. This will result in a macro effectively calling itself.
I test my X10 components on P1 and leave them on that code till I need them. This way if I need to reach in the X10 box of stuff for something in a hurry, I know the component has been already tested.
The actual looping macro is "P1 On". Macros "P2 On" and "P2 Off" start and stop the loop respectively.
- Initiating "P2 On" sets flag 1 and starts the P1 loop.
- The P1 loop continues till it sees the flag 1 cleared.
- Initiating "P2 Off" clears flag 1 and stops the P1 loop.
P1 ON LOOP TEST -
Triggers with P1 On and Flag Status On exactly 1 Delay for 2 Seconds
(P1) Dummy - Loop test OFF ;X10 test commands
Delay for 2 Seconds ; " " "
(P1) Dummy - Loop test Brighten then dim to 25% ; " " "
Delay for 4 Seconds ; " " "
(P1) Dummy - Loop test Brighten then dim to 75% ; " " "
Delay for 4 Seconds ; " " "
(P1) Dummy - Loop test OFF ; " " "
Delay for 2 Seconds ; " " "
(P1) Dummy - Loop test ON ;Recalls itself via dummy module
P2 ON - START SIGNAL TEST -
Triggers with P2 On Set Flags [1]
(P1) Dummy - Loop test ON ;Starts P1 loop via dummy module
P2 OFF -STOP SIGNAL TEST -
Triggers with P2 Off Clear Flags [1] ;With flag 1 clear P1 loop will stop at the end of its current loop
Delay for 2 Seconds
Clear Flags [1] ;Redundant command. Most likely not needed. Added just for the "Murphy factor"
Delay for 30 Seconds
(P1) Dummy - Loop test OFF ;Just to make sure whatever I was testing is left off.
Another exit approach would be to place a timed condition in the looping macro.