How can I combine humidty and temp from Tellstick Duo MQTT before sending, when it is there?

I have finally found something that works for me so that I can use the Tellstick Duos that I have around my house and cabin (I bought a bunch of them cheap when they were going out of style, so quite some years ago). This Docker container can be set up with whatever MQTT topic you want, so it's usable with Node-RED too, not just Home Assistant:

The only problem is that it sends separate messages for humidity and temperature, so my old node making it into the format I would like it in (it's sent to a webpage for display) does not work. This is the code I use in the function node:

var id = msg.topic.split('/')[1];
var tmp = msg.payload.temperature;
var hum = msg.payload.humidity;
msg.payload = id+','+tmp+','+hum;
return msg;

But then there are separate messages for humitidy and temperature, here's one with the ID 167, they come within milliseconds of each other:


In addition to that the mesages come three times each, and I have not found , I get messages out like this, with the humidity:


And one with temperature from the same sensor:


So two things, first remove the extra sends and then combine the two messages into one. I have looked at the filter node, but it seems like that can't filter out same messages within x seconds, only filter out changes. I would like the mesages to come in each time the sensor sends, not just when it changes.

Here's a screenshot of two of the raw messages, if that helps:

And here it's shown that it sends three times:

And then there's one thing: Some of the sensors do not have humidity, only temperature. So I hope it can be done so they send the temp, without waiting for humidity that never comes.

See this article in the cookbook for an example of how to join messages into one object.

@E1cid Thanks! The filtering seems to work too, it turns out that when there's a new temp sensor sending, the filter node considers that a new value in the same setup, so input --> filter --> join --> function works.

1 Like

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