Openhab 3 MQTT LWT thing says device is Online but it is not. If I save the thing then it goes Offline

Hi,

I have 2 lights that I turn the power off to them through the day as they are not needed.
In openhab 3 when I go to the light thing it shows the light as online. The MQTT LWT for the light says it is offline.
Below is from openhab 3.

If I go into the thing and just hit save it goes offline (which it should be).

The MQTT shows the correct state of off line:
tele/lampjap1/LWT Offline
tele/lampjap2/LWT Offline

Below is my LWT set up for the thing.

Is there a way to force load the LWT? Like I said if I just save the thing then it goes offline (which is what it should be).
I am at a loss as why it doesn’t pick up the LWT.

I am also running openhab 2.5 and it is showing the correct LWT of Offline but I have set up the LWT as a separate channel and not in the advanced (show more) section of the thing.

Anyone else seeing this?

Thanks

Is the LWT message retained? If not then if OH doesn’t happen to be connected when the LWT message was published it won’t see the message.

I assume it is retained.

When I do this command: mosquitto_sub -h 192.168.0.164 -v -t “#”

all the tele and stat topics list up. It is a sonoff device by the way.

I am using an external MQTT broker.

I just looked on the openhab 3 settings for the MQTT and there are no settings there.

This are the settings for the MQTT server I am using.




Everything looks OK to me, but I am no expert. :slight_smile:

I tried to disable the MQTT broker I am using and then re-enable it to see if the devices go offline but they don’t. They only go offline if I press the save option for the thing.

P.S If I restart OH all the online/offline status are correct.

I don’t know why this is happening.

It’s the device that publishes the message that sets the retained flag. So check the configuration on the device to verify whether or not the message is published as retained. It sounds like it is but it’s good to verify rather than assume.

Download and use a MQTT client like MQTTExplorer or MQTT.fx so you can actually see the messages on the broker.

Don’t post screen shots when the code tab is available. Screen shots are impossible to read, impossible to search, and never provide the complete information. Click the code tab at the upper right and past that using code fences.

If you verify that:

  • the device is publishing the online/offline messages to that topic
  • the messages are exactly Online/Offline, matching case and everything
  • after verifying all of that the status of the Thing still isn’t working, file an issue on the binding.

Have you tried setting it up like this in OH3? Of so, does the Channel show everything correctly at all times too?

Yes I am also running 2.5 and yes I have separate LWT channels and they do work. I thought I would use the LWT that is built into the thing instead of having an extra channel but I may need to revisit that idea.

Thanks for idea though.

Hi,

The online offline works if I restart openhab.
I might have to set up separate channels for the LWT like I had in OH 2.5.

Thanks for the pointers on how to use the forum as well.

The mqtt online offline has been working fine since I deleted mqttbroker.config file:

sudo rm /var/lib/openhab/config/org/openhab/mqttbroker.config

I am using an external mqtt broker (mosquitto)

Strange but at least it is now working as it should.