Skip to main content

Add your description here

Project description

Home Assistant MCP

smithery badge

A Model Context Protocol (MCP) integration for controlling Home Assistant devices using AI assistants.

Home Assistant MCP server

Overview

This MCP allows AI assistants to control your Home Assistant devices. It provides tools to:

  1. Search for entities in your Home Assistant instance
  2. Control devices (turn them on/off)
  3. Control light colors and brightness

Prerequisites

  • Python 3.11 or higher
  • Home Assistant instance running and accessible via API
  • Home Assistant Long-Lived Access Token

Installation

Installing via Smithery

To install Home Assistant Integration for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @hpohlmann/home-assistant-mcp --client claude

Manual Installation

  1. Clone this repository
  2. Set up a Python environment:
cd home-assistant
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -U pip
pip install uv
uv pip install -e .

Configuration

Get a Home Assistant Long-Lived Access Token

  1. Go to your Home Assistant instance
  2. Navigate to your profile (click on your username in the sidebar)
  3. Scroll down to "Long-Lived Access Tokens"
  4. Create a new token with a descriptive name like "MCP Integration"
  5. Copy the token (you'll only see it once)

Set up in Cursor AI

Add the following configuration to your MCP configuration in Cursor:

{
  "mcpServers": {
    "home_assistant": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/your/home-assistant-mcp",
        "run",
        "main.py"
      ],
      "env": {
        "HOME_ASSISTANT_TOKEN": "your_home_assistant_token_here"
      },
      "inheritEnv": true
    }
  }
}

Replace:

  • /path/to/your/home-assistant with the actual path to this directory
  • your_home_assistant_token_here with your Home Assistant Long-Lived Access Token

Home Assistant URL Configuration

By default, the MCP tries to connect to Home Assistant at http://homeassistant.local:8123.

If your Home Assistant is at a different URL, you can modify the HA_URL variable in app/config.py.

Usage

Once configured, you can use Cursor AI to control your Home Assistant devices:

  • Search for devices: "Find my living room lights"
  • Control devices: "Turn on the kitchen light"
  • Control light colors: "Set my living room lights to red"
  • Adjust brightness: "Set my dining room lights to blue at 50% brightness"

Light Control Features

The MCP now supports advanced light control capabilities:

  1. Color Control: Set any RGB color for compatible lights

    • Specify colors using RGB values (0-255 for each component)
    • Example: set_device_color("light.living_room", 255, 0, 0) for red
  2. Brightness Control: Adjust light brightness

    • Optional brightness parameter (0-255)
    • Can be combined with color changes
    • Example: set_device_color("light.dining_room", 0, 0, 255, brightness=128) for medium-bright blue

Troubleshooting

  • If you get authentication errors, verify your token is correct and has not expired
  • Check that your Home Assistant instance is reachable at the configured URL
  • For color control issues:
    • Verify that your light entity supports RGB color control
    • Check that the light is turned on before attempting to change colors

Future Capabilities

Dynamic Entity Exposure

The current implementation requires a two-step process to control devices:

  1. Search for entities using natural language
  2. Control the entity using its specific entity_id

A planned enhancement is to create a more dynamic way to expose entities to the control devices tool, allowing the AI to:

  • Directly control devices through more natural commands (e.g., "turn off the kitchen lights")
  • Cache frequently used entities for faster access
  • Support more complex operations like adjusting brightness, temperature, or other attributes
  • Handle entity groups and scenes more intuitively

This would significantly reduce the time to action and create a more seamless user experience when controlling Home Assistant devices through an AI assistant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_home_assistant-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_home_assistant-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_home_assistant-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_home_assistant-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_home_assistant-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e0e490a69d1cf75522aa56bd18379ae320e767d08bf1632d1771f787e386ef3
MD5 48f56ba3255a8de4ed8a74c9e457fc9d
BLAKE2b-256 8010c293e9dd61701441499db1f510267660943371769f9c218c176f8227b297

See more details on using hashes here.

File details

Details for the file iflow_mcp_home_assistant-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_home_assistant-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_home_assistant-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8788284f74ff38a97324de7c7fbcf40aa705ca6c7b2c9668c7c91889f47d694e
MD5 60b60d18ff85714510d1de04bd29e3cb
BLAKE2b-256 651064ee12de1455524c59e2eaddcefd278cc3d214945179756561023116aeb7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page