How to distinguish between a switch change triggered by home assistant from an update initiated by the device it self?

I have a bunch of sonoff ZBMiniL2 in my lights, in a couple of rooms I also have some presence radars and/or PIR sensors to automatically turn the lights on or off when movement or presence is detected.

The problem I have is that my wife doesn’t like that when she goes from some rooms and turn manually the light off it turns on again for a couple of seconds before it turns off again (due the Debounce I have set up for the automation).

Just removing the automation is also not possible because in some places where no radar use is posible I NEED the Debounce, otherway the light will turn off por some seconds when someone is there.

So, what I want is to be able to distint who or what triggered the state change, so if the light state changes due hardware switch press I can wait a couple of seconds before starting to tracking for presence again.

I have done some search for this but not found anything, or maybe I am not searching for the correct thing.

Is this possible?

One approach would be to set an input_datetime to the current date when the sensor turns on the light. Then you can trigger on the light’s state changing and check if it changed shortly after the sensor changed it. That would indicate that it was changed by the switch, and not the sensor.
-David

I suppose this could work, I would need to set a helper for each switch. I was hopping that something could be configured on zigbee2mqtt side.