In order to reduce the number of Particle.publish events in a product I have been looking at storing a small cache of readings and then uploading them with timestamps as supported by the Ubidots API.
the validated JSON for this is as so: curl -X POST -H "Content-Type: application/json" -d '{"Temp": "63","Floogit1":[{"value":"28","timestamp": "1505913534000"},{"value": "23","timestamp": "1505913554000"},{"value": "22","timestamp": "1505913574000"},{"value":"50","timestamp":"1505913513000"}],"Floogit2":[{"value": "28","timestamp": "1505913534000"},{"value": "23","timestamp":"1505913554000"},{"value":"22","timestamp":"1505913574000" },{"value": "50","timestamp": "1505913799000"}] }' http://things.ubidots.com/api/v1.6/devices/mymagicaldevice?token=thatisonesexytoken
However Iām struggling to work out how to create the mustache/string that will process this webhook correctly. Iām sure Iām missing something pretty elementary but I just donāt see it. This is my JSON definition in the webhook:
{
"Temp": "{{T}}",
"Floogit1": [
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
}
],
"Floogit2": [
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
},
{
"value": "{{v}}",
"timestamp": "{{t}}"
}
]
}
And this is my string / publish
Status=String::format( "{\"T\": \"%i\"\", \"v\":\"%i\",\"t\": \"%u000\"},{\"v\": \"%i\",\"t\": \"%u000\"},{\"v\": \"%i\",\"t\": \"%u000\"},{\"v\":\"%i\",\"t\":\"%u000\"},{\"v\": \"%i\",\"t\": \"%u000\"},{\"v\": \"%i\",\"t\":\"%u000\"},{\"v\":\"%i\",\"t\":\"%u000\" },{\"v\": \"%i\",\"t\": \"%u000\"}} ", 31,v1,t1,v2,t2,v3,t3,v4,t4,a1,t1,a2,t2,a3,t3,a4,t4,);
Particle.publish("myEvent",Status,PRIVATE);
Iāve been happy up to now with simple flat mustache definitions but this doesnāt seem to be quite so simple. When testing this against request.bin I can see a convincing output except all the values are empty:
{"Floogit2":[{"timestamp":"","value":""},{"timestamp":"","value":""},{"timestamp":"","value":""},{"timestamp":"","value":""}],"Floogit1":[{"timestamp":"","value":""},{"timestamp":"","value":""},{"timestamp":"","value":""},{"timestamp":"","value":""}],"Temp":""}
thanks for the edit