[RELEASE] Google Fit Tile

smartapp_misc
smartapp_sensors

(Sam Steele) #1

I’ve released a SmartApp that will display your current Google Fit step count and most recent weight as a tile in the SmartThings mobile app. This app also makes the steps count available to other apps that support the Steps Sensor capability. Huge thanks to @mnestor’s GCal-Search app for showing me how to handle Google OAuth2!

You’ll have to install both the SmartApp and the Device Handler from my github repo: https://github.com/c99koder/SmartThings and there are instructions for configuring the OAuth2 login in the README.

https://github.com/c99koder/SmartThings/raw/master/smartapps/c99koder/google-fit-tile.src/Screenshot_20161107-153736.png


Need help with complicted Oauth process
(Brian Diehl) #2

This looks awesome!

Now I have to check and see whether my Withings sends my weight over to Google Fit.


(Sam Steele) #3

It should work, I’m using a Withings Smart Body Analyzer through Google Fit here.


(I got a hair cut from Alexa) #4

This is so cool…nice job!

I missed something though. I get no steps or weight and I see this in the ST log when I hit the refresh button.

java.lang.NullPointerException: Cannot get property ‘value’ on null object @ line 231

I do see the requests hit the Google API dashboard graph.
Any clue where I might have made the mistake?
Thanks
–Keith


(Sam Steele) #5

I’ve just pushed a fix to github that adds a bit more debug output and should hopefully fix the issue fetching the steps data. Please let me know if you’re still having an issue!


(Brian Diehl) #6

That’s what I’m using and it appears to be pushing over.
Awesome.


(I got a hair cut from Alexa) #7

It works I see steps now!

But I get a different entry in the log:
java.lang.NullPointerException: Cannot invoke method reverse() on null object @ line 296


(Brian Diehl) #8

What shows up for Weight in the app?
Wondering if maybe you get an error if you don’t use the weight features in Google Fit?


(I got a hair cut from Alexa) #9

Well a graph from may 16 to oct 12 shows up in the fit app…apparently I haven’t opened the WeightGurus app to sync with the bluetooth scale for 3 weeks.


(Sam Steele) #10

The app only requests the last week of weight measurements (annoyingly there’s no API to just get the most recent one, you have to specify a date range). I’ve extended the range to 6 weeks, let me know if you can see the weight now!


(I got a hair cut from Alexa) #11

Thanks Sam,
That last change did it for me, it picked up my weight from the last weight sync 3 weeks ago. I should get a wifi scale instead of a bluetooth one. :wink: No errors in the log.
Really cool app…good job!
–Keith


(Manny) #12

I followed the instructions as best as I could but I’m getting “disallowed_useragent” on the app when I try to put in my google credentials. When I created the Oauth key I set it up for web application and specified the redirect URI. I’m running android 7.1 on a nexus 6. I copied and pasted the client ID and secret into the smartapp before publishing it. I also enabled the google fit API in a new project.

Any ideas on what I could be doing wrong? Thanks.


#13

Same here, getting same error.


(Sam Steele) #14

Looks like Google doesn’t allow logins through the SmartThings app anymore. Samsung would have to update the SmartThings app to use a real browser instead of an embedded web view for oauth logins.


(Manny) #15

I clicked on more details on the error and it said something about starting
November 2016 or so they would disallow Oath authentication from webview,
or something like that. It said something about steering developers to use
some other type of authentication.

Update: Here is the info about it. This change went into effect after the last post on this thread.


#16

c99koder,

I was able to get this working by changing style to external on line 51 like this on the Smartapp:

href url:redirectUrl, style:“external”, required:true, title:"", description:“Click to enter credentials”

This will make it so it loads in the browser instead of trying to embed it in Smartthings app and works perfect now for me. After I authorized it, I had to close the browser page and go back to the Smartthings app but it connected fine with my Google Fit account.


#17

Is there anyway to add more content like Active minutes, Miles and Calories to this app too?


(Manny) #18

Thanks! That worked for me too.


(Sam Steele) #19

Thanks! I’ve updated the smartapp on github to use external authentication, glad to hear it’s working again. It should be possible to add calories, though you’ll have to re-authorize the app to add additional permissions. I’ll look into adding more data soon


(Manny) #20

Thanks! Nice work! Adding more info would be even better.

By the way how often should the info be refreshing? Sometimes I have to manually refresh. Not a big deal. Just asking. Thanks.