[PROJECT] Google Photos integration for dashboard image slide-show

This repo provides a Hubitat App and Device Driver code to run a slide-show in a Hubitat Dashboard of images from an album in the user's Google Photos library. Pre-requisite setup via Google Cloud Platform is detailed in the README.md file.

12 Likes

Wow! This works great.

Thanks

@dkilgore90 - thanks - I also was able to get this integrated and it's working great!

It's not a big deal but I'm wondering if it'd be easy to allow the 1 minute timer to be configurable?

Also, are the images (URL's) updated as I update the Google Photo's folder or does it just create this list when the device is initially created?

  1. Yes, changing the refresh timer to a configurable interval is straightforward - on my to-do list.

  2. Currently it rotates through a list of image IDs that are retrieved and stored when you click Load Photos from Album in the App page. There isn't a notification when the album is updated, but I could look into refreshing the ID list daily (or on some other configurable interval)

2 Likes

@jpage4500 Both changes available in app version: 0.1.0, just released. Also added to my HPM repo, so it should show up there shortly for auto-updates, etc.

1 Like

Hi @dkilgore90, the link for your HPM is not working. I get this

Invalid Package File

https://raw.githubusercontent.com/dkilgore90/google-photos/blob/master/packageManifest.json does not appear to be a valid Hubitat Package or does not exist.

I think it should be this?
https://raw.githubusercontent.com/dkilgore90/google-photos/master/packageManifest.json

1 Like

Argh -- copy/paste bites again. Thanks for the heads up and correct link, I've pushed this fix in the HPM repository.json file.

1 Like

Please hold for app version: 0.1.1 -- to be released shortly. I accidentally set the "nightly refresh" to run every second for the entire hour of 11pm :grimacing:

UPDATE: release pushed. Please click the Done button in the App page to ensure that the new schedule is applied.

2 Likes

Awesome, thanks! I'll give it a shot.

Just curious - I noticed a few of my photos were actually videos (they are images but have a little play button in the middle). Is there a way to access the video URL? Just thinking I could have video's play when the image is viewed full-screen in my dashboard app

Same url - for the image attribute I'm wrapping it in an <img> html tag, probably would need to intelligently change the tag based on the media content - maybe a <video> tag? :slight_smile:

I should have mentioned - the dashboard I created pulls the url from the <img> tag and loads it directly. It's a crazy long URL with no extension.. I did notice the URL ends with \u003dw2048-h1024. Can that same URL work for video playback?

Good question! This link from the API documentation shows the usage of the video URL - essentially, strip the =wXXXX-yXXXX params you mentioned, and add =dv. As is, and you get the video thumbnail. There are other attributes I can parse from the API response to know if it is a photo or video - and make those changes internally before providing the URL - probably in conjunction with the html tag change mentioned above

Thanks! That's a useful link. It would be awesome if there was a flag or some other indicator that this is a video link. At least in my dashboard I could use that and try to play the video when the image is opened full-screen.

I'm also thinking of keeping track of the last URL's received for this device.. and then when displayed full screen I can offer swiping left/right to browse recent images. I did see a note in the API docs that said the link is only valid for 60 minutes so that might affect things (although I cache the images too so it might not matter)

anyway - thanks for all of your help!

Tonight's updates:

  • new attribute "mediaType" -- values: photo or video
  • "image" attribute uses html <video> tag if the mediaType is video -- will autoplay and loop in Hubitat Dashboard until the next image is loaded.

@jpage4500 -- if you still want to parse out the URL for your own handling, you can generically find the src="URL_HERE" string within the HTML provided by this attribute.

1 Like

Hi @dkilgore90 is there step 7. 1. Copy and paste the contents of your Oauth2 credentials.json file downloaded from GCP into the Google credentials.json input field

Do I just copy all the contents inside credentials.json file and past it to the HE google app input field?
Did that but I don't get the link to authorize with your Google Photos library.
My content is this. Client_id and Client_secret replaced with xxx.

{"web":{"client_id":"xxx.apps.googleusercontent.com","project_id":"he-photos","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"xxx","redirect_uris":["https://cloud.hubitat.com/oauth/stateredirect"]}}

The **Note to click "Done" could be considered step 7.1 (or step 8)... Assuming you did that after pasting your credentials.json.

If you click the "gear" icon in the top right on the App page, in the Settings table, you should have an entry for credentials, with the JSON you pasted. And in the State table, you should have an entry for accessToken. If either of these is missing, it would explain why the Auth link is not displaying -- and we can then dig into why it is missing.

Thanks for your help.

I do see the credential entry in the setting but not the access token in the state table.

Hitting log access token and force token refresh give me these logs.

app:10682021-05-25 06:47:32.732 errorLogin refresh failed -- Bad Request: [error:invalid_request, error_description:Missing required parameter: refresh_token]

app:10682021-05-25 06:47:32.409 infoRefreshing access_token from Google

app:10682021-05-25 06:47:30.426 debugAccess Token: null

I thought I was doing something wrong (and maybe I am?), but I have the same results/errors as @Navat604 .

I do not show any entry for accessToken in the State table.

Thanks.

The state.accessToken entry is the OAuth access token for Hubitat (used when Google calls us back in the auth process). It should be created automatically when the App is installed. Go back to the Apps Code page - does the OAuth column show enabled for Google Photos App? If not, you missed step 3 in Hubitat Installation in the README.

You can run that step now, then Remove the current app installation and add it again.

It does show 'Enabled' for OAuth. I also just uninstalled and re-installed the user app, re-inserted the credentials. json contents, hit 'Done'. then re-opened the app. No changes. Still no State for accessToken and the errors are the same as listed above. Thanks.

Download the Hubitat app