Toggle action in PLEG?


I trying to get the S2 of a Fibaro dimmer module (configured to act as a scene controller using parameter 28) to toggle a virtual switch. I want Scene ID 26 (1 x click) to toggle the status of the virtual switch. If the switch is already on it should turn off and if the switch is off if should turn on.

However, I can’t seem to work out the Logic Action. The S2 input gives a LastSceneID 26 when clicked and the Condition is true, but when using the ToggleState under HaDevice1 as a Action nothing happens. I assume this is not the right way of toggle a device status?

Is it possible to use LUA instead? I tried this LUA code I found but it do not work either:

local dID = 1420
local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status",dID)
 if status == "1" then

Does the virtual switch support the following action?

luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “ToggleState”, {},  devNo)

…in which case, no coding needed!

I don’t know? ToggleState is one of the actions under HaDevice1 in the drop down menu (see screenshot) but this doesn’t work if chosen.

I obviously didn’t read your OP in full! Sorry

1 Like

You might be able to do this in AltUI oddly. I found it while trying to get my kitchen lights to turn on or off.


How did you do? IS PLEg behaving differently in AltUI?

No but the dimmers have a ToggleState command available when you crate a scene and select actions. This doesn’t appear to be accessible from the standard UI.

I thought this might help you get to your goal


Oh, in the standard scene create mode?I’ll check it out! Thanks for the tip!

Good luck!

I spend hours trying to make something work in PLEG!