Help, trying to save data to Google spreadsheet

Hi, I'm trying to save data to a Google sheet via IFTTT Webhooks.
I found some posts about this, but they don't show information for all the questions that I have.
I get a row in the spreadsheet, but no data.
I want to have time in column1, then humidity, then temperature.
I have 2 local variables in my rule machine app that to hold sensor data for humidity and temperature. Are local variables OK to use, or do they need to be global?

When I write the POST command, it asks for a content type.
Not clear here if I should pick JSON or one of the other types. I've tried both JSON and text. Then on the IFTTT end, what ingredients do I need for the formatted row?
screen1

Thanks,
John

1 Like

I don't have experience with either of these (posting json from RM or using IFTTT from RM, but one thing you may want to try is including "curly braces" at the beginning and end of the json string you are constructing, so resulting in a body of:

{ "value1" : "63.0", "value2" : "16.2" }

I wrote up a non-IFTTT method for doing precisely this (writing multiple data fields directly to a spreadsheet in Google Drive), by using a pre-made Form.

My step-by-step How-To is online here. Though originally intended for Reactor Multi-Hub or Tasker, the procedure should be adaptable very readily to Hubitat.

1 Like

Why get IFTTT involved? Go direct from Hubitat to Sheets.

Alternately, there is also Simple Event Logger from krlaframboise.

2 Likes

Thanks, I added the curly braces.
From my logs, the command sent was:


but the spreadsheet just says "json payload", so somethings not quite right.
screen2

I'm wondering whether the key needs to match the column headings in your spreadsheet? So:

{ "Humidity Value" : "63.0", "Temperature Value" : "16.2" }

And maybe the curly braces are not required in your string?

I do tend to agree with where @jlv was heading with his suggestoins. I'd even take it a step further (I think...) and say that if you can get a method to record results locally that can then sync them into the cloud, that would be quite useful.

@jlv, Thanks for the suggestion. I created and deployed the web app per the readme apps/googleSheetsLogging/README.md at master ยท cschwer/apps ยท GitHub
I tested it, and it worked.
Now my question is how to I trigger this from rule machine?
The instructions say:

Create the App

  1. Use the standard app creation steps

Install the App

  1. Select events you want to log under "Log devices..."
  2. Enter URL key from step 6(v) under "URL key"
  3. Click Done!

My question is how to do I trigger this from Rule Machine?
Is is another POST command, if so what variable type?
I don't understand the reference "log devices"

Thanks,
John

1 Like

There's no need to use RM.

In the app, just select the devices and the attributes for those devices you want logged. The app will subscribe to the events and automatically post the event to the spreadsheet on a regular basis. cschwer's app bundles up multiple device events into one row. It will automatically add columns to the spreadsheet for each thing logged.

It looks like this (but I formatted my column header a tiny bit):
image

Simple Event Logger does something similar, but it logs one line per event.

1 Like

@jlv Thanks, I now have the app installed, and I configured it with my two data points, one for humidity and one for temperature. I didn't think it was working yesterday, but now I have some date in the spreadsheet. I thought the data would be on some sort of schedule, but it appears a little random (over 6 hours now with no data), and I'm only getting one variable per timestamp. Perhaps if the variable isn't changing much it doesn't send it? But it's working. Thanks for your help

screen4

3 Likes

From what I'm seeing in that screenshot, I'll stick with my direct-to-Spreadsheet-via-HTTP-POST approach using my "Google Forms" method**. At least I come away with every variable (that I include) posted at each timestamp, whose frequency I control (from any rule engine or phone), and my timestamps are consistent in appearance. (Screenshot redacted for privacy.) :slight_smile:

P.S. In case you're wondering, I use this to log things like who called, where we drove, when we watched TV, when our Android devices got charged, etc. **Just didn't have the necessary free time to modify this technique to Hubitat, but plan to very soon.

1 Like

Correct.
cschwer's app only queues the data to send when the event gets fired, and then only POSTs to the sheet after the time to queue.

For both of my uses (recording temps in one sheet and battery value in another), I use a long time to queue (15 minutes for temps and 6 hours for battery value). Only the last value for a particular device/attribute gets logged, and that works for me. For other esoteric things (that aren't logged often) I use a 1 or 5 minute queue time.

1 Like

I agree, it would be nice to be more in control of when I get the data. I may fiddle with a direct post from Rule Machine and see if I can get it to work. It seems like some other people do have it working.

1 Like