Physical button vs. UI Button

On something like a light switch, is there a way to distinguish if someone hit the physical button on the switch vs. the “button” on the UI?

Unless your switch supports Instant Status … Vera will not know you changed the switch for a few minutes.

In general there is really NO way to tell the difference between you setting the physical switch and you remotely setting the switch via Vera.

More often, in Home Automation, you want to detect whether the switch was change manually (remotely or directly) or was changed by the Automation logic. You might want to allow manual changes to override the Automation logic for a period of time.

If you have Instant status, and you use the PLEG plugin … you can use a PLEG Sequence Expression to compare the TimeStamp of last switch setting, with your automation logic that would have changed the switch.
If the switch change happened shortly AFTER (within a few seconds) of the automation logic, you can deduce that it was changed via the Automation Logic. If the change has NOT followed a recent Automation request you can deduce that it was a manual change.

My solution to this was have the UI control a virtual switch which then turns the light on (via pleg).

Using what Richard has stated above you then have 3 outcomes when it’s turned on instead of 2.

If the light switched on before the auto logic and before the virtual switch it was manual.

If it switched on before the auto logic but not before the virtual it was the ui.

If it was switched on after the auto logic it was auto.

I use this for my bathroom light.
The light switches on via motion and stays on for 20 mins.
If you are in the bath often it will expire and the sensor hasn’t seen you move again.

If you are having a bath there is a bath mode on the UI but also switching on the light manually before going in the room ensures the light will stay on for a minimum of an hour.

I have dimmers in my bathroom.

In automation I set the level at things like 31% 51% 91%
Easy to test in logic
(Level % 10) == 1

Then if someone change the Dim level it will no longer have a 1 in the value.