mcp-hass について
mcp-hassは、Home AssistantのMCPサーバーを介して状態を確認し、スマートホーム機器を操作するスキルです。
主な機能
- 01Home Assistantのライブコンテキスト確認
- 02デバイスのオン・オフ
- 03サーバーURLとアクセストークンの設定
- 04利用可能なツールパラメーターの確認
活用シーン
- 01Home Assistantの現在の状態確認
- 02指定した照明やエリア内デバイスの操作
- 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 インスタンスにアクセスします。
- 設定 > デバイスとサービスに移動します。
- 右下の[+ 統合を追加]ボタンを選択します(https://my.home-assistant.io/redirect/config_flow_start?domain=mcp)。
- リストから 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 について
- 互換性を高めるため、コマンドを実行する際は
mcporterではなくnpx -y 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
コメント
Markdown 対応