Please login or register.

Login with username, password and session length

Author Topic: Restartable macro?  (Read 4571 times)

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Restartable macro?
« on: April 28, 2006, 11:47:15 AM »

Anyone figured out a way to effectively restart a macro?
eg. How about a macro (or group of macros actting as one) that has a timed delay that would let you restart the set of commands ignoring the previous set. This way a triggering condition would restart the timed macro.
I had this idea it might be possible with a combination of elses, flags and chaining macros. I got lost in the logic trying to make it possible. Is this possible or am I just dreaming?
My latest idea is to toggle a flag and chain to another macro or 2.
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. :)

roger1818

  • Hero Member
  • *****
  • Helpful Post Rating: 28
  • Posts: 1072
  • Roger H.
Re: Restartable macro?
« Reply #1 on: April 28, 2006, 02:45:11 PM »

You can use flags to count the number of times the macro has been called and the number of times the macro has finished.  I did something similar to this to create a sleep timer for my old TV (run the macro once and the TV will turn off in 30 min, twice and it will turn off in an hour, three times and it will turn off in 2 hours and four times and it will cancel the timer).  I use two flags to create the 4 states.

There are limitations which make it not work perfectly, but it is good enough for my needs.
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: Restartable macro?
« Reply #2 on: May 14, 2006, 08:00:28 PM »

It is possible! I recall an old post when AHP was first released where a user made a macro that looped inorder to test for problems so you'll need to use the flags conditions . Problem is you can't stop a macro once it has been triggered. And if you get lost in the logic you could end up with a continually looping  set of macros.
Post exactly what it is your tring to do and perhaps some one with some spare time will figure it out! ;)
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Restartable macro?
« Reply #3 on: May 14, 2006, 08:33:55 PM »

First this is not a high priority for me but it could prove useful sometime down the line.
My idea was to have the net effect of an event happening after the last time a macro was started.
eg
B1 on
delay 10 min
B2 off
However, trigger again and have the time restart. I thought there might be away to use flags to effectively negate previously started macros but the last time I tried it on paper it failed after two levels of macros.
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. :)

roger1818

  • Hero Member
  • *****
  • Helpful Post Rating: 28
  • Posts: 1072
  • Roger H.
Re: Restartable macro?
« Reply #4 on: May 15, 2006, 03:14:34 PM »

One way to solve this would be to create the following macros.  I am using 4 flags to allow up to 15 unexpired triggers but you can adjust the number of flags to meet your needs.

Macros M1 ON
conditions: flag 0 cleared
B1 ON
set flag 0
delay 10 min
M1 OFF

conditions: flag 1 cleared and flag 0 set
B1 ON
set flag 1
clear flag 0
delay 10 min
M1 OFF

conditions: flag 2 cleared and flags 0 & 1 set
B1 ON
set flag 2
clear flags 0 & 1
delay 10 min
M1 OFF

conditions: flag 3 cleared and flags 0, 1 & 2 set
B1 ON
set flag 3
clear flags 0, 1 & 2
delay 10 min
M1 OFF

Macros M1 OFF
conditions: flags 0 set and flags 1, 2 & 3 cleared
B1 OFF
clear flag 0

conditions: flag 0 set
delay 1 second
clear flag 0

conditions: flag 1 set and flag 0 cleared
delay 1 second
clear flag 1
set flag 0

conditions: flag 2 set and flags 0 & 1 cleared
delay 1 second
clear flag 2
set flags 0 & 1

conditions: flag 3 set and flags 0, 1 & 2 cleared
delay 1 second
clear flag 3
set flags 0, 1 & 2


I have found that for some reason the 1 second delays are needed, otherwise multiple macros will be triggered with one command.

Let me know if you have any problems.
Logged

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Restartable macro?
« Reply #5 on: May 15, 2006, 08:07:59 PM »

I'd have to sit down and go through the logic but at 1st glance looks like it would work and "15 unexpired triggers" should be enough for almost any situation. I see how you could adjust it to another (2n - 1) value by adding or subtracting flags.

As I mentioned earlier, I don't have an immediate need for this. I tossed out the hypothetical idea in case I or someone else did in the future.

Thanks for working out the logic for us!
« Last Edit: May 16, 2006, 08:19:51 AM 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. :)
 

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