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

Thanks. I got it working. And I do see photos from my album, however, the hub hung or crashed. My hub never got this kind of state for over 2 years.

Is this App causing performance issue?

My hub is a secondary hub of a mesh, and all of the z wave and zigbee devices are all on the other primary hub. Most of the apps are on the primary hub. So, this secondary hub is pretty idle most of the time before I added this Google Photos App.

First report I've seen of a performance issue, but that doesn't mean there isn't some bug. Can you provide logs (debug for App), the App metrics on the hub, and all settings values applied in the app?

I removed the App as soon as I rebooted the HE hub, let me reinstall the App and get the info for you.

P.S. I selected a Google Album that has over 10,000 photos, not sure if this was the culprit.

Thanks in advance.

1 Like

Loving the possibilities with this! I do have a question though. Is there a way to easily format so my photos don't get cut off? I seem to be ok with width scaling correctly but the vertical dimensions are getting cut off.

Based on the Google Photos API specs, the "c" param would crop photos, which we don't specify when building the image attribute iframe html.

This was a side project, I don't use it for anything in my own dashboards - but let me dust it off and see what I can find...

2 Likes

I haven't forgotten about this -- you could play with the "Preferred image resolution" preferences to match your dashboard tile size, this will work to statically resize the images. Doesn't help if you have video clips, though.

Alternatively, I've restructured the html a bit to dynamically resize images inside the dashboard tile in a custom branch, feel free to try it out -- but this likely breaks the parsing applied by @jpage4500 in his native dashboard app. Again, no love for video clips yet.

There has to be some combination of HTML/CSS that accomplishes the desired goal -- haven't found it yet, though

I'm happy to update my app to support any changes you want to make. Just let me know!

Here's what I'm doing today if it helps at all.. I wanted to always show an image on the main dashboard and then if it was a video, play the video when the tile was opened full-screen.

  • pull out the image URL from the image attribute and load that image for the tile
  • look at mediaType attribute; if it's video and this is the main dashboard, I'm changing the URL to show an image only (I know this was what you were doing originally sorry!)
                            // change video URL to an image
                            // from "=dv" to "=w2048-h1024"
  • However, if it's a 'video' and this is a fullscreen tile I'm showing the video
  • In fullscreen mode, clicks to the right side of the screen will call next command and left side calls previous command

@dkilgore90 - I'm having an issue getting something to work and was wondering if you have any ideas. I already have 3 google photos integrations which I'm displaying on my dashboard.. 2 of them as large tiles and the other one as the background image. All of these had been working well for months.

Today I decided I'd replace the background images and use some Halloween themed ones so I removed all of the images from my Google Photos folder and then added a couple spooky ones.

I went to the Photos driver and hit Refresh but nothing happened. I then tried re-selecting the folder from the Photos hub app and still nothing.. I ended up removing the Hub app/driver and re-adding it but it's still not fetching any images. I even created a new Google Photos album to see if that was the issue.

I also don't see anything in the logs.. any ideas?

image
image

The app caches IDs/links to the photos in the selected album, and the refresh command on the device page simply pulls the next cached ID (functionally equivalent to next).

When changing the album (or its contents), you need to click the Load Photos from Album button on the App page in order to reload the cached IDs - otherwise if the "Refresh nightly" toggle is enabled, it will update automaticallt at 11pm.

I clicked on Load Photos button too yesterday (forgot to mention that as well). This morning the newly created photos driver still doesn't have an image set.

logs from hitting Load Photos on app and then 'next' on device:

logs from this morning:

Is there some extra debugging I can do to maybe see where something's going wrong?

I figured something out.. I modified the app driver to add the else() case below (last line in snippet below)

def handlePhotoGet(resp, data) {
...
        def respJson = resp.getJson()
        device = getChildDevice(state.deviceId)
        if (respJson?.mediaMetadata?.photo) {
            def w = imgWidth ?: 2048
            def h = imgHeight ?: 1024
            sendEvent(device, [name: 'image', value: '<img src="' + "${respJson.baseUrl}=w${w}-h${h}" + '" />'])
            sendEvent(device, [name: 'mediaType', value: 'photo'])
        } else if (respJson?.mediaMetadata?.video) {
            sendEvent(device, [name: 'image', value: '<video autoplay loop><source src="' + "${respJson.baseUrl}=dv" + '" type="' + "${respJson.mimeType}" + '"></video>'])
            sendEvent(device, [name: 'mediaType', value: 'video'])
        } else {
            log.warn("Unknown response: ${respJson}")
        }
    }
}

Now I'm seeing this else case printed out:

app:7662022-10-12 10:16:12.544 AMwarnUnknown response: [id:ANAJ_-sVT6eaKQnIPG7rNQ1MsMmVJUDzIZ1Op_gIb7b0W_uHFfEYDeWU1cfL8pCoaPfLPj9RucxfvdM5jJGK_kjMldz8OyNygQ, productUrl:https://photos.google.com/lr/photo/ANAJ_-sVT6eaKQnIPG7rNQ1MsMmVJUDzIZ1Op_gIb7b0W_uHFfEYDe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qdWnrJ8Ar4, mimeType:image/jpeg, mediaMetadata:[creationTime:2022-10-11T14:20:57Z, width:4618, height:3464, photo:[:]], filename:rafael-garcin-wlOv3cf41iE-unsplash.jpg]

You can open the URL's above (guessing they'll expire after some time though). They're of this image which I added:
image

last update.. I was able to get this to work by modifying the code just a little to always assume a photo. Not sure if it's going to break at some point in the future but at least for now it seems good. Just wanted to mention it in case it helps anyone else

def handlePhotoGet(resp, data) {
...
        if (respJson?.mediaMetadata?.video) {
            sendEvent(device, [name: 'image', value: '<video autoplay loop><source src="' + "${respJson.baseUrl}=dv" + '" type="' + "${respJson.mimeType}" + '"></video>'])
            sendEvent(device, [name: 'mediaType', value: 'video'])
        } else {
            def w = imgWidth ?: 2048
            def h = imgHeight ?: 1024
            sendEvent(device, [name: 'image', value: '<img src="' + "${respJson.baseUrl}=w${w}-h${h}" + '" />'])
            sendEvent(device, [name: 'mediaType', value: 'photo'])
        }
    }
}

Thanks for this - I see what is happening now. The mediaMetadata.photo is returning an empty object/map, so Groovy truth evaluates as false and skips the logic within that clause. I should simply check the existence of the key, instead of relying on Groovy evaluation of the value.

1 Like

Not sure what happened. I now get this

app:15302022-10-30 14:20:44.560 warnExcluded attribute image size of attribute > 1024 characters

when adding the device to the dashboard device list without even have it on the dashboard. Just add the google photo device to the dashboard app list. The dashboard when shows this instead of the photo
photo2

going into the device detail does show me the photo.
The app setting is this

Hmm, I see the same. Looks like Google has made their URLs longer such that it no longer fits within the 1024 char attribute limit for Hubitat dashboards... Will see what can be done to work around this...

1 Like

Any luck with this or anything I could do to help?

Haven't spent a ton of time on it... Conceptually would need to use a url shortener like tinyurl to stay under the dashboard 1024 char limit...

Food for thought - maybe I'll find some time to implement over the holidays: TinyURL.com - shorten that long URL into a tiny URL

@dkilgore90 - this is just a random request while I'm thinking of it. I have several Google Photo's apps installed and just wondering if there was an easy way to give each instance a name to differentiate between them. Or, maybe 1 app that can manage multiple child devices (I imagine that's more work though)

Anyway, it's not a big deal by any means.. this app/driver has worked great for me for a long time now!!

Try the new App code just posted, v0.3.2

For now I have added a few lines to auto-update the name of each App/Device pair, when you click "Done" in the App page, with the selected album name -- this should hopefully make it easy to differentiate them.

Also included in this update are some changes to the image attribute when displaying an image -- to help combat any cropping effects, particularly on vertical images -- instead scaling to fit within a tile. Hopefully this doesn't add any significant rework on your end. Likely it is mostly irrelevant to native Hubitat dashboard users, since I haven't circled back on URL shortening :frowning:

1 Like

just got the chance to try this -- perfect! thanks for this!

Images still work for me in HD+ dashboard.

This seems new to me (unless I missed it above) - what does it do?
image