Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0f4daaa
Merge main back into staging
github-actions[bot] Oct 26, 2026
ee3d01e
add guide on adding Scaleway as an opencode provider
ftschindler Oct 26, 2026
4d8821f
add guide on pinning an AUR package with a paru PKGBUILD repo
ftschindler Oct 27, 2026
15b5bd1
Name keyring service attributes after the tool, not the server
ftschindler Oct 28, 2026
30f3e10
add finding on a phantom touch pinning the pointer to the system tray
ftschindler Oct 29, 2026
05d68a7
Add tool page for wshm
ftschindler Oct 30, 2026
80f0048
Add finding on wshm's open-core split, and link it from the tool page
ftschindler Oct 30, 2026
abc46e8
Add rootless Docker tool page, two findings on disk space and Compose…
ftschindler Nov 10, 2026
98b036d
add tool page: Inference Manager (Canonical)
ftschindler Nov 16, 2026
daec8ef
Add Arch sudo fix to Inference Manager tool page
ftschindler Nov 16, 2026
a9c545f
Add Python type annotation investigation, type-checker-in-CI principl…
ftschindler Nov 17, 2026
2d50aac
Add feed-reading wish and Miniflux decision
ftschindler Nov 17, 2026
76e02d0
Add finding on the Plasma lock screen logging a failed login on every…
ftschindler Nov 17, 2026
0250a54
add tool page Math*DB MCP (MaRDI4NFDI) and finding on missing MCP too…
ftschindler Nov 18, 2026
cc2db2c
Merge main back into staging
github-actions[bot] Nov 23, 2026
6ff9b5b
add Lenovo ThinkPad X390 Yoga hardware page
ftschindler Nov 15, 2026
870f28e
Add investigation: agentic AI + Home Assistant integration (skills + …
ftschindler Nov 24, 2026
71d0a31
Add blueprint: Home Assistant agent integration via MCP (voska/hass-m…
ftschindler Nov 24, 2026
97f54a3
Add finding: Autologon set up with Autologon.exe is gone after the ne…
ftschindler Nov 30, 2026
c3b9bcc
Add finding on the Wayland freeze after an i915 GPU hang, and a draft…
ftschindler Dec 3, 2026
2c6ce49
Revise the xe guide after carrying it out: VA-API driver, xe as defau…
ftschindler Dec 3, 2026
a7880b1
Add investigation: LeOn Audio-Aufnahme Sicherheitsanalyse
ftschindler Dec 3, 2026
4b3762e
Fix OKF type field and markdownlint issues in agentic_ai_homeassistan…
ftschindler Dec 3, 2026
f85caa1
Fix OKF type field and markdownlint issues in home_assistant_agent_in…
ftschindler Dec 3, 2026
fa2846a
Add trailing newline to investigations/index.md (end-of-file-fixer)
ftschindler Dec 3, 2026
698d580
Cite declared source in pin_an_aur_package guide
ftschindler Dec 3, 2026
09fe067
Add guide: Harden SSH after the NSA post-quantum advisory
ftschindler Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 336 additions & 0 deletions docs/blueprints/home_assistant_agent_integration_via_mcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
---
type: Blueprint
title: Home Assistant Agent Integration via MCP
description: Full remote agent access to Home Assistant through MCP server and best-practices skill, without oh-my-openagent
status: implemented
generated:
by: opencode/qwen3.5-397b-a17b
at: 2026-11-24
verified:
at: null
by: null
tags:
- home-automation
- mcp
- agent-integration
- smart-home
- blueprint
references:
- ../investigations/agentic_ai_homeassistant_integration.md
- https://github.com/voska/hass-mcp
- https://github.com/homeassistant-ai/skills
---

## Home Assistant Agent Integration via MCP

### Overview

This blueprint delivers **full remote agent access** to a Home Assistant instance through two components:

1. **MCP Server** (`voska/hass-mcp`) - Real-time WebSocket connection for device control, Lovelace editing, history queries
2. **Best-Practices Skill** (`homeassistant-ai/skills`) - Read-only knowledge that prevents anti-patterns (native HA constructs over templates)

**What the agent can do:**

- Read all entity states in real-time
- Control lights, locks, climate, media, covers, fans, switches
- Edit Lovelace dashboards with live preview + automatic backups
- Query historical data and statistics
- List and trigger automations
- All via secure MCP layer (token never exposed to agent)

**What this blueprint does NOT require:**

- oh-my-openagent plugin (not used here)
- Docker (runs via `uvx` directly)
- Root access (fully rootless)
- Public internet exposure (local LAN only)

## Prerequisites

| Requirement | Why | How to verify |
| ------------- | ----- | --------------- |
| Home Assistant instance (2024.x+) | MCP server connects via WebSocket API | `https://your-ha.local:8123` reachable |
| Long-lived access token | Authentication for MCP→HA connection | Profile → Security → Create token |
| opencode with MCP support | Loads MCP servers from config | `opencode --version` ≥ 2.x |
| `uv` package manager | Runs `hass-mcp` without Docker | `uv --version` |
| Local network access | HA must be reachable from opencode machine | `curl http://ha.local:8123/api/` |

### Create Long-Lived Access Token

1. Open Home Assistant UI
2. Click your user profile (bottom left)
3. Go to **Security** tab
4. Click **Create Long-Lived Access Token**
5. Name it `opencode-agent` (or similar)
6. Copy the token (starts with `eyJ...`)
7. Store securely - valid for 10 years, full user permissions

## Installation

### Step 1: Install the Skill (already done)

The best-practices skill is already installed via akit:

```bash
# Already executed:
# uvx --from federated-agent-kits akit add --global homeassistant-ai/skills home-assistant-best-practices
```

**Location:** `/home/felix/.agents/skills/home-assistant-best-practices/` (16 files)

**What it does:** Teaches native HA patterns - e.g., use `condition: numeric_state` instead of `condition: template`, which HA validates at load time rather than failing silently at runtime.

### Step 2: Configure MCP Server

**Config file:** `~/.config/opencode/opencode.jsonc`

The MCP entry has been added:

```jsonc
"hass-mcp": {
"type": "local",
"command": ["uvx", "hass-mcp@latest"],
"env": {
"HA_URL": "{file:.env.hass_mcp_voska}",
"HA_TOKEN": "{file:.env.hass_mcp_voska}"
},
"enabled": true
}
```

**Env file:** `~/.config/opencode/.env.hass_mcp_voska`

```bash
HA_URL=http://homeassistant.local:8123
HA_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...your_token_here
```

**Action required:** Fill in your actual `HA_URL` and `HA_TOKEN` in the env file.

### Step 3: Restart opencode

```bash
# Quit opencode if running
# Then restart:
opencode
```

The MCP server starts automatically on first agent request that needs HA access.

## Configuration Details

### Network Considerations

**Local LAN (this blueprint):**

- `HA_URL` = `http://homeassistant.local:8123` or `http://192.168.x.x:8123`
- opencode machine must be on same network as HA
- No firewall changes needed
- Token transmitted unencrypted (LAN only)

**Remote via Home Assistant Cloud:**

- `HA_URL` = `https://your-url.nabu.casa`
- Requires HA Cloud subscription (~$5/month)
- Encrypted tunnel, no port forwarding
- Same config, just different URL

**Remote via VPN (Tailscale/ZeroTier):**

- `HA_URL` = `http://100.x.y.z:8123` (Tailscale IP)
- VPN must be active on opencode machine
- Encrypted, no public exposure

### Security Model

| Layer | Protection |
| ------- | ------------ |
| **Token storage** | `.env.hass_mcp_voska` (mode 600, gitignored) |
| **Token exposure** | Never sent to agent - MCP holds it |
| **Network** | Local LAN only (unless HA Cloud/VPN) |
| **Rate limiting** | None built-in - agent self-limits |
| **Permissions** | Full user permissions - use non-admin user if concerned |
| **Audit trail** | HA logs all actions, attributed to token owner |

### File Permissions

```bash
chmod 600 ~/.config/opencode/.env.hass_mcp_voska
```

The env file is already set to mode 600 (owner read/write only).

## Capabilities

### What the Agent Can Do

| Capability | Tool | Example |
| ------------ | ------ | --------- |
| **Read entity state** | `get_entity` | "What's the temperature in the living room?" |
| **List entities** | `list_entities` | "Show me all lights in the bedroom" |
| **Control devices** | `entity_action` | "Turn off all kitchen lights" |
| **Call any service** | `call_service_tool` | "Activate the 'Movie Night' scene" |
| **Edit Lovelace** | `add_card`, `update_card`, etc. | "Add a temperature card to the dashboard" |
| **Query history** | `get_history`, `get_statistics` | "Show me energy usage last week" |
| **List automations** | `list_automations` | "What automations run at sunset?" |
| **Trigger automation** | `call_service_tool` | "Run the 'Good Morning' automation" |

### Lovelace Dashboard Editing

The voska MCP server supports **live Lovelace editing**:

- `list_dashboards` - List all dashboards (storage mode only)
- `get_dashboard_config` - Get full dashboard config
- `add_card` / `update_card` / `remove_card` / `move_card` - Edit cards
- `list_view_sections` - List sections in a "sections"-type view
- `add_view` / `remove_view` / `update_view` - Edit views

**Automatic backups:** Before every write, the current config is saved to `~/.hass-mcp/dashboard-backups/`. Can restore via `restore_dashboard`.

**Important:** Only works with **storage-mode** dashboards (UI-managed). YAML-mode dashboards must be edited directly.

## Testing

### First Commands to Verify Connection

After filling in the env file and restarting opencode, try these:

1. **Basic connectivity:**

```text
What's the current state of the sun entity?
```

Expected: Returns `above_horizon` or `below_horizon`

2. **List entities:**

```text
List all lights in my home
```

Expected: List of `light.*` entities with states

3. **Read a sensor:**

```text
What's the temperature in the living room?
```

Expected: Current temperature from your sensor

4. **Control a device:**

```text
Turn on the hallway light at 50% brightness
```

Expected: Light turns on, agent confirms

5. **Query history:**

```text
Show me the living room temperature over the last 24 hours
```

Expected: Historical data points

### Troubleshooting Connection

**"Connection refused" or "Cannot connect to HA":**

- Verify `HA_URL` is correct and reachable: `curl http://your-ha:8123/api/`
- Check HA is running: `systemctl status home-assistant@homeassistant` (if systemd)
- Ensure opencode machine is on same network

**"Invalid token" or "Unauthorized":**

- Re-create the long-lived token in HA
- Ensure no trailing whitespace in `.env.hass_mcp_voska`
- Token must be for an existing HA user

**"No Lovelace dashboards found":**

- Only **storage-mode** dashboards are editable
- YAML-mode dashboards must be edited directly
- Check: HA → Settings → Dashboards → see which are "Storage" vs "YAML"

**MCP server not starting:**

- Check opencode logs for MCP startup errors
- Verify `uv` is installed: `uv --version`
- Test manually: `uvx hass-mcp --help`

## Architecture

```text
┌─────────────────┐ ┌─────────────────┐ ┌──────────────────┐
│ opencode │────►│ voska/hass-mcp │────►│ Home Assistant │
│ (agent) │ MCP │ (uvx process) │ WS │ (local network) │
└─────────────────┘ └─────────────────┘ └──────────────────┘
│ │ │
│ HA_TOKEN in .env Long-lived token
│ (mode 600, never (full user perms)
│ exposed to agent)
│
└─ home-assistant-best-practices skill (read-only knowledge)
/home/felix/.agents/skills/home-assistant-best-practices/
```

**Key properties:**

- MCP server runs as local process (no Docker)
- Token stored in env file, read by MCP only
- Agent never sees token - calls MCP tools
- Skill guides *what* to write, MCP executes *how*

## Maintenance

### Updating the MCP Server

```bash
# MCP server updates automatically via @latest in config
# To force update, clear uv cache:
uv cache clean
```

### Updating the Skill

```bash
# Skill is pinned by akit to commit 166defa
# To update:
uvx --from federated-agent-kits akit update --global home-assistant-best-practices
```

### Rotating the Token

If the token is compromised:

1. Revoke old token: HA → Profile → Security → Revoke
2. Create new token
3. Update `.env.hass_mcp_voska`
4. Restart opencode

### Backups

**Lovelace backups:** Automatic, stored in `~/.hass-mcp/dashboard-backups/`

**HA instance backups:** Use HA's built-in backup system (Settings → System → Backups)

**Config backups:** The `.env.hass_mcp_voska` file is your responsibility - back it up securely.

## Related

- [Investigation: Agentic AI and Home Assistant Integration](../investigations/agentic_ai_homeassistant_integration.md) - full survey of skills and MCP servers
- [What an MCP server can be, and who can reach one](../investigations/mcp_server_entry_points_and_transports.md) - MCP architecture patterns
- [voska/hass-mcp documentation](https://github.com/voska/hass-mcp) - upstream MCP server docs
- [homeassistant-ai/skills](https://github.com/homeassistant-ai/skills) - best-practices skill source

## Changelog

- **2026-11-24** - Initial blueprint, based on investigation findings
- Skill installed via akit (16 files rendered)
- MCP config added to `opencode.jsonc`
- Env file template created (`.env.hass_mcp_voska`)
- Awaiting user to fill in actual HA_URL and HA_TOKEN
1 change: 1 addition & 0 deletions docs/blueprints/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

The concrete, copyable artefact a decision produced.

- [Home Assistant Agent Integration via MCP](home_assistant_agent_integration_via_mcp.md) - full remote agent access to HA through MCP server and best-practices skill, without oh-my-openagent
- [MkDocs Material PKB publishing stack](mkdocs_material_pkb_publishing_stack.md) - the stack this site runs on, component by component, with the reasons attached
- [Sharing one knowledge bundle on two branches](sharing_one_knowledge_bundle_on_two_branches.md) - what a bundle looks like once several people file into it, and the published branch takes no direct pushes
1 change: 1 addition & 0 deletions docs/decisions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Listed oldest first, so the reasoning reads forward.
- [Teaching my agents to write like me](teaching_my_agents_to_write_better.md) - the three prose principles turned into a hook, a skill and an always-on digest, each reaching an audience the others miss
- [Adopting caveman at lite, without its init block](adopting_caveman_at_lite_without_its_init_block.md) - keeping the terseness skill and refusing the rule block its installer would have written into a file that already argues the other way
- [Adopting ponytail without its always-on ruleset](adopting_ponytail_without_its_always_on_ruleset.md) - taking the half of a skill that adds something, and why the plugin it would have collided with cannot be patched
- [Self-hosting Miniflux as a feed reader](self_hosting_miniflux_as_a_feed_reader.md) - two containers behind the existing Traefik, the server doubling as the sync, and RSSHub held back until a source needs it
Loading