MQTT message not seeming to work

I have a couple of Tasmota devices connected.

Looking, the LWT message is retained. So I would think that when the machine is powered up the message is received and should be affected.

Sorry it is a bit messed up in layout, but this is the code:

[{"id":"3f35b888.962a","type":"mqtt in","z":"26262ba1.62dcbc","name":"Bulb-1 *","topic":"BULB-1/#","qos":"2","datatype":"auto","broker":"378c0403.8cda04","x":2480,"y":300,"wires":[["49320631.8fafc8","3c073047.1c12"]],"info":"This needs editing for different BULBS"},{"id":"3c073047.1c12","type":"switch","z":"26262ba1.62dcbc","name":"TOPICS *","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"BULB-1/cmnd/power1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":2660,"y":300,"wires":[["c0671188.49e67","f0e5a33c.047358"],["ff9438db.05a24","4af31854.bb2928"]],"outputLabels":["State","LWT"],"info":"This needs editing for different BULBS"},{"id":"ff9438db.05a24","type":"switch","z":"26262ba1.62dcbc","name":"LWT","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Online","vt":"str"},{"t":"eq","v":"Offline","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2480,"y":390,"wires":[["c1e2fde4.9eac38","650e33e.943974c"],["6f2a3190.8deba8"]]},{"id":"6f2a3190.8deba8","type":"function","z":"26262ba1.62dcbc","name":"BAN","func":"msg = {icon: '<font color = \"red\"><i class=\"fa fa-ban fa-3x\"></i></font>'};\nreturn msg;","outputs":1,"noerr":0,"x":2650,"y":420,"wires":[["ac1d9aac.bbcae"]]},{"id":"ac1d9aac.bbcae","type":"change","z":"26262ba1.62dcbc","name":"Disable","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":2850,"y":420,"wires":[["c8ea1741.fbff8"]]},{"id":"c8ea1741.fbff8","type":"ui_button","z":"26262ba1.62dcbc","name":"BULB#1","group":"7893c6c4.30ede","order":2,"width":"1","height":"2","passthru":false,"label":"{{msg.icon}}","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"X","payloadType":"str","topic":"","x":3060,"y":380,"wires":[["b31baea6.87a2f"]]},{"id":"378c0403.8cda04","type":"mqtt-broker","z":"","name":"MQTT HOST","broker":"","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"7893c6c4.30ede","type":"ui_group","z":"","name":"BULB-1","tab":"aa487daa.33c1c","order":4,"disp":true,"width":"3","collapse":false},{"id":"aa487daa.33c1c","type":"ui_tab","z":"","name":"Real_World_Control","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

The idea is that if a LWT message is received with Offline it puts a fa-ban icon on the button and disables it.

But the button is active and has the wrong icon.

This is a picture from MQTT Explorer showing the message is retained:

The BAUHN-1 is unplugged and is showing the right icon/s.

The bulb is also unplugged and showing the wrong icon.

(Where's the elephant?)

Which machine, node red or tasmota?
Either way start by putting a debug node on the mqtt in node to see where the problem is. If it is node red startup that is the problem then do a full deploy to initiate the problem.

I think you got the LWT idea wrong. The LWT is a „hidden“ (I don‘t think that mqtt explorer shows this) value of a topic which is submitted during connect. This value will replace the actual value as soon as the device loose the connection unexpected without a proper disconnect.
I do not know tasmota but in esp easy you can define a LWT and value in the mqtt protocol section. In case of the homie convention it should be set to:
homie/device/$state = „lost“
The device sending a „ready“ to this topic and when it does loose connection the broker will issue the LWT containing „lost“.
(Before deepsleep instead the device will send „sleeping“ and disconnect graceful so LWT don’t kick in)
So perhaps first check if this mechanism works.

My apologies.

The computer.

The tasmota stuff is plugged in (or not) doing its stuff.

I power on the machine (this) and load NR. Or more so the browser and load the page/s.

The bulb is powered down. The LWT messages is Offline - as shown in MQTT explorer.
And it is retained.

The computer power up and gets the most up to date MQTT messages.
Therefore I would expect the Offline message to be received and the icons changed to the ban ones as shown on the left of the screen.

I do have debug nodes on the MQTT in nodes. I didn't include them in the export but shall turn them on and see if I get anything next time.


Just what I am seeing: MQTT explorer showing me the messages (after booting) and the web page (edit screen of NR) (sorry) dashboard showing me the wrong icons.


you say LWT is retained... but how have you configured the broker ? unless you configure it to retain things to disk it will be retained in memory and so lost when you reboot (assuming it's the device that is being rebooted).

Oh. Interesting.

This is what I understand and what is:
The broker is on another machine.
The broker can retain messages if desired.

I power up the this machine and NR starts.
I load my browser and look at the page. It is not showing the correct icon for the device.

Loading MQTT explorer it shows the message exists and is retained.

So when NR starts: shouldn't it get all the retained messages?
(and so have the correct icon showing)

Sorry I wasn't clearer. Got a few train wrecks happening.

On a new tab, can you add an MQTT in node and subscribe it to the LWT topic and feed it to a debug node with status enabled

Deploy the flow

Does the debug node pick up the value of the LWT?

Stop Node-RED and restart it again

Does the debug node pick up the value of the LWT?



If I do the MQTT node listening to BULB-2/# it doesn't show much. (anything)

I do this because that is how it is in the flow.

But if I change the MQTT node to BULB-2/tele/# I get the LWT messge.



I am doing downstream parsing of the message to reduce the number of MQTT nodes.

But that seems flawed.

I'll try it by adding extra MQTT nodes with longer paths in their topic field.

I'll get back to you in some days when The machine has been cycled a few times.

If that is true then there is something very wrong somewhere. BULB-2/# should show you all the same subscriptions as BULB-2/tele/# and more. Are you sure you have specified the right broker?

Yeah, well..... Initial tests are showing that is true.

BULB-2/# gets nothing if I deploy.

But if I make it BULB-2/tele/LWT and deploy: I get the LWT message.

Testing continues.

What happens if you then change it back to BULB-2/#? If it then shows the problem may be that you did not do a full deploy. If you don't do a full deploy you are not guaranteed to get retained messages as the node thinks it has sent them already. Always do a full deploy when doing this sort of test.

Typically for me things are now working after my reporting the problem.

How ever, I shall continue to monitor how things work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.