MQTT Thing with commandTopic and stateTopic

I have my Things setup as follows below.
I’m wondering what the effect on the item when it has a commandTopic and stateTopic.
vs separating these as below. As this a momentary relay switch, I don’t know if when the relay goes on/off if this will follow. I’m seeing a short jump from ON/OFF back to ON before and after I hit the button.
This may be something to do with my TASMOTA setup but just seeing whats the best practice.

Thing topic garagedoors "Gararge Doors Tasmota" @ "Garage" {
         Type switch : GarageDoor1 "Garage Door1" [commandTopic="cmnd/tasmota_8AD88C/POWER1", on="ON", off="OFF" ]
         Type switch : GarageStateDoor1 "Garage state Door1" [stateTopic="tele/tasmota_8AD88C/SENSOR", transformationPattern="JSONPATH:$.Switch1" ]


Switch GarageDoor1 "Door1 East [MAP(]" <switch> (garage) {channel="mqtt:topic:mqttbroker:mos_garagedoors:GarageDoor2", autoupdate="false"}
Switch GarageStateDoor1 "Door1 East [MAP(]" <switch> (garage) {channel="mqtt:topic:mqttbroker:garagedoors:GarageStateDoor1" }

Where to send any commands received by the linked openHAB Item(s).
No effect on Item state, ever.

Messages arriving on this topic are used to update linked Item state.

These are essentially two unrelated operations.

What people sometimes overlook when working out the flow of command and state is the autoupdate effects

I think I was or am confused about the what happens to the state of the Switch when I press the sitemap button vs the response I get from StateTopic.
ie does the press of the switch do anything to to the items state?

Poking stuff on the UI issues commands to openHAB Items.
That doesn’t affect your Item state directly.
Unless you tell it otherwise, autoupdate feature will usually guess an outcome for a command, and go on to update Item state.
And the command may be processed by a binding channel,and onward to a device. The device may later report a new status, which would get fed back to your Item state.

Maybe you could tell us which switch behaviour surprises you, and show your events.log

Is the confusion here related to simulating a “pushbutton”? Push to open door, push to close door (and simulated button un-pushes itself)?
You seem to be on the right track, modelling the pushbutton and the door as separate Items in openHAB.
On the UI, you’re not interested in pushbutton state… You might show door Item state, with up/down switch or buttons. UI commands would go to the door Item, and you’d want re-routing to the pushbutton by rule or link to channel.
As you’d most likely want to massage the command, i.e. act on UP command only when door is “down”, and convert to pushbutton ON, a rule might be most convenient.

An MQTT channel gives you nearly complete separation between the inbound “update state” and outgoing “do command” actions, but bear in mind the mini-transform parameters like “on=1” are shared or bidrectional, and that’s likely to cause a problem here. Whether you intend “up” or “down” target state, you want the same “push” command.
You’d probably want to manage pushbutton and door with separate channels, for sanity.

I’m seeing some duplicate or additional events which I want to be sure its nothing to do with my config

2021-07-13 20:32:29.007 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'GarageDoor1' received command ON
2021-07-13 20:32:31.248 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'GarageDoor1' received command ON

2021-07-13 20:32:35.310 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageDoor1' changed from ON to OFF
2021-07-13 20:32:35.310 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageStateDoor1' changed from ON to OFF
2021-07-13 20:32:35.502 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageDoor1' changed from OFF to ON
2021-07-13 20:32:35.503 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageStateDoor1' changed from OFF to ON
2021-07-13 20:32:35.503 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageDoor1_Last_Opened' changed from 2021-07-13T20:32:26.780932+1000 to 2021-07-13T20:32:35.502807+1000
2021-07-13 20:32:35.710 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageDoor1' changed from ON to OFF
2021-07-13 20:32:35.710 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GarageStateDoor1' changed from ON to OFF

However I think some of these ghost messages might be coming from my sensor / tasmota device, but thats something I need to figure out why as well… but just need to clear a bit of this noise.


Okay, let us know when you want to explain anything about the setup. What is supposed to happen with the Tasmota relay? Is this a pushbutton thing, i.e. “push” for open and for close, resets itself? What is Tasmota SENSOR Switch1 representing exactly, the state of the relay or some door position sensor?

If you’re using Items as in your first post, note that GarageDoor1 is linked to some channel we haven’t seen yet, GarageDoor2.