自动化管理服务

通过Model Context Protocol (MCP)管理Home Assistant中的自动化配置,支持FTP客户端操作YAML文件并通过API触发重新加载。

  • by cavemancave
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 cavemancave/hass-automation-mcp

使用说明

家庭助理自动化管理MCP服务器

该项目用于通过模型上下文协议(MCP)管理家庭助理中的自动化。

解决方案是在其中封装一个FTP客户端,以列出/读取/写入YAML文件。

然后使用API触发重新加载。

使用指南

  1. 安装 紫外线 和 npm 如果尚未安装。

  2. 在家庭助理中安装FTP服务器
    设置->插件->FTP->安装

  3. 配置FTP服务器用户名和密码,启用操作权限和文件夹权限。
    设置->插件->FTP->配置

  4. 获取长寿命代币
    用户->安全->长寿令牌->创建

  5. 测试FTP连接

  6. 下载此仓库,配置环境文件

    git clone https://github.com/cavemancave/hass-automation-mcp.git
    cp .env.example .env
    # change .env
    
  7. 更改路径 claude_desktop_config.json,由检查员测试

    npx @modelcontextprotocol/inspector --config claude_desktop_config.json --server hass-automation-mcp
    

    连接->列出工具->列出文件->配置/->运行工具

  8. 合并 claude_desktop_config.json 进入LLM配置

故障排除

测试FTP连接

yadang@yadang-ubuntu:~$ ftp 192.168.1.22
Connected to 192.168.1.22.
220 Welcome to the Hass.io FTP service.
Name (192.168.1.22:yadang): yadang
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||30009|)
150 Here comes the directory listing.
drwxr-xr-x    2 ftp      ftp          4096 Jun 25 16:12 addons
drwxr-xr-x    2 ftp      ftp          4096 Jun 25 16:12 backup
drwxr-xr-x    9 ftp      ftp          4096 Jul 04 14:11 config
......
226 Directory send OK.
ftp> cd config
250 Directory successfully changed.
ftp> ls
229 Entering Extended Passive Mode (|||30002|)
150 Here comes the directory listing.
-rw-r--r--    1 ftp      ftp             8 Jun 25 16:45 .HA_VERSION
drwxr-xr-x    2 ftp      ftp          4096 Jun 25 16:45 .cloud
drwxr-xr-x    3 ftp      ftp          4096 Jul 07 07:36 .storage
-rw-r--r--    1 ftp      ftp           260 Jul 04 14:11 automations.yaml
......
226 Directory send OK.
ftp> get automations.yaml
local: automations.yaml remote: automations.yaml
229 Entering Extended Passive Mode (|||30004|)
150 Opening BINARY mode data connection for automations.yaml (260 bytes).
100% |*********************************************************************|   260        4.50 MiB/s    00:00 ETA
226 Transfer complete.
260 bytes received in 00:00 (729.61 KiB/s)
ftp> quit
221