How Can I toggle virtual switch from UI to control a scene

I would like to control a scene from a virtual switch. The scene will toggle a device on or off.

If I create a scene in UI7 i select a trigger as the virtual switch but the option is to chose the switch as either on or off.

In the LUA for the scene I can implement a check status of the switch and then send a change status for the device.

But, only the trigger part of the toggle will work. I.e., if the trigger for the switch was set to on, then only the on part of the LUA will work.

How can I trigger the scene for both on or off of the virtual switch.

Many thanks

PLEG would be my choice for this but if you’re not interested in that route you can accomplish this with two scenes rather than one. One scene would look for the virtual to be set to ON and the other would look for the switch to be set to OFF. Then each of the two scenes would have the appropriate action.

I would have liked to have done this with one thing is that something that’s possible with lua luup?

You can add the same device twice to the trigger of a scene. Simply add the virtual switch and select On the first time through the Scene wizard, when you get to the end of the Scene wizard, go back to triggers and add the same device again only this time select Off, the scene will now trigger on On or Off of the virtual switch.

Your a star. I never thought of that. Thank you so much.