Elk Rule: How to toggle a task

iostream212

Active Member
I have a low voltage light connected to one of my Elks outputs. I have a task called 'Light On' and 'Light Off'.
I am trying to combine the tasks so it is called 'Light On/Off' but my rules aren't working as expected. I just want the task to toggle
the output between on and off.

Code:
WHENEVER Light On/Off IS ACTIVATED
THEN TURN Light (Out 16) ON
THEN TURN Output 100 ON

Code:
WHENEVER Light On/Off IS ACTIVATED
AND Output 100 STATE IS ON
THEN TURN Light (Out 16) OFF
THEN TURN Output 100 OFF

All this does nothing. If the light is already on this task will turn it off.
 
I have a low voltage light connected to one of my Elks outputs. I have a task called 'Light On' and 'Light Off'.
I am trying to combine the tasks so it is called 'Light On/Off' but my rules aren't working as expected. I just want the task to toggle
the output between on and off.

Code:
WHENEVER Light On/Off IS ACTIVATED
THEN TURN Light (Out 16) ON
THEN TURN Output 100 ON

Code:
WHENEVER Light On/Off IS ACTIVATED
AND Output 100 STATE IS ON
THEN TURN Light (Out 16) OFF
THEN TURN Output 100 OFF

All this does nothing. If the light is already on this task will turn it off.

Try this:
Code:
WHENEVER Light On/Off IS ACTIVATED
AND Light (Out16) IS ON
THEN TURN Light (Out16) OFF

WHENEVER Light On/Off IS ACTIVATED
AND Light (Out16) IS OFF
THEN TURN Light (Out16) ON
 
I have a low voltage light connected to one of my Elks outputs. I have a task called 'Light On' and 'Light Off'.
I am trying to combine the tasks so it is called 'Light On/Off' but my rules aren't working as expected. I just want the task to toggle
the output between on and off.

Code:
WHENEVER Light On/Off IS ACTIVATED
THEN TURN Light (Out 16) ON
THEN TURN Output 100 ON

Code:
WHENEVER Light On/Off IS ACTIVATED
AND Output 100 STATE IS ON
THEN TURN Light (Out 16) OFF
THEN TURN Output 100 OFF

All this does nothing. If the light is already on this task will turn it off.

Sandpiper has a rule that should work, but what if you did this for the 1st rule:
WHENEVER Light On/Off IS ACTIVATED
AND Output 100 STATE IS OFF
THEN TURN Light (Out 16) ON
THEN TURN Output 100 ON

It should work also, right? I've only had my system for a couple weeks so I'm still learning all this ;)
 
Unless I am missing something obvious, I would just use the toggle function:

WHENEVER Light On/Off IS ACTIVATED
THEN TOGGLE Light (Out 16)


If you don't HAVE to use a task, then why not provide direct control of the output itself, most touch screen interfaces supporting the M1 will let you do this. The less rules, the better!
 
Back
Top