Update websocket_server.py

新增hass初始化
This commit is contained in:
c1pher 2025-03-14 00:37:11 +08:00 committed by GitHub
parent 3687e183f1
commit c48a4e1955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,7 @@ class WebSocketServer:
def __init__(self, config: dict):
self.config = config
self.logger = setup_logging()
self._vad, self._asr, self._llm, self._tts, self._music, self._memory, self.intent = self._create_processing_instances()
self._vad, self._asr, self._llm, self._tts, self._music, self._hass, self._memory, self.intent = self._create_processing_instances()
self.active_connections = set() # 添加全局连接记录
def _create_processing_instances(self):
@ -78,7 +78,7 @@ class WebSocketServer:
async def _handle_connection(self, websocket):
"""处理新连接,每次创建独立的ConnectionHandler"""
# 创建ConnectionHandler时传入当前server实例
handler = ConnectionHandler(self.config, self._vad, self._asr, self._llm, self._tts, self._music, self._memory, self.intent)
handler = ConnectionHandler(self.config, self._vad, self._asr, self._llm, self._tts, self._music, self._hass, self._memory, self.intent)
self.active_connections.add(handler)
try:
await handler.handle_connection(websocket)