Identify command source

Hi all

I have a simple mqtt switch with tasmota fw
My question is when the power state changed is it possible to know if the change came from mqtt command or from button pushed

TIA

Oded

Only if Tasmota publishes something which allows you to tell. What is the JSON string that is published when using the switch, and what is the JSON string that is published when acting on an MQTT command?

When I use the switch it works direct without mqtt
I can change this behavior but then the switch send mqtt command to power like openhab do

The other way to approach this is to “remember” if you just sent a command from openHAB. One approach is to start a short timer when you send a command, if some update arrives from the device within the timer window you can make a guess it was because the command. If update arrives outside the time window, probably a remote pushbutton.

Good idea
Is there a built in way to know what was the last time switch on sitemap used?

Nope, you would have to make this yourself using rules triggered by command. You cannot tell if a command has come from the UI or from e.g. another rule, but maybe you don’t care about that.

openHAB persistence services and timestamping profiles deal in Item states, and so will not help you here.

This is covered in a design pattern. Design Pattern: Manual Trigger Detection