publishStateString data to Webhook JSON or Web Form to Google Sheets

I have changed the way I publish my data to a StateString to use with Losant, and to save on data. I want to have a backup of that data sent to a google sheet. In the past I used a Webhook / Web Form or JSON. Now that my data is in a string I can’t seem to figure out how to change my Webhook to read that new data format. I have tried a number of different combinations… really just guessing but keep coming up blank. Is there a tutorial on how to do this that I missed? I did a number of searches but was not able to find anything that related.

Thank you.

Here is how my data is published. With @ScruffR’s and @RWB’s help.

if (Particle.connected()) {
    publishStateString[0] = '\0';         // make sure the string is reset
    if (millis() - lastpub2 > 600000) {   // time for a full report?
      lastpub2 = lastpub = millis();      // reset BOTH timers as the full report also features the short report data
      snprintf(publishStateString         // use this for losant format, removed ADC
              , sizeof(publishStateString)
              , "%.1f:%.2f:%.1f"
              , flow, fuel.getVCell(), fuel.getSoC()); 
if (publishStateString[0])  // if the string was populated send it
      Particle.publish("State", publishStateString, 60, PRIVATE, NO_ACK); 

Here is my webhook with the JSON data parts removed. I assume that I need to do this differently than your typical JSON format. Maybe a custom body? I am just not sure. I can’t figure out how to separate data that is all within one set of " " and separated by :

Any ideas or tutorials I missed please share. Thank you for the help it is really appreciated.

If you want to separate data in the webhook integrations, it’s the easiest to send your data as JSON.

But if Google Sheets can deal with comma separated strings your data field contains the string as you sent it from your device.

Thank you @ScruffR.
Do I need to use a some type of custom format in the webhook integration or can you only use JSON? I don’t want to go back to JSON as I finally have Losant recording the string. I also found your way to publish the data way easier and save on bytes. I tried webform and custom body but I either get undefined or empty cells. I thought that maybe I could decode it like I do in Losant but no luck there either.

Am I missing something very obvious? That is usually the case with me and this stuff.

Thanks again.

I’d need to look into the Google Sheets format, but IIRC @bko once mentioned pipe symbols (|) as columns separators.
But Losant is most flexible in the way to parse your data, so whatever Google Sheets - as the more “restrictive” target - needs you can use and then throw at Losant too.

1 Like