Please login or register.

Login with username, password and session length

Author Topic: Safe to install conditionals?  (Read 14015 times)

paul warshawsky

  • Sr. Member
  • ****
  • Helpful Post Rating: 5
  • Posts: 102
Safe to install conditionals?
« on: November 22, 2004, 04:51:16 PM »

I have a few macros that would benefit from
conditionals, but they aren't critical.  I
don't want to lose the functionality that I
currently have by installing the add-on.
I'd like to know if people had trouble
after installing the conditionals.

The conditionals I'm thinking about would
include dealing with problems like this one:

A switch triggers a macro that turns on
several lights and then turns them off 10
minutes later.  Currently, if you trigger
the switch again, just before the lights
were due to go off, they will STILL be
turned off at the scheduled time.  (They
will be turned of AGAIN 10 minutes later,
but of course they are already off.)  I was
thinking of adding a variable that is
incremented every time the switch is
triggered and decremented every time the 10
minute period has elapsed.  Only if the
variable reaches 1 (or 0) will the lights
actually turn off.

Will I be able to do this?

Thanks,

Paul
Logged

kevinw

  • Guest
Re: Safe to install conditionals?
« Reply #1 on: November 23, 2004, 03:15:55 PM »

Obviously I'm biased, but adding
conditional support to your system
shouldn't create trouble for you.

Regarding your counter solution:  The CM15
hardware supports 16 flag variables.  Being
flags and not counters your choice of
values is 0 or 1.

Using the SDK, you could implement a
variable timer system, but your computer
would need to be turned on.

You could count 10 minute periods using
flags, but you would require 1 flag per 10
minute period.  For instance:

if not flag1
set flag1
turn on,
delay 10 mins turn off if not flag 1
delay 10 mins turn off if not flag 2
delay 10 mins turn off if not flag 3
else if not flag2
set flag2
else if not flag3
set flag3
Logged

paul warshawsky

  • Sr. Member
  • ****
  • Helpful Post Rating: 5
  • Posts: 102
Re: Safe to install conditionals?
« Reply #2 on: November 23, 2004, 04:58:41 PM »

Ah.  Well if you only support flags, then
for now I don't think I'll take any
chances - I'll just wait a bit before
installing the add-on.  No offence
intended...

Paul
Logged

mike

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 17
Re: Safe to install conditionals?
« Reply #3 on: November 24, 2004, 03:12:40 AM »

"A switch triggers a macro that turns on
several lights and then turns them off 10
minutes later.  Currently, if you trigger
the switch again, just before the lights
were due to go off, they will STILL be
turned off at the scheduled time."

If you trigger a macro that is already
running, it restarts completely including
any delays. In your example, the light
won't turn off until 10 minutes after the
last time the switch is pressed.

This gets more complicated with conditional
macros since each "condition" (if/then or
else) behaves like a separate macro. If any
condition has a delay off sequence, the
delay and off will happen unless that the
macro is retriggered and that particular
condition is met again. You can't modify
that behavior by retriggering the macro and
having a different condition (eg else) met.
That only results in both sequences
running. Activehome's example doesn't seem
to take or counting the switch presses into
acount. But kudos to him for the great info
on calling macros from macros, the dusk to
dawn conditional bug, etc. Please keep it
coming!

I didn't see any new issues after
installing the conditional macros. They
have limitations but still allow some
pretty creative stuff that can't be done
without them. I wouldn't have bothered with
AHP if they weren't available or consider
an alternative unless it provided them
without a PC on all the time. I just find I
have to think in terms of state machines
and recursion ala Lisp and Snobol eons ago.

Mike
Logged

paul warshawsky

  • Sr. Member
  • ****
  • Helpful Post Rating: 5
  • Posts: 102
Re: Safe to install conditionals?
« Reply #4 on: November 24, 2004, 11:57:13 AM »

Mike:

So if I understand you correctly only one
thread of the same macro can execute at a
time?  If the same macro is re-triggered
(with the exception of different
conditionals) the first thread is abandoned?

That makes things easier.

Thanks,

Paul
Logged

mike

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 17
Re: Safe to install conditionals?
« Reply #5 on: November 24, 2004, 12:15:53 PM »

Paul,

No, based on what I've seen, it's just the
opposite, multiple "threads" of a "single"
conditional macro can execute in parallel.
They behave as independant macros once
triggered.

If you set up an if/then else sequence and
the if/then conditions are met when the
macro is triggered, the if/then will run to
completion regardless of whether the macro
is triggered again and the else conditions
are met. The if/then and else behave as
separate macros. "threads" never seem to
be "abandoned". They always seem to run to
completion. However, "threads" can be
restarted.

I agree that it would be a lot simpler is
starting the else "thread" caused the
previously started if/then "thread to be
abandoned but x10 doesn't appear to have
implemented conditional macros that way.
It's going to require folks to think of
implementing conditional macros in a non
intuitive way.

Mike
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Safe to install conditionals?
« Reply #6 on: November 24, 2004, 12:52:15 PM »

What would make even more sense to me would
be if they changed the way macros function
entirely. If they (at least
optionally) "linked" a macro to an on/off
pair (I know, this cuts the number of
possible macros in half, and makes it
annoying to use) so that pressing the "on"
button would start (or restart) the macro,
and pressing the "off" button would stop it
(conditionals and all). But taht is a lot to
ask, and kinda hard to implement.
I suppose one could "fake" it with
conditionals, where you assign a flag for
each macro, and the first step of the macro
turns the flag on, and each subsequent step
check to make sure the flag is still on, or
it exits. So, turning off the flag will stop
the macro at the next step.
Logged

gene

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 13
Re: Safe to install conditionals?
« Reply #7 on: November 24, 2004, 06:44:32 PM »

Noam,
Whats wrong with this? J8on starts a
macro,J8off macro turns off all the mods in
the 'on'macro unless you exclude them.
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Safe to install conditionals?
« Reply #8 on: November 25, 2004, 08:13:59 AM »

Gene -
Here's an example:
Your macro turn on 4 lights, at 5 minute
intervals.
After 10 minutes (2 lights are on) you press
the button to run the macro that turns off
all the lights. The two that are on will
turn off, but the other two will still get
turned on, as the first macro runs to
completion.
the ability to programmatically stop all
running macros, or a specific running macro
would be nice.
Logged
 

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