geoph9 / hass-gshell-extension

A simple gnome shell extension for home assistant.
https://extensions.gnome.org/extension/4170/home-assistant-extension/
68 stars 15 forks source link

Extension crash on Gnome startup when HASS is not reacheable #61

Closed brenard closed 1 year ago

brenard commented 1 year ago

As discussed in #58, On my Debian Bookworm installation (Gnome 44 / GTK4), when I open my session without network, the extension crash and can't be restarted in parameters :

error

With bad network (on mobile data or bad Wifi for example), it worse because it try to reach HASS for every declared entities and each request blocked the startup for some long delay.

I partially fixed the problem by adding a try/catch in send_request() (around session.send_and_read() call) and setting a smaller timeout on session (using session.set_timeout()), but the main problem is these requests are synchronous. I mean the right way to fix this problem is to refactor the code to use Soup.Session.send_and_read_sync() and callbacks instead of the synchronous Soup.Session.send_and_read().

It's a quite long work I mean due to the impact of this change, so I prefer to ask you your idea on this problem before working on a PR.

geoph9 commented 1 year ago

Thanks for bringing this up. I guess you mean that we need to use `Soup.Session.send_and_read_async(), right? This would probably solve this issue, but we would need to very carefully design the callback function.

Is this something you can work on? I am very busy lately and I don't use HASS as much as I used to, so it's a bit difficult for me to test and debug.

brenard commented 1 year ago

Thanks for bringing this up. I guess you mean that we need to use `Soup.Session.send_and_read_async(), right? This would probably solve this issue, but we would need to very carefully design the callback function.

Yes, my bad, I'm of course talking about Soup.Session.send_and_read_async() :smile:

Is this something you can work on? I am very busy lately and I don't use HASS as much as I used to, so it's a bit difficult for me to test and debug.

Yes, I will try.

geoph9 commented 1 year ago

This is solved in #62

OctoNezd commented 1 year ago

image

Seems like it's still an issue. Happens for me after exiting sleep and on sometimes on startup.

geoph9 commented 1 year ago

I think you are using the extensions.gnome.org version of this which hasn't been updated, yet (due to some issues with formatting that I plan to solve within the next few days). Maybe try installing from the Releases page of this repo.

If that's not the case, then could you explain what ha.octonezd.me is? Is this the URI you trying to connect to?

OctoNezd commented 1 year ago

Its domain name of my home assistant instance. I will try installing version from releases page and check if issue is still there

geoph9 commented 1 year ago

Just FYI, I just uploaded a new version on e.g.o. and it should be accepted within the next couple of days.