The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(homeassistant): shared _close for ws/session teardown
Tekniuma6f1d3cd0af3
diff --git a/plugins/platforms/homeassistant/adapter.py b/plugins/platforms/homeassistant/adapter.pyindex a19b7048875..4d2df6cfb8a 100644--- a/plugins/platforms/homeassistant/adapter.py+++ b/plugins/platforms/homeassistant/adapter.py@@ -157,12 +157,15 @@ class HomeAssistantAdapter(BasePlatformAdapter):return Falsereturn True+ @staticmethod+ async def _close(obj) -> None:+ if obj and not obj.closed:+ await obj.close()+async def _cleanup_ws(self) -> None:- if self._ws and not self._ws.closed:- await self._ws.close()+ await self._close(self._ws)self._ws = None- if self._session and not self._session.closed:- await self._session.close()+ await self._close(self._session)self._session = Noneasync def disconnect(self) -> None:@@ -175,8 +178,7 @@ class HomeAssistantAdapter(BasePlatformAdapter):passself._listen_task = Noneawait self._cleanup_ws()- if self._rest_session and not self._rest_session.closed:- await self._rest_session.close()+ await self._close(self._rest_session)self._rest_session = Nonelogger.info("[%s] Disconnected", self.name)