[OBSOLETE] Log events to Google Sheets [see post /36719/154 for Github repo and v1.1]

I’m no expert on any of this. I have been able to figure out a number of things, but only through extensive trial and error, and help from others. I’m an old amateur VBA dude. Groovy, javascript, and server-based apps are pretty exotic to me.

At this point all I am doing is taking tiny tiny steps based on what’s right in front of you. If the date looks good, is .timezone not defined? Did you supply location coordinates (API “My Locations”)? Grasping at straws here. There’s probably something very basic that’s wrong. The question is did you forget a step, or to set something, or is your setup/hub/whatever broken somehow.

I have been told that DevDocs.io are a good javascript reference. There are also subreddits on javascript as well as a google forum for Google Docs apps and script . Not sure where a groovy forum would be, but it’s based on javascript.

We can still try a Skype screen sharing but who knows if it will help.

In my ST app, it appears that this smartapp is not configured (nothing selected), but it seems to be working/logging every 10 minutes. Anyone else see this, quick way to fix it? Prefer not to set it all up again since it is logging but I wanted to change some devices.

@Kevin I only ever change CSchwer log settings through ST website API (on PC), not through my phone ST app

Mike - how do you do that? I was just looking in the ST IDE(???) and I don’t see the options. Thanks!

  1. Go to web API at https://graph.api.smartthings.com. I do it on my PC, although strictly speaking you can probably do it on your phone. Make an account if you don’t have one.
  2. Go to “My SmartApps” (a “tab” along top)
  3. Click on your copy of CSchwer logging app

This is the same place you copied and pasted the code into to start everything. We may be stumbling over how to call things.

I get to the smart app and code, I guess I don’t know what settings you are able to change there. There is the source code and a button for “app settings”, but not really anything to change the app’s settings like queue time or which devices log.

check the documentation

I just started using this SmartApp. It’s very cool and I’m liking it a lot. Just a quick question.

I noticed some of my data logs very sporadically like this:

Is this normal?

Thanks,
Joe

Yes, I think it is because the sensor hasn’t reported a new value, so the smart app doesn’t log anything in that cell. Not positive though

Kevin is correct, your sensors typically report irregularly. Such as, only when a value changes. Although you can adjust the reporting interval for many of them. It may seem wonky at first but in the long run, things stand out when they change. And you can deal with it in the spreadsheet by repeating values down in another column if you need to compare to other values side by side.

Here are several places to see more of what’s going on, including each individual sensor data report:

  1. In the SmartThings (ST) phone app, looking at the page for the device, go to the Recent tab.
  2. Much more powerful: Go to the web API at https://graph.api.smartthings.com. Here you can look at your devices, get a long List Events, or even get that list filtered on a particular sensor (temperature) by clicking on Temperature on the device page. Shows time in seconds and even milliseconds (List Events). For all these API logs, you can scroll back for seven days.
  3. You can watch the CSchwer logging script in action in the web API on its My Apps page. Select your Location and Install it and a log will start running, showing the current string it is building.
  4. You can likewise see everything going on for your hub/account in the web API by using the Live Logging link at top of API page. Including CSchwer logging.
  5. You can see further details of each app if you go to My Locations and on the row for your hub, click Installed Apps. Then click on the “Other” entry for the Logging app. This is yet another even more detailed view into a lot of little aspects of the script, such as a listing of each time it ran recently. Great for testing or troubleshooting. Play with the links here to see interesting things sometimes.

Hope that helps.

1 Like

I’ve only searched through this thread briefly so I apologize if it’s already been addressed. I’ve been running this app for over a month now and I’m up to over 10,000 rows. I saw mentioned above that there is a Google Sheets limit of 2 million cells (rows x columns). What will happen to the event logs once this limit is reached? Does old data start to be deleted or does the app stop logging altogether? I want to be prepared in case I need to export any of the data.

Getting this error message in logging file.

Error sending value: groovyx.net.http.HttpResponseException: Not Found

Anyone have suggestions?

Spreadsheet Time Entered as Float

Installed code per very clear instructions (thank you). The time field is being entered as a float and not like what others in this thread have received as a result.

The thread above with similar issues to my issue did not result in a usable answer.

Here is an example live log output:

Google accepted event(s)
debug 200 https://script.google.com/macros/s/***/exec?

Time=2%2F14%2F2017+08%3A07%3A35&Bed+Right+Toe+Motion+Sensor+motion=inactive&Bathroom+Toe+Motion+Sensor+motion=inactive&Bed+Left+Toe+Motion+Sensor+motion=inactive
debug url [https://script.google.com/macros/s/***/exec?]
debug Processing Queue
debug healthPoll()

I have already destroyed and recreated this process twice (including killing the Google Macros and starting with a fresh sheet), with the same results.

Thank you.

Crispy,

Sheets will simply give an error if creating a new row would cause it to go over 2M cells. There’s no way around it. CSchwer’s SmartThings code will not handle this. So your output will simply be lost unless this is fixed.

I just make a copy of my Sheet when it is near full and rename it something logical like “ST CSchwer Logs 2016-10 to 2017-02”.

Then I empty my general “ST CSchwer Log” and then it has plenty of room to keep going. No need to edit my scripts for a new Sheet name.

Yes it’s a little awkward. Especially given the fact that there is no way to have all your data in one Sheet ultimately, after this. I don’t think there’s any way around it, not even by paying. Still, Sheets are a hella convenient way to do a lot of things. And you can always copy it down to Excel, put it in some other dataset, or whatever, if you are really serious about having all your data in one place.

.
I made a little Sheet that anyone can use to estimate their time left. You should be able to see it and copy it but not edit it. But you want it on your Sheet to estimate your time, anyway.

If I had the time I would make an option for it to check the max number of rows itself so you didn’t even have to check.

And if somebody here can help, maybe we can get some code so that the Google Apps Logging Sheet sent you an email if it was getting to full. (There would be a place you could put your email, and the warning interval.)

2 Likes

Mark Poole, a common mistake is that when you give the CSchwer’s SmartThings app the handoff Google Sheets app URL, you put the URL of the sheet, not of the script (step 6v of the documentation). It needs the script URL, not the sheet URL.

I’m not sure this will solve it because your error is that it can’t even find the URL. Anyway, check out the documentation.

Enjoy!

You need to Format the column in Sheets to Date time then all should be okay.

ANSWER

Thank you, this answered my question.

1 Like

Thanks for the reply RedKnight

The issue was I put the entire URL including the key in the Smart App field labeled Script URL Key

Example
https://script.google.com/macros/s/AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4/exec

Only wanted AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4 in this value.

Better description might be… Key from Script URL

What is wrong with this screenshot? It keeps saying my data range is incorrect
.

Hi Mark,

Step 6.v says

v. Extract URL key for your new webapp, it is between /s/ and /exec.

       AKfycbzY2jj4l7RSpFYfN62xra0HmcXPQXAUI17z6KKHWiT3OYyhUC4

   You will need to enter this into the SmartApp below.

It seems pretty clear to me, maybe you were moving too fast?

Anyway, glad it works now. There are a lot of moving parts there. My problem has been that, although it installed just fine, that was months ago. If there’s a problem now, I can’t always remember where it was discussed, or even if it was.