-
Create a new spreadsheet: http://docs.google.com/spreadsheets/create
-
Name the spreadsheet file whatever you want
-
Get your new spreadsheet ID from the URL. Example: https://docs.google.com/spreadsheets/d/169v40OsFOaGHO6uQwuuMx2hlWK-wvYCzrr93FAWivHk/edit#gid=0
example id is "169v40OsFOaGHO6uQwuuMx2hlWK-wvYCzrr93FAWivHk"
-
Add the single value "Time" in cell A1. You might consider selecting View -> Freeze -> 1 Row
-
Create the helper script
-
Open script: Click Extensions -> Apps Scripts. Optionally change the name of the project (default "Untitiled project")
-
Copy the contents of Code.gs to replace the stub "function myFunction"
-
On line 4, Replace "REPLACE ME WITH SPREADSHEET ID" with sheet id from step 3
-
If you changed the name of the sheet (the name in the tab at the bottom of the spreadsheet, not the name of the file), update it on line 5. (defaults to "Sheet1").
-
Deploy helper script as webapp
-
Change Who has access to the webapp to "Anyone". Please note, if any one gets a hold of your published endpoint, they will be able to send data to your spreadsheet, but they will not be able to view any of it.
Also: If you revise or fix your webapp code, be sure to selectNew
as the version on the webapp publishing popup's Version drop-down. Otherwise you may continue to run the older version. Version management must be explicitly performed sometimes. -
Copy the URL on the confirmation page.
E.g.: https://script.google.com/macros/s/AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4/exec
-
Extract URL key for your new webapp, it is between /s/ and /exec.
AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4
You will need to enter this into the SmartApp below. -
(Optional): Test out your new webapp, add this to the end of the URL from step 6:
?Temp1=15&Temp2=30
E.g., https://script.google.com/macros/s/AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4/exec?Temp1=15&Temp2=30
A successful test will return the messageThe script completed but did not return anything.
If you do test it, make sure you delete the test data from the spreadsheet. Just delete any rows added after row 1 and any test columns
-
Login to the the SmartThings IDE at https://account.smartthings.com/ (Make an account if you haven't already)
-
Go to "My SmartApps"
-
Use either Github Integration (step 4) or Manual (step 5)
-
Github Integration
(See this link if this is your first time using GitHub Integration: http://docs.smartthings.com/en/latest/tools-and-ide/github-integration.html)- Click Settings
- Add this repo:
Owner:loverso-smartthings
Name:googleDocsLogging
Branch:master
- Click Save
- hit "Update from Repo" and select
googleDocsLogging (master)
- Under "New (Only in GitHub)" select "google-sheets-logging"
- Select the checkbox next to "Publish"
- Click "Execute Update"
-
Manual creation (If you didn't follow step 4)
- hit "+ New SmartApp" on the right, then select the "From Code" tab. 2, In another window, open the source code located in this repo at smartapps/cschwer/google-sheets-logging.src/google-sheets-logging.groovy https://github.com/loverso-smartthings/googleDocsLogging/blob/master/smartapps/cschwer/google-sheets-logging.src/google-sheets-logging.groovy
- Click "Raw" and copy all the code
- Paste the code into the New SmartApp "From Code" box and click Create
-
In the SmartThings App, tap on the Automations tab, click on + in the upper right of the screen, select Add Routine and choose the Discover tab at the top. Scroll down to find the Google Sheets Logging smartapp.
Alternately, you can install via the beta SmartThings web interface at https://my.smartthings.com/. Login with your SmartThings account, click the plus in upper right corner, select Add Groovy SmartApp and then select Google Sheets Logging.
-
Select events you want to log under "Log devices..."
-
Enter URL key from step 15 under "URL key"
-
Enter a name of the smart app
-
Click Done!