Now i want to write all sensor data with the same timestamp from the different messages into one influxdb mesurement with one field for every single sensor data/mqtt message.
Example - this three messages comes at the same time.
My idea is, all sensor data reported at the same time by a device should also have the same timestamp in the influxdb.
If I have for example a weather station, then I thought so far that one collects these sensor data all in a mesurment.
The Bucket is Haussensorik (House sensors)
The Mesurement is for example Wetterstation (weatherstation)
in principle, yes. there is a receiving unit that receives the data from the microinverter via a proprietary protocol and passes it on to the brocker via mqtt. Unfortunately I can not modify the structure of the topics.
Thanks!
Is there an easy way to shorten the names of the elements? Here is the complete mqtt topic now.
Or should I change the names via a function node?
If you want the fields to be name, bootloaderversion, etc then in a function node you can iterate the keys using Object.keys(obj).forEach() as described in Iterating Through an Object with `forEach()` - Mastering JS, then for each one use split("/") on the property name and take the last element of the array as the new key name. Build a new object with the new field names and then replace the payload with the new one.
Should not several of those be tags rather than fields in influx? Also make sure you change the ones that are numbers from Strings to Numbers, though I am surprised that the MQTT node does not do that for you if you tell it to auto-detect the type.
Yes, I still need to think about the database/table design.
Yes, if I use auto-detect, then only strings are generated. If I set "a parsed JSON Object", then the numbers are recognized. With the strings there are then errors. I can process them with Catch
When i use in the mqtt node "output: auto-detect" then all messages contain the data type string.
When i use "output: a parsed JSON Object" then I receive only the messages that contain a number. Messages containing a string are not forwarded. The messages with a string as payload cause an error. I can then catch this error with a "Catch Node" and convert it to a correct message with a string as payload.