Daanoz / ha-google-photos

Home Assistant Google Photos integration
MIT License
84 stars 5 forks source link

Entities unavailable followed by apparent reset #14

Closed goodlucknow closed 1 year ago

goodlucknow commented 1 year ago

Version of the custom_component

V0.4.4

Configuration

configured through UI

Describe the bug

All sensors seem to become unavailable on occasion. Once they become available again, the current photo resets to the same one every time. Sometimes it seems like opeing the entity/device page in the frontend can trigger this. The debug logs do not seem to show any activity during the event,yet the device logs do as in screenshots attached. Use case: I'm using this intergration with wallpanel to have a screensaver photo that updates daily at 04:00 via a service call automation. This seems to work perfectly, but then at some stage during the day the displayed photo reverts to the original one. This hapened with the previous version as well as latest.

Debug log

2023-03-30 03:29:26.838 DEBUG (SyncWorker_6) [googleapiclient.discovery] URL being requested: GET https://photoslibrary.googleapis.com/v1/mediaItems/AMrVKRFzNtwJT4tchGK9ypqykPAvXAjWb1Z06JRjxrMLhBiQBCA-KpEabkpgvQom6CyfoZX9P5vJbjhR4xDLs3UV2WYmcoqLDQ?alt=json
2023-03-30 03:29:43.202 DEBUG (SyncWorker_3) [googleapiclient.discovery] URL being requested: GET https://photoslibrary.googleapis.com/v1/mediaItems/AMrVKREQ8Oog8B1mt0Uqg3e9d7_3yqQJorVfF2Y-tbQr0nGZGYbYl10DKS2VNwQkok5CkjndYjDI?alt=json
2023-03-30 03:29:52.456 DEBUG (SyncWorker_4) [googleapiclient.discovery] URL being requested: GET https://photoslibrary.googleapis.com/v1/mediaItems/AMrVKREg4SH2t61HgJRPf0-y5nX_2gS8mrx3oFwBa_SfVlvsdwLkPkJthi8Az6mJfxWqtYIMs4KglLa0kZdqWP5sMl9LMDqOvw?alt=json

Add your logs here.
Screenshot 2023-03-30 at 03 47 27 Screenshot 2023-03-30 at 03 48 35
goodlucknow commented 1 year ago

Thanks for the work on this integration! Having a curious issue as outlined above. The associated entities, and thus the displayed picture, seem to reset multiple times a day. Any ideas as to how I might better debug this issue?

goodlucknow commented 1 year ago

Perhaps worth noting: when I try to configure the settings from the integrations page, album selection works fine, but the settings option seems like it's missing something from the description? The only option available is metadata. The update interval can of course be set through the provided entity but it reads like a similar option should display here?

Screenshot 2023-03-31 at 00 15 24
Daanoz commented 1 year ago

Hmm, I've seen it happen once or twice as well. It looks like there is a moment where Home Assistant marks it as unavailable, but I can't really seem to figure out what's the trigger. I'll do some debugging to find it. Loading the device page requests an image to be shown as thumbnail for the image, that could trigger state updates, so my guess is that's the key to the issue.

For the last issue with the options, I'll change that, it's a left over from when the configuration was not per album but for the entire integration.

goodlucknow commented 1 year ago

Thanks for the attention on it. It seems to happen quite regularly on my setup, every few hours. I wonder is there a connectivity issue my end but whatever the cause, is there any way for the entity states to persist after an unavailability event? Or perhaps an option to have it not poll for updates unless requested? It strikes me that (just in my use case), the integration should request the image at 4am and the image would remain locally until requested again?

It makes sense about the thumbnail triggering it - on that note I have noticed quite a lag between the thumbnail updating after an image update, while testing different configurations of how often wallpanel should check the entity for updates.

Forgive me if I'm talking nonsense, just thinking out loud about it...

Daanoz commented 1 year ago

Feel free to think along, it's always helpful to read how others interpret what you made!

Did some debugging over night, it probably has to do with Google's OAuth token expiring in combination with the way I'm currently handling adding new albums, so I'll need to make some changes there.

The integration already tries to reduce reloading data as much as possible, in general it will only update data if you actually request an image. So if the interval is one minute, but you don't have any dashboards opened nothing will happen right up to the moment you reopen a dashboard (or look at the device page, due to the thumbnail that is shown there).

Ah, and for the thumbnail not updating, I noticed that too, but that's a home assistant thing, it just doesn't do that. I guess it makes sense as it's normally used for camera feeds, and no one will probably look at the small thumbnail very long.

goodlucknow commented 1 year ago

thanks @Daanoz for fixing this. Updated to the latest now and looking forward to trying it out.

goodlucknow commented 1 year ago

My issue appears to be solved. Thanks so much. The only other query I'd have on it is that after a home assistant restart, that same photo is recalled, which makes me think the initial photo selection doesnt adhere to the "random" setting. But it's an easy workaround to call a new photo after a restart via automation so it's not a huge issue, and perhaps by design. Thanks again.

Daanoz commented 1 year ago

Yeah, that's default behavior, the first photo that it loads is actually whatever photo you have set as cover photo in Google Photos.

goodlucknow commented 1 year ago

ah, thanks for clarifying that! I hadn't realised. That's perfect I can just set a new cover photo, as i've grown to resent the previous one during troubleshooting 😄