SmartThings Google Sheets Logging
Create the Spreadsheet
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
Copy the contents of Code.gs to replace the stub "function myFunction"
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, even anonymous". 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 select
Newas 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.
Extract URL key for your new webapp, it is between /s/ and /exec.
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:
A successful test will return the message
The 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
Create the SmartApp
Login to the the SmartThings IDE at https://graph.api.smartthings.com/
(Make an account if you haven't already)
Go to "My SmartApps"
Use either Github Integration (step 4) or Manual (step 5)
(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:
- Click Save
- hit "Update from Repo" and select
- 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
Install the SmartApp
In Smartthings App go to marketplace -> Smartapps -> My Apps -> Google Sheets Logging
Select events you want to log under "Log devices..."
Enter URL key from step 6(v) under "URL key"