mcp-hass
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHome Assistant
Home Assistant
Control Home Assistant smart home and query states using MCP protocol.
通过MCP协议控制Home Assistant智能家居设备并查询其状态。
Prerequisites
前提条件
Enable MCP server in Home Assistant:
- Browse to your Home Assistant instance.
- Go to Settings > Devices & services.
- In the bottom right corner, select the + Add Integration button.
- From the list, select Model Context Protocol.
- Follow the instructions on screen to complete the setup.
在Home Assistant中启用MCP服务器:
- 访问你的Home Assistant实例。
- 进入“设置 > 设备与服务”。
- 在右下角,点击+ 添加集成按钮。
- 从列表中选择“Model Context Protocol”。
- 按照屏幕上的说明完成设置。
Config
配置
When prompted that the MCP server does not exist, remind the user to configure the and environment variables by executing the following command to add the configuration:
HASS_BASE_URLHASS_ACCESS_TOKENshell
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}"当提示MCP服务器不存在时,提醒用户执行以下命令配置和环境变量以添加配置:
HASS_BASE_URLHASS_ACCESS_TOKENshell
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}"Usage
使用方法
shell
undefinedshell
undefinedGet states
获取设备状态
npx -y mcporter call home-assistant.GetLiveContext
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")
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"])
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.
brightness:灯光亮度百分比,0为关闭,100为最亮。
color: Name of color
color:颜色名称
npx -y mcporter call home-assistant.HassLightSet(name: "Bedroom Light", brightness: 50)
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.
percentage:风扇转速百分比,0为关闭,100为最高速。
npx -y mcporter call home-assistant.HassFanSetSpeed(name: "Fan", area: "Bedroom", percentage: 80)
Execute the following command to learn about specific usage methods:
- `npx -y mcporter list home-assistant --schema --all-parameters`npx -y mcporter call home-assistant.HassFanSetSpeed(name: "Fan", area: "Bedroom", percentage: 80)
执行以下命令了解具体使用方法:
- `npx -y mcporter list home-assistant --schema --all-parameters`About mcporter
mcporter关于mcporter
mcporter- To improve compatibility, use instead of
npx -y mcporterwhen executing commands.mcporter - https://github.com/steipete/mcporter/raw/refs/heads/main/docs/call-syntax.md
- https://github.com/steipete/mcporter/raw/refs/heads/main/docs/cli-reference.md
- 为提升兼容性,执行命令时请使用而非
npx -y mcporter。mcporter - https://github.com/steipete/mcporter/raw/refs/heads/main/docs/call-syntax.md
- https://github.com/steipete/mcporter/raw/refs/heads/main/docs/cli-reference.md