I am attempting to send a JSON with multiple payload datapoints. My event name is dataup. When I replace "String::format("{"tcdata":"%f","towerid":%s}", tcdata, towerid)" with String(tcdata) it works, but then I can't parse the payload on the other end of my Webhook.
This is the template I am using. I tried room.c_str() but this doesn't translate for a floating point. I'm really struggling to understand this, any advice is appreciated.
FIRMWARE
String room = "kitchen";
int temp = 20;
String data = String::format(
"{ \"room\": \"%s\", \"temp\": %d }",
room.c_str(), temp);
client.publish("test", data, PRIVATE);
WEBHOOK
{
"eventName": "test",
"url": "http://example.com/log/{{{room}}}",
"json": {
"location": "{{{room}}}",
"temperature": "{{{temp}}}"
}
}
Here's my code.
String towerid = "ancillary_1";
float tcdata = maxthermo.readThermocoupleTemperature();
client.publish("dataup", String::format("{\"tcdata\":\"%f\",\"towerid\":%s}", tcdata, towerid), PRIVATE, NO_ACK);