[Solved] MQTT2 and Expire Fails

The latest Openhab ver 2.5.10 broke my MQTT V1.1 setup so I decided to start the migration to MQTT V2.5. I created a test install to ensure I fully understand the setup before committing to my working setup. I ran into a problem and would appreciate some help.

Problem: Built a single switch item for a tasmota switch, controlled by MQTT. The openhab switch works properly via sitemap to turn on/off the tasmota switch. Manually switching the tasmota on/off does not update openhab. I added an EXPIRE but it only turns off the openhab switch and does not send an OFF via MQTT. What am I doing wrong?

I did find this same issue with MQTT1.1 but the solution does not fit V2.5.

Environment: Ubuntu 18, server MQTT, Openhab 2.5.10-1 (running stable)
I setup the MQTT system broker connection via PaperUI (Test-openhab) and it’s online.

Bridge mqtt:systemBroker:Test-openhab
{
	Thing topic switches "Switches" {
		Channels:
			Type switch : courtyard "courtyard"
				[ stateTopic="tasmota/courtyard/stat/POWER",
				  commandTopic="tasmota/courtyard/cmnd/POWER",
				  postCommand=true
				]
}

Item:
	Switch shelly_courtyard  <switch>
		{ channel="mqtt:topic:Test-openhab:switches:courtyard", 
		  expire="5s,state=OFF", 
		  autoupdate="false" }

  {
	Thing topic switches "Switches"  [ availabilityTopic="tasmota/courtyard/tele/LWT", payloadAvailable="Online", payloadNotAvailable="Offline"]  {
		Channels:
			Type switch : courtyard "courtyard"
				[ stateTopic="tasmota/courtyard/stat/POWER",
				  commandTopic="tasmota/courtyard/cmnd/POWER",
				  postCommand=true , on="ON", off="OFF"
				]
}


expire=“5s,state=OFF”,

Read the expire binding docs. If you would like to send a command for the binding to deal with, instead of a state update, you only have to tell it so.

Thanks so much for the quick responses.
It’s working now. Here’s the resulting code:

Bridge mqtt:systemBroker:Test-openhab
{
   Thing topic switches "Switches"
   {
		Type switch : courtyard "courtyard"
			[ stateTopic="tasmota/courtyard/stat/POWER",
			  commandTopic="tasmota/courtyard/cmnd/POWER",
			  postCommand="true" , on="ON", off="OFF"
			]
	}
}

ITEM:
Switch courtyard  <switch>  { channel="mqtt:topic:Test-openhab:switches:courtyard" , expire="5s,command=OFF" }
1 Like