Node-RED Function for MQTT --> Influxdb

Hi all,

I have setup my MQTT and Influxdb connection already and it is working quite good for a while now.
Now i want to add some let's call it "advanced functionallity". So a little backround information: I have multiple sensors (temperature, humidity etc.) in my home installed and all are sending their values in the data base, but every sensor is sendy by change so i have different time stamps for each single sensor/value. Is it possible with a node-RED function to get all sensor values from one type e.g. all temperatures and store them into an array and if one value changes the complete array of values will get pushed into the database? So e.g. 15 sensors are connected with this node and one value changes than all 14 values (previous values) would be send again and the new one value will be sended with the updated value?

I'm thankfull for every hint to get it working :slight_smile:

BR Xienter

It should be possible using a join node to combine all of your temperature readings into an array and send the array to your database when any single new reading arrives. That's not quite the same as when any value changes.
Probably adding in a filter node would prevent duplicates but I've not tried it with an array.

However, it's bad database design to store compound values and duplicates.
It must be possible to extract the data you want with the dB query.
I discarded Influx though because it's understanding of SQL differs from mine.

I will say use join node with message resend node:

  1. create local or global array for all your temperatures (I use local flow variable)
  2. write the new sensor temperature into the array
  3. write the entire temperature array into influxdb

Why is that a problem? That is the efficient way to store the data.

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