With the help of Garmin API I successfully get my Hear rate data into the json file. In JSON file there are pairs of values: EPOCH date/time along with heart rate. My idea is to import this pairs into the SQL.
My JSON file is located on my nodered server.
I know how to import data into the SQL with nodered.
What I don't know is how to write a loop that will go through json and put epoc and hr data into the variable that I will then pass to the SQL.
Also please suggest me if the format of the json file is ok, or should I change it? hr3.json (8.4 KB)
If you want to be able to draw graphs of the historical data then you could consider using influxdb and grafana rather than SQL.
If you use a Change node to extract just the array of timestamp/rates into msg.payload, and then feed that through a Split node, you will get a stream of messages with individual records, which you can then insert into the database.
You're right, influxdb is more appropriate for this scenario, but since I am already having SQL in place, I somehow got used to SQL but I am representing the data in Grafana.
In the meantime I already sucesfuly parsed the json into the object.
Now I am planning to use function node and while loop node to go through all hearRateValues and for each write it to the SQL.
Can you please suggest me, how to get the highest value of hearratevalue array, because I need for a while loop condition.
Thank you in advance. In above example it is 386. How can I get this 386?