Having fun extracting data from my Duet 3 card on my 3D Printer to email me useful informations.
So far, I have all I need, except the formatting of the data send in the email is horrible.
I get this:
{"status":"Printing from SD card","printPercent":80.9,"printTimeLeft":3751.6,"x":135.425,"y":121.557,"z":91.17,"currentBedTemp":50,"currentHotendTemp":210.3,"activeBedTemp":50,"activeHotendTemp":210,"stateBed":"Active","stateHotend":"Active","fileName":"0:/gcodes/cam holder.gcode"}
Is it possible to get this instead:
Status : Printing from SD card
printPercent : 80.9
printTimeLeft : 3751.6
x : 135.425
etc.
The format is in a single line of data right now and is kinda hard to read. I've messed with CSV but it is not really helping my cause as all I can get is all the data without the description, but still all on a single line.
I was thinking of inserting a break between each message in the payload. Is that possible?
That is not a JSON object, that is a Javascript object. A JSON object is a string, which I assume is what you started with. So it isn't a horrible email format at all, it is ideal as it is JSON. So now all you have to do is to build the text you want from the object. Start by reading the node red docs Working with Messages which will show you how to access the various attributes. Then I suggest maybe using a Template node (not ui-template) to format the text for putting in the email. The Information panel for the node shows you how to insert values from the payload into the string returned.
Feed the javascript object into the template, not the original JSON.