hass-browser_mod icon indicating copy to clipboard operation
hass-browser_mod copied to clipboard

device in integration unavailable

Open bisquit2003 opened this issue 1 year ago • 4 comments

My Home Assistant version: 24.02.03 (but the problem was on all versions)

every time I restart my haos, my sonoff nspanel pro in integration goes to the unavailable status, I have to go to the panel, close the android ha app and open it again and then everything will return to normal. Is there anything we can do about it?

bisquit2003 avatar Feb 23 '24 20:02 bisquit2003

I am also seeing this. Looks like a fix was implemented previously (#527) but it is no longer working.

I can see the web socket connection is definitely re-opened after a restart because I am getting logs in Home Assistant, but the entities don't seem to update; they stay as Unavailable until you refresh the browser.

2024-03-18 11:03:30.490 INFO (MainThread) [custom_components.browser_mod.connection] LOG MESSAGE: Send:
2024-03-18 11:03:30.491 DEBUG (MainThread) [custom_components.browser_mod.browser] Manually updated Browser Mod Coordinator data

codemunkie15 avatar Mar 18 '24 11:03 codemunkie15

@thomasloven I tried to debug this a bit and it looks like the connected property in the data (set in BrowserModBrowser.open_connection()) is lost on Home Assistant restart, which then causes BrowserModEntity.available to always return false.

browser.py

def open_connection(self, hass, connection, cid):
        ....
        self.update(hass, {"connected": True})

entities.py

@property
    def available(self):
        return self._data.get("connected", False)

Furthermore, I added some extra logging in the python classes and I can see BrowserModBrowser.close_connection() is called when Home Assistant restarts but the connection is never reopened with a call to BrowserModBrowser.open_connection(). Yet I am still receiving events from the browser in the websocket after a restart. Not sure what's happening here?

codemunkie15 avatar Mar 18 '24 13:03 codemunkie15

Bump

Flintr avatar Jun 28 '24 13:06 Flintr

Same issues. Looked through #527 and #405, both of which are marked as fixed but neither with any information about what fixed it. Would love to have browsermod survive a HA restart

dovy6 avatar Jul 30 '24 14:07 dovy6