360 Secure SkillHub
360 安全技能中心

🏠 Home Assistant via MCP protocol

基于 mcporter 调用 Home Assistant 的 MCP 服务器,支持查询设备状态,以及对灯、风扇等实体执行开关、亮度、颜色与风速控制。需在 Home Assistant 中启用 Model Context Protocol 集成,并配置 HASS_BASE_URL 与 HASS_ACCESS_TOKEN。

al-one
al-one
热度 97.03
最近更新 2026-05-11 16:01:18
分类:自动化依赖:代码执行 / MCP 服务 / 第三方 API应用场景:自动化脚本 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add mcp-hass
Metadata
name
mcp-hass
description
The skill for control Home Assistant smart home devices and query states using MCP protocol.
homepage
https://home-assistant.io/integrations/mcp
metadata
{"openclaw":{"emoji":"🏠","requires":{"anyBins":["mcporter","npx"],"env":["HASS_ACCESS_TOKEN","HASS_BASE_URL"]},"primaryEnv":"HASS_ACCESS_TOKEN","install":[{"id":"node","kind":"node","package":"mcporter","bins":["mcporter"],"label":"Install mcporter (node)"}]}}

Home Assistant

Control Home Assistant smart home and query states using MCP protocol.

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.

Usage

# Get states
mcporter call home-assistant.GetLiveContext

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

# Turn off the device
mcporter call home-assistant.HassTurnOff(name: "Bedroom Light")
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
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.
mcporter call home-assistant.HassFanSetSpeed(name: "Fan", area: "Bedroom", percentage: 80)

Execute the following command to learn about specific usage methods:

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

Config

When prompted that the MCP server does not exist, remind the user to configure the HASS_BASE_URL and HASS_ACCESS_TOKEN environment variables by executing the following command to add the configuration:

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

About mcporter