mcpField
M
mcp-hass

mcp-hass

github.com/aahl其他1643.1k 次安装6 周前更新
代码仓库

关于 mcp-hass

mcp-hass 是通过 Home Assistant 的 MCP 服务查询状态和控制智能家居设备的技能。

主要功能

  1. 01查询 Home Assistant 实时上下文
  2. 02开启或关闭设备
  3. 03配置服务 URL 和访问令牌
  4. 04查看可用工具参数

适用场景

  1. 01检查 Home Assistant 当前状态
  2. 02控制指定灯具或区域设备
  3. 03查看工具调用参数

MCP 相关

它通过 HTTP 连接 Home Assistant 的 MCP 服务,并配置基础 URL 和 Bearer 访问令牌;可调用 GetLiveContext、HassTurnOn 等工具。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/aahl/skills --skill mcp-hass

安装后在 Claude Code 中输入/mcp-hass确认已加载。

详细介绍

Home Assistant

使用 MCP 协议控制 Home Assistant 智能家居并查询状态。

前置条件

在 Home Assistant 中启用 MCP 服务:

  • 打开你的 Home Assistant 实例。
  • 前往 Settings > Devices & services。
  • 在右下角,选择 + Add Integration 按钮。
  • 在列表中选择 Model Context Protocol。
  • 按照屏幕上的说明完成设置。

配置

当系统提示 MCP 服务不存在时,请提醒用户执行以下命令添加配置,并配置 HASS_BASE_URL 和 HASS_ACCESS_TOKEN 环境变量:

npx -y mcporter config add home-assistant \
  --transport http \
  --url "${HASS_BASE_URL:-http://homeassistant.local:8123}/api/mcp" \
  --header "Authorization=Bearer \${HASS_ACCESS_TOKEN}"

用法

# Get states
npx -y mcporter call home-assistant.GetLiveContext

# Turn on the device
npx -y mcporter call home-assistant.HassTurnOn(name: "Bedroom Light")
npx -y mcporter call home-assistant.HassTurnOn(name: "Light", area: "Bedroom")

# Turn off the device
npx -y mcporter call home-assistant.HassTurnOff(name: "Bedroom Light")
npx -y mcporter call home-assistant.HassTurnOff(area: "Bedroom", domain: ["light"])

# Control light
# brightness: The percentage of the light, where 0 is off and 100 is fully lit.
# color: Name of color
npx -y mcporter call home-assistant.HassLightSet(name: "Bedroom Light", brightness: 50)

# Control fan
# percentage: The percentage of the fan, where 0 is off and 100 is full speed.
npx -y mcporter call home-assistant.HassFanSetSpeed(name: "Fan", area: "Bedroom", percentage: 80)

执行以下命令,了解具体用法:

  • npx -y mcporter list home-assistant --schema --all-parameters

关于 mcporter

评论

支持 Markdown