trouble triggering a task based on an output being on/off

rexwilson

Member
I want to be able to use one of my keypad function-keys to toggle a relay and various other things on and off.
Press it once and the stuff goes one, press it again later and the stuff goes off. Seemed pretty straight-forward.
I set up a task, and assigned that task to a function-key on the keypad.
Then I set up an output to keep track of the state.
Then I set up two rules...
 1.  Whenever task is activated
       And output is off
            then turn the stuff on, then "announce A"
             then turn output on
 
 2.  Whenever task is activated
        And output is on
             then turn the stuff off, "Announce B"
             then turn output off
 
When I press the button on the keypad, both rules fire, one after the other.
I hear the speaker say "A" then "B".
I suspect that the system is so fast that when rule 2 rolls around, it is still in a state of thinking that the task was just activated, and since at the end of rule 1 I turned on the output, this means that as soon as rule 2 fires up, it sees the output is on so proceeds to do its thing and turn everything off. This defeats the whole purpose of me having the two rules conditioned on the state of the output. I suppose I could rig up an elaborate delay counter in still another output to prevent rule 2 from firing right away, but that seems like an unfortunate bit of complexity to have to add.
Any other ideas???
 
 
You could try another way of writing these rules as follows:
 
Whenever F1 key Activates
  Then toggle Output nnn
 
Whenever Output nnn is Turned On
  Then turn stuff on
  Then Announce A
 
Whenever Output nnn is Turned Off
  Then turn stuff off
  Then announce B
 
Back
Top