本帖最后由 laojimigu 于 2025-5-29 05:26 编辑
我也遇到了重启后可用工具变少的问题,猜测是由于集成启动早于那些带实体的集成而造成的,尝试改了一下代码,目前看起来似乎可行
修改custom_components/ws_mcp_server/__init__.py中的async_setup_entry方法
async def async_setup_entry(hass: HomeAssistant, entry: WsMCPServerConfigEntry) -> bool:
"""Set up Model Context Protocol Server from a config entry."""
async def _system_started(event):
entry.runtime_data = SessionManager()
await websocket_transport.async_setup_entry(hass,entry)
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, _system_started)
return True
开头得导入一下常量
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|