Jump to content
C4 Forums | Control4

Achieving a three-way variable, better way to do this?


jbs

Recommended Posts

Would love any thoughts on how you might do this. I have a few items in my program which toggle a group of lights on and off. For example, our I have an "Exterior_Lights" Boolean variable which, when it changes to YES, turns several lights on, and when it changes to NO turns those same lights off.

What I'm trying to solve, though, is the possibility that sometimes I'll set it to ON but then the lights will get turned off manually, and the variable will remain at ON. Then, the next time an event happens that would trigger an ON (button press, door opening, etc) since the variable is not changing the action will not be taken.

I've come up with two ways I can think of to deal with this, but would love to know what's worked for you.

First, I can create a second variable, a numeric variable, and put the programming in there. So I'd still have the "Exterior Lights ON-OFF" Boolean but I'd also have an "Exterior Lights Action" numeric variable. Anywhere I'd want to trigger the action I'd first set the ON-OFF variable to whatever state I wanted, then I'd increment the numeric variable +1 and have the programming check the on-off variable. All the action would be programmed in the numeric variable.

The other option would be to use a single string variable and have the trigger change it to ON or OFF, and for the programming to say, when variable changes, if ON, do xyz, then set variable to "done". If Off, do abc, then set variable to "done". If "done", then stop.

That way, a trigger action will always change the variable to something, since it always leaves it in the DONE state.

Is there an easier/better/more reliable way to do this?

Thanks!

--Jason

Link to comment
Share on other sites


Yeah - you're on the right track with the numeric variable idea. Have each light in the group increment the variable when on and decrement when turned off. If you want to trigger the scene on you would trigger it if the variable is less than total # of switches...and I suppose it would always trigger off no mater what the number.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.