Skip to content

magnusoverli/ha_opencode

Repository files navigation

🚀 HA OpenCode

AI-Powered Configuration Assistant for Home Assistant

Version Project Stage License Maintenance

aarch64 amd64

Transform your Home Assistant configuration with the power of AI

InstallationFeaturesDocumentationSupport


✨ About

HA OpenCode brings the revolutionary OpenCode AI coding agent directly into your Home Assistant instance. Experience intelligent configuration editing through natural language, advanced YAML assistance, and deep integration via the Model Context Protocol (MCP).

🎯 Key Features

🤖 AI-Powered Editing

Use natural language to modify your Home Assistant configuration. No more searching documentation - just ask!

🎨 Modern Web Terminal

Beautiful terminal with 10 professionally designed themes, accessible directly from your HA sidebar.

🔌 Provider Agnostic

Works with 75+ AI providers: Anthropic, OpenAI, Google, Groq, Ollama, and many more.

🔧 Deep MCP Integration

32 tools, 13 resources, and 6 guided prompts for comprehensive Home Assistant interaction.

💡 Intelligent LSP Support

Smart YAML editing with entity autocomplete, live hover information, deprecation warnings, and go-to-definition support.

🛡️ Safe Config Writing

Validated config pipeline with automatic backup/restore. Multi-layered checks are designed to prevent AI-written config from breaking your HA instance.


🌟 What is OpenCode?

OpenCode is an open-source AI coding agent that transforms how you interact with your codebase. It understands your files, executes commands, and helps you build and maintain software using natural language.

Think of it as your personal expert developer who:

  • 📖 Reads and understands your entire configuration
  • ✏️ Suggests and implements improvements
  • 🐛 Finds and fixes bugs automatically
  • 🚀 Implements new features on request
  • 💬 Explains complex configurations in plain English

🎭 Supported AI Providers

HA OpenCode works with 75+ AI providers. Choose the one that fits your needs:

🔥 Popular Providers (Click to expand)
Provider Available Models
🧠 Anthropic Claude 4 Opus, Claude 4 Sonnet, Claude 3.5 Sonnet, Claude 3.5 Haiku
💎 OpenAI GPT-4o, GPT-4 Turbo, o1, o1-mini, o3-mini
🌈 Google Gemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 Flash
☁️ AWS Bedrock Claude, Llama, Mistral (via AWS)
🔷 Azure OpenAI GPT-4, GPT-4 Turbo (Azure hosted)
Groq Llama 3, Mixtral (ultra-fast inference)
🎯 Mistral Mistral Large, Mistral Medium, Codestral
🦙 Ollama Local models (Llama, CodeLlama, Mistral, etc.)
🌐 OpenRouter 100+ models through single API
🤝 Together AI Llama, Mixtral, and open models
🔥 Fireworks AI Fast inference for open models
🚀 xAI Grok models
💫 Deepseek Deepseek Coder, Deepseek Chat

🎁 Free Tier - OpenCode Zen

Start immediately with OpenCode Zen - no API keys or subscriptions required! Get access to curated models optimized for coding tasks, perfect for trying HA OpenCode or for users who prefer not to manage their own API keys.

Simply run /connect and select OpenCode Zen to get started for free.


📦 Installation

Quick Install

  1. Add this repository to Home Assistant:

    Add Repository

    Or add manually

    Go to SettingsAdd-onsAdd-on StoreRepositories

    Add: https://github.com/magnusoverli/ha_opencode

  2. Install the add-on:

    • Find "HA OpenCode" in the add-on store
    • Click Install
  3. Start using it:

    • Start the add-on
    • Click Open Web UI (or use the sidebar)
    • Run opencode and use /connect to configure your AI provider

🛡️ Safety & Validation

This add-on has read/write access to your Home Assistant configuration directory.

HA OpenCode includes a multi-layered validation pipeline designed to prevent AI-written configuration from causing your Home Assistant to fail to start:

  • 🔍 Automatic config validation — every config write is validated through HA Core's own check before committing
  • ↩️ Automatic backup/restore — if validation fails, the original file is instantly restored
  • 🧪 Jinja2 template pre-validation — templates are tested through HA's engine before writing to disk
  • 📋 Deprecation scanning — 20+ patterns catch outdated syntax, auto-updated from GitHub
  • 🏥 HA Repairs integration — surfaces your installation's active deprecation warnings
  • ⚠️ Structural checks — catches missing triggers, actions, and other required fields

Additional best practices:

  • 💾 Always backup your configuration before significant changes
  • 👀 Review changes suggested by the AI before accepting them
  • 📝 Use version control (git) when possible for easy rollback

📚 Documentation

Comprehensive documentation is available covering all features:


🎯 Quick Start Examples

Once installed and connected to an AI provider, try these commands:

# Create a new automation
"Create an automation that turns on lights when motion is detected"

# Review your configuration
"Check my configuration.yaml for any issues"

# Add sensors
"Add a template sensor to track my total energy usage"

# Get entity information
"What's the current state of all my lights?"

# Troubleshoot
"Why isn't my bedroom motion sensor triggering automations?"

# Analyze history
"Show me temperature trends for the past 24 hours"

🤝 Support

Need help? We've got you covered:

💬 Discord

Join OpenCode Discord

Community support & discussions

📖 Documentation

OpenCode Docs

Comprehensive guides & tutorials

🐛 Issues

GitHub Issues

Bug reports & feature requests


🌟 Contributing

We love contributions! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🔧 Create your feature branch (git checkout -b feature/amazing-feature)
  3. 💾 Commit your changes (git commit -m 'Add amazing feature')
  4. 📤 Push to the branch (git push origin feature/amazing-feature)
  5. 🎉 Open a Pull Request

Contributions of all kinds are welcome — feel free to open a PR!


👏 Authors & Contributors

Magnus Overli
Magnus Overli

Creator & Maintainer

All Contributors

See the contributors page for the full list of amazing people who have helped make this project better!


📜 License

This is free and unencumbered software released into the public domain - see the UNLICENSE file for details.


⭐ If you find HA OpenCode helpful, please star this repository!

Made with ❤️ for the Home Assistant community

InstallationFeaturesDocumentationSupport