Making a state switch in UI7 or PLEG

If i missed some genius thread in my forum searches, just point me to it, and i’ll delete this thread. :slight_smile:

I want to program my kitchen light switch to have multiple states, and to be able to switch to the next state by pressing the “Light on” again. Light Off should always turn lights off.


  1. All lights turn on
  2. Ceiling light turns off, leaving the table and bench lights on.
  3. Only dining table light is on
  4. Only bench lights is on

I imagine this can be done using PLEG, and having done some programming in C and VB i know that this is easily done if you have a variable that holds the current state.

LUA and PLEG is new to me, how would you go about it there?

There are guys that are way better at this than me, but if you arent doing it with PLEG I’d think it requires some virtual switches to keep track of where it is supposed to be in the cycle. If those that are better at this dont pipe up soon I’ll throw my hand at trying to figure it out with LUA… I still have not figured out PLEG

Most switches do NOT provide an ON event if you are already in the ON state.
Maybe a scene controller will work … but I do not have much (successful) experience with these.

I would have thought that it could be done in PLEG using the Count function if you used a Momentary Switch (Push Button)?

Each press of the button equates to the desired scene, don’t forget to add State 5 = All Off

Maybe I missed something in your request as RTS has a different opinion?

I was referring to a regular Z-Wave switch, you can command it On then Off.

But not ON, then ON, then On, then Off.

I see the problem, Richard. I’m using 433 light switches through rfxtrx, and i’m pretty sure i sent consecutive ON commands that was recieved by the rfxtrx. Question is however if this is relayed to UI7/PLEG if the switch is allready on. Mabye there is a way to register the switch as two momentary switches? (Physically its is that allready)

I will look in to this later. :slight_smile:

Richard is right, UI7 will not accept repeated ON commands.

I think this is something they should include - a way to redefine light switches to be two momentary switches instead of ON/OFF. The NEXA units are actually two momentary switches, and they register with two different messages, so it shouldn’t be too difficult to make a definition for it?

This will, in addition to making my state switch possible, open for any scene based control from these kind of switches.

For now i will make my state switch by having the scene turn the switch off each time, and have an IF that checks which lights are on.

Edit: That worked well, the only thing i’m missing is the “lights off” side…