Filter incoming MQTT messages with same topic

Hi, I am trying to filter incoming MQTT messages that all have the same topic, however different payload objects.

I have a rtl_433 that i am using to pick up the signal from my outdoor weather station. I then wish to take this data and display it.

The problem that i am having is that i am also receiving data from a solar controller so am unable to just set msg.payload to msg.payload.temperature for example, as both the solar controller and the weather station has this in the object.

My thought has been to only pass payloads that contain the payload object "model" : "Bressier".
All i seem to be able to do is pass only the model data and not the rest of the objects in that payload. However this is where my knowledge has ran out and i am struggling and would like some guidance.

Sorry if i have not explained myself well.

Hi and welcome to the forum.

Quick question/observation:
the topic should be all you need to filter the messages.

The rtl_433 should be sending on a specific channel.

So the MQTT IN node should have that topic set so ONLY those messages from that device are received.

So really: no filtering should be needed.

How ever: Of those OTHER devices are sending messages on the same topic, that's where your problem starts/is.

Could you send a sample of data from a Debug node so that a complete MQTT message can be seen?

It would help people understand what you are trying to explain.

1 Like

Hi!
Just simply use a "Switch" Node and test if the key is existing!

image

Hi, Thank you and thank you for your quick reply.

I understand what you mean as everywhere i have looked, read and watched all the MQTT topics seem to be unique to the device for example rtl_433/Marlec-solar or rtl_433/Honda-Remote. But if you look at the attached screen shot that i have just taken that is not the case. The unique identifier seem to be in the payload object "Model"

image

Hi, I have included a sample above which should help explain. Unfortunately the sample does not contain the weather station data.

As I wrote before, just use the "switch" node to add a filter that only let the payload pass that have an explicit key! Wait until you have a payload in the debug from your wheather station and find an unique key. Then filter it!

1 Like

eg. msg.payload.model are unique in the above messages.

But the topic should also be unique to THAT device.

So any/ALL of the messages it sends will have that unique topic.

So again: why do you need to filter them?

Can you (@elmo2002 ) also post a message you do NOT want?

So that raises a question:

Shouldn't it have weather data in it?

How do you know that is a message that comes from the weather station?
Just you are saying you are getting incorrect messages that are NOT weather messages.

So how do you know that is a valid message?
It could be one of those unwanted ones.

Andrew the rtl device is a radio receiver. It doesn’t know what things are sending what messages apart from what is in the received payload. So we need to identify something unique in the payload first before we can assign that to the topic.

Oh, sorry. My mistake.

So - for people like me:

You have WiFi devices that all talk back to the rtl device - which is the WiFi receiver.
Then ALL packets get sent to a MQTT message.

Then after being received by NR (and MQTT) you need to route the messages depending on something in their message.

Yes?

The topic does not seem to be unique for each device. If you look in the above screen shot then both topic's are rtl_433.

Can you (@elmo2002 ) also post a message you do NOT want?

If you take the above screen shot as an example i would like to pass all payload objects for the "Marlec-Solar" but nothing for the "Honda-CarRemote"

You can use a switch node:

@elmo2002

Could you post a message from both the solar device and a message from the weather device?

The rtl device is a radio receiver that listens to all transmissions on a certain frequency and then converts the received data into a usable format like my screenshot above.

Then after being received by NR (and MQTT) you need to route the messages depending on something in their message.

That is correct, When i receive a message where the "Model" : "Bresser-5in1" is found in the payload, I wish to forward the entire contents of that payload on

Sorry i haven't included a screen shot of the debug for the weather station, it seems to be a little temperamental in sending data at the moment.

No problem.

I think there are enough people helping you here now.

Yes, it seems you need to use the switch node to filter the messages.
I don't want to start a pissing contest to who is the better one to help.
I got it wrong when I replied and didn't understand the problem.

An MQTT Topic is created as a UTF-8 string with one or more topic levels.Each Topic levels are seperated by a forward slash.

I had thought of this but thought that it would only pass the model part of the payload and not all of the objects.

However in trials with using the "Honda-CarRemote" it passes all of objects so think i have a solution.

Many thanks to all that replied and so quickly. Its much appreciated and i have defiantly learnt from this.