My use case is to share a record of when people unlock our front door with the rest of my family. Here's how I configured Rule Machine to log directly to Google Sheets without any other services involved. Hope it's useful, the other solutions I found involved third party services like IFFT and such, this is direct and fast.
First, create a new sheet and create a form with short answer texts.
Copy the link somewhere and extract out each of the "entry.NNNNNNNNN" items from the URL. Extract the sheet ID from the URL, the string of characters before the last /.
In Rule Machine, create a rule to set some local variables to the values you want to save as rows. I set name and action using the device properties of the lock.
Create a local variable named sheet and set it to the value of the sheet ID.
Finally make the final action a form encoded POST to the URL https://docs.google.com/forms/d/e/%sheet%/formResponse?usp=pp_url
Select content type: form encoded
Enter body for POST. Note the & separating each field.
Had an application for this trick (logging run times for a residential well pump, using a Zooz ZEN78 Power Relay in my use case), but couldn't get it to pass any data to Forms....until I changed from a HTTP POST action to a HTTP GET action. In case anyone else has a need...
Follow JMac's instructions for getting your [Form ID] and Entry ID from Google Forms, then embed your Form ID directly in the GET, after the "/d/e/" of the URL, and add your variable(s) immediately after "formResponse?", formatted as JMac says above (i.e., "entry.NNNNNNNNN=%YourVariable%"). You do not need the "usp=pp_url" in the GET URL and no body for GET is needed. Be sure to link the Google Form to a Sheet if you want to do any calcs or manipulations.
I got to this: Second, click the edit button when looking at the form, click the 3 dots in the top right and select, "Get pre-filled link"
a. I don't see an edit button.If by Edit button, it means to click the 3 vertical dot menu, I can do that. However:
My 3 vertical dots appear next to a purple button labeled "Publish"
If I select "Pre-fill form" it tells me to "Pre-fill responses, then click "Get link"
So I put some data in the fields, then clicked "Get Link." The result is that at the bottom I get an opportunity to "Copy Link"
The next step is "extract out each of the "entry.NNNNNNNNN" items, so I did exactly that. The NNN's are followed "=[data I inserted in the fields]" but I left the = sign and the data I inserted in the url.
I also extracted the string of characters before the last /. This leaves two // directly prior to "viewform?"
If someone can tell me if what I've done so far is correct, I'll go to the Rule Machine step...
I have not yet gotten this working. However, in the hopes that someone who knows what they are doing can help, I wrote up a step by step set of directions, inferring what I could from @JMac original post, and @mjd1953 updates. I had to infer, because the Google interface has changed somewhat.
Can anyone PLEASE tell me what I've done wrong?
Create a new Google sheet and name the sheet
Select Tools/ Create a new form.The form will open with the same name as the spreadsheet.
Enter the form fields (by overwriting “Untitled Question”); in the dropdown to the right for the type of response, select “Short answer text”.Add fields by clicking the plus sign to the right. Repeat the above for all fields.Best to start simple with one word field names.I started with only “Date” and “Humidity”
Click the 3 dots in the upper right corner, to the right of the purple “Publish” box, and select “Pre-fill form”
In the response field for each field you are tracking, enter the field name as the response (so if the field name is “Date”, enter “Date” as the response)
Click on the purple “Get Link” button below your form fields
Click on the black “Copy Link” button at the bottom left of the page
Paste the link URL somewhere
In the paste of the link
Extract out (copy & paste elsewhere) the last part of the URL beginning with the first “entry.NNNN “ up to the end of the URL
Extract (copy & paste elsewhere) the sheet ID from the URL, which is the string of characters before the last /
Go to Hubitat/Automations/Rule Machine, and create a new rule.
Define your trigger (in my case it was Humidity changed) and click “Done with Trigger Actions.”
Click on “Select Actions to Run (and Create and manage Conditions and Local Variables)”
Click on “Create a new Variable” (in Green)
Create a new Local Variable for each value you want in your data rows (the columns)
Create a local variable named sheet and set it to the value of the sheet ID.
Click on “Create new Action” (in Green)
At “action type to add” select “Send Message: Notify, Speak, Log; HTTP Request