How to say if a switch was pressed manually / physically

I have searched around but haven’t found an appropriate answer. I have a ZWave switch which is connected to a physical light switch to turn a light on or off. It can be operated manually (by pressing the switch) or via my sitemap - everything works fine. But how can I distinguish if it is pressed manually/on the switch and via app/gui/rule? I thought there must be a design pattern for that type of question - I would like to apply certain rules but these need to be handled differently whether it was pressed manually or handled automatically - is there a way to tell?

There is. See

This one is one of the trickier DPs so if you run into trouble please ask.

I do this a slightly different way using a virtual switch.

i.e. when virtual switch is changed, a rule changes the actual zwave switch item.

then another couple of rules can detect changes in the zwave switch item. If those changes put the zwave switch item into the same condition as the virtual switch then you know that the changes were in the UI (i.e. because the virtual switch changed first). But if those changes put the zwave switch item into a different state from the virtual switch then you know the changes originated at the zwave device.

1 Like