Passing MQTT Message issues

I am trying to pass some sensor values from an arduino to MQTT within home assistant. The MQTT Broker is picking up the message, but no payload is attached. Here are a few screenshots, and willing to share more if it helps troubleshoot, but I'm relatively new to mqtt, so not sure what I'm missing.

As you can see, there is a temperature value being passed (the NR dashboard gauge reflects it accurately), but according to mqtt.fx there are no values coming through.

Maybe it's me, but I see payload in your screenshots ?
I am not familiair with mqtt.fx, should it show the message ? (for a more visualized method, try mqttexplorer)

I'm not sure I'm following either. The debug in your screen shot is labelled "MQTT debug"
but none of the messages in the debug panel come from that debug.

The easiest way to check that you are sending what you think you should be sending would be to add a debug to share the inputs to your MQTT-OUT node.

And then subscribe to the same topic with a MQTT-IN node and attach a debug to that. Give both debug nodes sensible names and you should easily see what you are sending.

It appears to be working via the debugs, but I'm not getting anything in HA

So it’s either a problem with HA or HA can’t cope with the format of the payload.

There’s a return character at the end of the string. You could try deleting the character so you send just a number and see if that works

I was wondering about that extra character as well...not sure how to delete it or even why it's there. The value is passing according to mqqt explorer:

Use a function node

The return character is whitespace at the end. Do you know where it is coming from? For example with the default serial node it can often be handled by editing the config node you can set what character to split messages on. This specific return character is the Carriage Return Line Feed, represented in a visual string like that arrow, and in text as \r\n.

Have you tried editing the input to split on \r\n rather than the default \n?
This would solve the problem from the start. In general, you can use msg.payload = msg.payload.trim() in a function node to strip of whitespace from the start and end of a string. As for stripping the last character, there are other methods, but as you appear to deal with whitespace specific issues here, use the road of least resistance :slight_smile:

I have been down a very similar road to yours.

I receive MQTT messages and wanted to parse their content.

I got bogged down with the formatting of the message. The solution for me was to put the message through a JSON node first.

I tried editing the input and it just moved the carriage return to before the payload and got the following error?

TypeError [ERR_INVALID_ARG_TYPE]: The "list[1]" argument must be one of type Array, Buffer, or Uint8Array. Received type string

Sure you get, show better WHAT you have edited and how it looks now, otherwise we cannot follow what you have done. An error message like that is not helping us to help you

1 Like

I used the msg.payload = msg.payload.trim() as listed above and now it has just the number without any additional characters. I'm still not getting a result in Home Assistant, so I'm thinking I may need something in the template value to get it readable, so I should probably take that question to the HA forum lol unless anyone here has any suggestions.

Have you tried the JSON node?

Put it just after the MQTT node and before you do any thing else.
But note: the payloads will be slightly modified.


Gets rid of the quotation marks, which I assume is changing it to a numeric value? Still no result in HA. Feel like I'm getting closer though?

I'm not at my desk so excuse the brevity.

Sorry, but what "HA" value?

Sorry, Home Assistant

Have you found out yet what format HA wants?
Have you checked the topic names are identical?

(Me again)

Looking at what you said in this post:

Honestly: try adding the JSON node between the MQTT receive node and what ever is next.

I am really sure it will fix the error.

I spent a lot of time messing about with something very much like this and Nick O'Leary mentioned the JSON node all fell into place from there on.
(For that problem)

As @ukmoose asked: What does HA want?