thomasloven / hass-browser_mod

🔹 A Home Assistant integration to turn your browser into a controllable entity and media player
MIT License
1.24k stars 176 forks source link

device in integration unavailable #686

Open bisquit2003 opened 4 months ago

bisquit2003 commented 4 months ago

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?

codemunkie15 commented 3 months ago

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 commented 3 months ago

@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?

Flintr commented 3 days ago

Bump