Using the Date().toISOString()
results in:"Error: Incorrect datetime value: '2022-12-24T07:10:45.752Z' for column 'timestamp' at row 1"
I tried Date().toLocaleString()
and I get this error: "Error: Incorrect datetime value: '12/24/2022, 9:52:32 AM' for column 'timestamp' at row 1"
... no wonder with that AM/PM mess.
Please suggest a solution
if my mqtt payload is { "battery": 100, "humidity": 87.36, "linkquality": 150, "linkquality": 147, "power_outage_count": 11, "pressure": 1002, "temperature": -1.06, "pressure": 1002.2, "temperature": -1.07, "voltage": 3085 }
how can I refer to some selected values?
I mean to do something like: msg.topic="INSERT INTO mqtt (`timestamp`, `temperature`, `humidity`) VALUES (Date().toISOString().slice(0, 19).replace('T', ' ') , ??????)
...
I do not understand the ?,? in the example - how do I complete my "msg.topic" with temperature and humidity from the incoming mqtt array ?
In that case, probably, the sensor is publishing it three times.
You could use a delay node set to allow 1 message every 10 seconds and to discard intermediate messages. That would throw away the repeats.