Jump to content

How To Make A Program Toggle A Switch


DualBandAid

Recommended Posts

Hi there,

 

I've found in several instances I like to create an "alt" functionality in a SwitchLinc using a down-press when the light is already off. I'll give you one example. My baby's room. The light switch turns the light off (duh). But once it is off, I programmed it so that a down-click WHEN THE LIGHT SWITCH IS OFF will turn on or off the baby noise machine (that is connected to an ApplianceLinc). The alt functioning only works if the light-switch is off -- which is fine because that's the only time I ever need this "alt" function.

 

So here's how it works. I turn the light off. Then I off-click the light again - and the noise machine turns on. This is the program I use:

 

If
       Status  'MASTER - Fan Light' is Off
   And Control 'MASTER - Fan Light' is switched Off
   And Status  'BABY - White Noise' is Off

Then
       Set 'BABY - White Noise' On

Else
  - No Actions - (To add one, press 'Action')

 

Then if I want to turn the noise machine off, I use a SECOND program that looks like this:

 

If
       Status  'MASTER - Fan Light' is Off
   And Control 'MASTER - Fan Light' is switched Off
   And Status  'BABY - White Noise' is On

Then
       Set 'BABY - White Noise' Off

Else
  - No Actions - (To add one, press 'Action')

 

It works like a charm. The thing is, I would LOVE to able to do all this in one single program, but I can't seem to figure it out. Using the ELSE function doesn't seem like it would work. What would work maybe is a "then" function that "toggles" the switch...

 

Toggle 'BABY - White Noise'

 

...except there isn't any function like that. The problem here is, I have about a dozen of these alt functions in my house (and love them) but they require twice as many programs. I have program-bloat. And also, if I make a change, I have to make it twice. It's just one more thing...

 

Any ideas?

Link to comment

You should be able to do this with a single program and a variable.

Set up a variable like noise_machine_state and use the variable in place of the appliancelinc state in the if test. This will allow you to use the then and else clauses to turn on or off the machine,

 

If

and Noise_machine_state is 0

 

then

turn on noise machine

noise_machine_state = 1

 

else

turn off noise machine

noise_machine_state = 0

Link to comment
You should be able to do this with a single program and a variable.

Set up a variable like noise_machine_state and use the variable in place of the appliancelinc state in the if test. This will allow you to use the then and else clauses to turn on or off the machine,

 

If

and Noise_machine_state is 0

 

then

turn on noise machine

noise_machine_state = 1

 

else

turn off noise machine

noise_machine_state = 0

 

 

This wouldn't work for his program because the "other tests" would need to be:

 

Status 'MASTER - Fan Light' is Off

And Control 'MASTER - Fan Light' is switched Off

 

The first line "status master light is off" would be a trigger every time the light changed status which would result in the "else" clause running a whole lot of times you didn't want it.

 

Also, it would require that this program be the only way you turn the noise machine on/off. If you turned the noise machine on or off otherwise, the variable would be out of sync, and you would need another program to track the status of the noise machine. . . which defeats the whole purpose of trying to turn 2 programs into 1.

 

The real answer to this problem has been discussed at length in the past, and that would be for ISY to allow you to select which conditions may act as triggers. Like a check box after each line or something.

Link to comment

I'm hopeful that the next firmware update with expanded variable support will allow me to reduce my program count significantly while greatly improving the ISY's capabilities.

 

-Xathros

Link to comment

(I'm new to ISY programing so someone with more experience please correct me if I'm off base with this suggestion)

 

It won't reduce the number of programs but you could try a different split which may help make things more manageable. You could create a disabled dedicated toggle program:

 

If
      Status  'BABY - White Noise' is Off
Then
      Set 'BABY - White Noise' On
Else
      Set 'BABY - White Noise' Off

 

Then make a single enabled program that calls it to do what you want:

 

If
       Status  'MASTER - Fan Light' is Off
   And Control 'MASTER - Fan Light' is switched Off 
Then
       Run Program 'Toggle BABY - White Noise' (If)
Else
  - No Actions - (To add one, press 'Action')

 

That way you can hide away all your simple Toggle programs in a folder that you'll likely never need to touch and keep your single program with logic. Might even get to cut down on a few programs if you can reuse a Toggle program or two.

Link to comment

Thank you, everyone. And thank you apnar. But I will have to wait for either the baby itself to be asleep to get enough head space to see if that will help things. :)

 

EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop?

Link to comment

EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop?

 

I don't think so. With the toggle program being disabled it should only run if it's explicitly called. I am new at this though, so I'd test it out when the baby isn't sleeping :wink:

Link to comment
Thank you, everyone. And thank you apnar. But I will have to wait for either the baby itself to be asleep to get enough head space to see if that will help things. :)

 

EDIT: One follow-up question, apnar. Wouldn't I need to have a disable program command at the end the "then" and "else" sections of the baby toggle, or else it will loop?

 

No, you wouldn't. The program is always disabled (assuming you set it as disabled). Calling a program via "run if/then/else" does not re-enable it. The "enable" and "disable" only serves to stop the program from SELF triggering (or in other words, by a condition in the "if" clause causing the "if" to trigger). Any other program or a manual action on a user's part can still force run the if/then/else even while disabled.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...