{"id":35882113,"url":"https://github.com/stephengolub/ha-opencode","last_synced_at":"2026-01-21T20:02:47.788Z","repository":{"id":332416732,"uuid":"1130060112","full_name":"stephengolub/ha-opencode","owner":"stephengolub","description":"Home Assistant integration for OpenCode AI coding assistant","archived":false,"fork":false,"pushed_at":"2026-01-21T00:21:56.000Z","size":156,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-21T11:03:07.752Z","etag":null,"topics":["custom-component","hacs","home-assistant","homeassistant-integration","opencode"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephengolub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-08T01:15:01.000Z","updated_at":"2026-01-21T00:22:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stephengolub/ha-opencode","commit_stats":null,"previous_names":["stephengolub/ha-opencode"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/stephengolub/ha-opencode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephengolub%2Fha-opencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephengolub%2Fha-opencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephengolub%2Fha-opencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephengolub%2Fha-opencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephengolub","download_url":"https://codeload.github.com/stephengolub/ha-opencode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephengolub%2Fha-opencode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28641293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T18:04:35.752Z","status":"ssl_error","status_checked_at":"2026-01-21T18:03:55.054Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-component","hacs","home-assistant","homeassistant-integration","opencode"],"created_at":"2026-01-08T18:05:43.380Z","updated_at":"2026-01-21T20:02:47.783Z","avatar_url":"https://github.com/stephengolub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenCode Home Assistant Integration\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/assets/brand/opencode-wordmark-dark.png\"\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"docs/assets/brand/opencode-wordmark-light.png\"\u003e\n    \u003cimg alt=\"OpenCode\" src=\"docs/assets/brand/opencode-wordmark-light.png\" width=\"300\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eUnofficial Home Assistant Integration for OpenCode\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://stephengolub.github.io/ha-opencode\"\u003e\u003cimg src=\"https://img.shields.io/badge/docs-GitHub%20Pages-blue\" alt=\"Documentation\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/stephengolub/ha-opencode/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/stephengolub/ha-opencode\" alt=\"GitHub Release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/hacs/integration\"\u003e\u003cimg src=\"https://img.shields.io/badge/HACS-Custom-orange.svg\" alt=\"HACS\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n\u003e **Note:** This is an **unofficial** community project and is not affiliated with, endorsed by, or supported by OpenCode or Anomaly. OpenCode branding is used in accordance with their [brand guidelines](https://opencode.ai/brand).\n\n---\n\nA native Home Assistant integration for [OpenCode](https://opencode.ai), the AI coding assistant. Monitor and control your OpenCode sessions directly from Home Assistant.\n\n**[Full Documentation](https://stephengolub.github.io/ha-opencode)** | **[OpenCode Plugin](https://github.com/stephengolub/opencode-homeassistant)**\n\n## Features\n\n- **Native Integration**: Direct WebSocket connection to OpenCode - no MQTT broker required\n- **Secure Pairing**: Simple pairing flow with one-time codes\n- **Session Monitoring**: Track session state, model, tokens, cost, and activity\n- **Permission Handling**: Approve or reject permission requests from Home Assistant\n- **Send Prompts**: Send prompts to OpenCode from automations or the Lovelace card\n- **Auto-reconnect**: Persistent connection with automatic reconnection\n- **Lovelace Card**: Beautiful card for viewing and interacting with sessions\n- **Blueprints**: Ready-to-use automations for mobile notifications\n\n## Requirements\n\n- Home Assistant 2024.1 or later\n- [OpenCode](https://opencode.ai) with the [opencode-homeassistant](https://github.com/stephengolub/opencode-homeassistant) plugin installed\n\n## Installation\n\n### HACS (Recommended)\n\n1. Open HACS in Home Assistant\n2. Go to \"Integrations\" section\n3. Click the three dots menu \u003e \"Custom repositories\"\n4. Add `https://github.com/stephengolub/ha-opencode` as \"Integration\"\n5. Search for \"OpenCode\" and install\n6. Restart Home Assistant\n\n### Manual Installation\n\n1. Download the [latest release](https://github.com/stephengolub/ha-opencode/releases)\n2. Extract `custom_components/opencode` to your Home Assistant `config/custom_components/` folder\n3. Copy `frontend/dist/opencode-card.js` to `config/www/`\n4. Restart Home Assistant\n\n## Setup\n\n### 1. Add the Integration\n\n1. Go to Settings \u003e Devices \u0026 Services\n2. Click \"Add Integration\"\n3. Search for \"OpenCode\"\n4. A pairing code will be displayed (e.g., `ABC12DEF`)\n\n### 2. Pair from OpenCode\n\nIn your OpenCode session, use the `ha_pair` tool:\n\n```\nPair with Home Assistant using:\n- URL: http://homeassistant.local:8123\n- Access Token: \u003cyour long-lived access token\u003e\n- Code: ABC12DEF\n```\n\nTo create a long-lived access token:\n1. Go to your Home Assistant profile (click your name in the sidebar)\n2. Scroll to \"Long-Lived Access Tokens\"\n3. Click \"Create Token\"\n\n### 3. Add the Lovelace Card\n\nAdd the card resource:\n\n**Via UI:**\n1. Go to Settings \u003e Dashboards\n2. Click the three dots menu \u003e Resources\n3. Click \"Add Resource\"\n4. URL: `/local/opencode-card.js`\n5. Type: JavaScript Module\n\n**Via YAML** (in `configuration.yaml`):\n```yaml\nlovelace:\n  resources:\n    - url: /local/opencode-card.js\n      type: module\n```\n\n### 4. Install Blueprints (Optional)\n\nCopy the blueprints to your Home Assistant config:\n\n```bash\nmkdir -p config/blueprints/automation/opencode\ncp blueprints/automation/*.yaml config/blueprints/automation/opencode/\n```\n\nThen reload automations in Developer Tools \u003e YAML \u003e Reload Automations.\n\n## Entities\n\nThe integration creates these entities for each OpenCode session:\n\n| Entity | Type | Description |\n|--------|------|-------------|\n| `sensor.*_state` | Sensor | Session state (idle, working, waiting_permission, error) |\n| `sensor.*_session` | Sensor | Session title |\n| `sensor.*_model` | Sensor | Current AI model |\n| `sensor.*_current_tool` | Sensor | Currently executing tool |\n| `sensor.*_input_tokens` | Sensor | Total input tokens used |\n| `sensor.*_output_tokens` | Sensor | Total output tokens used |\n| `sensor.*_cost` | Sensor | Total session cost |\n| `sensor.*_last_activity` | Sensor | Last activity timestamp |\n| `binary_sensor.*_permission_pending` | Binary Sensor | Permission request pending |\n\n## Services\n\n### `opencode.send_prompt`\n\nSend a prompt to an OpenCode session.\n\n```yaml\nservice: opencode.send_prompt\ndata:\n  session_id: ses_abc123\n  text: \"Fix the bug in main.py\"\n  agent: code  # optional\n```\n\n### `opencode.respond_permission`\n\nRespond to a permission request.\n\n```yaml\nservice: opencode.respond_permission\ndata:\n  session_id: ses_abc123\n  permission_id: perm_xyz789\n  response: once  # once, always, or reject\n```\n\n### `opencode.get_history`\n\nRequest session history (response sent via event).\n\n```yaml\nservice: opencode.get_history\ndata:\n  session_id: ses_abc123\n```\n\n### `opencode.get_agents`\n\nRequest available agents (response sent via event).\n\n```yaml\nservice: opencode.get_agents\ndata:\n  session_id: ses_abc123\n```\n\n## Blueprints\n\nThe integration includes ready-to-use blueprints for common automations.\n\n### State Notifications\n\n**File:** `blueprints/automation/opencode_state_notifications.yaml`\n\nSends mobile notifications when:\n- A task completes (idle after working)\n- Permission is required (with approve/reject buttons)\n- An error occurs\n\n**Features:**\n- Configurable notification service\n- Toggle notifications by type\n- Detailed permission info (type, title, pattern)\n- Android and iOS support\n\n### Permission Response Handler\n\n**File:** `blueprints/automation/opencode_permission_response.yaml`\n\nHandles taps on notification action buttons:\n- Extracts session and permission IDs\n- Calls `opencode.respond_permission` service\n- Works with both iOS and Android\n\n**Usage:**\n1. Install both blueprints\n2. Create an automation from \"State Notifications\" blueprint\n3. Create an automation from \"Permission Response\" blueprint\n4. Configure your mobile notification service\n\n## Lovelace Card\n\nAdd the card to a dashboard:\n\n```yaml\ntype: custom:opencode-card\ntitle: OpenCode Sessions\n```\n\n### Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `title` | string | \"OpenCode Sessions\" | Card title |\n| `device` | string | - | Device ID to pin to (shows detail view only) |\n| `working_refresh_interval` | number | 10 | Auto-refresh interval when working |\n\n### Examples\n\n**Basic card:**\n```yaml\ntype: custom:opencode-card\n```\n\n**Pinned to specific device:**\n```yaml\ntype: custom:opencode-card\ndevice: opencode_abc123def456\n```\n\n## Events\n\nThe integration fires these events for automations:\n\n| Event | Description |\n|-------|-------------|\n| `opencode_state_change` | Session state changed |\n| `opencode_permission_request` | New permission request (detailed info) |\n| `opencode_history_response` | History response received |\n| `opencode_agents_response` | Agents response received |\n\n### Example: Custom Permission Automation\n\n```yaml\nautomation:\n  - alias: \"OpenCode Permission Alert\"\n    trigger:\n      - platform: event\n        event_type: opencode_permission_request\n    action:\n      - service: notify.mobile_app\n        data:\n          title: \"{{ trigger.event.data.title }}\"\n          message: \u003e\n            Type: {{ trigger.event.data.type }}\n            Pattern: {{ trigger.event.data.pattern }}\n```\n\n## States\n\n| State | Description |\n|-------|-------------|\n| `idle` | Session is idle, waiting for input |\n| `working` | AI is actively working |\n| `waiting_permission` | Waiting for permission approval |\n| `error` | An error occurred |\n\n## Troubleshooting\n\n### Integration not connecting\n\n1. Check that OpenCode is running with the plugin installed\n2. Verify your access token is valid\n3. Check Home Assistant logs for connection errors\n\n### Entities not updating\n\n1. Verify the WebSocket connection is active (check integration status)\n2. Look for errors in Home Assistant logs\n3. Try restarting OpenCode and re-pairing\n\n### Card not appearing\n\n1. Verify the resource is loaded (Developer Tools \u003e Network)\n2. Check browser console for JavaScript errors\n3. Clear browser cache and reload\n\n### Notifications not working\n\n1. Ensure both blueprints are installed\n2. Check that the notification service is correct\n3. Verify mobile app is connected to HA\n\n## Building from Source\n\n```bash\n# Frontend (Lovelace card)\nnpm install\nnpm run build\n\n# Development with auto-rebuild\nnpm run dev\n```\n\n## Documentation\n\nFull documentation is available at **[stephengolub.github.io/ha-opencode](https://stephengolub.github.io/ha-opencode)**\n\n- [Installation](https://stephengolub.github.io/ha-opencode/installation/)\n- [Setup Guide](https://stephengolub.github.io/ha-opencode/setup/)\n- [Entities Reference](https://stephengolub.github.io/ha-opencode/entities/)\n- [Services Reference](https://stephengolub.github.io/ha-opencode/services/)\n- [Lovelace Card](https://stephengolub.github.io/ha-opencode/card/)\n- [Blueprints](https://stephengolub.github.io/ha-opencode/blueprints/)\n- [Automations](https://stephengolub.github.io/ha-opencode/automations/)\n- [Troubleshooting](https://stephengolub.github.io/ha-opencode/troubleshooting/)\n\n## Related Projects\n\n- [opencode-homeassistant](https://github.com/stephengolub/opencode-homeassistant) - OpenCode plugin (required) ([docs](https://stephengolub.github.io/opencode-homeassistant))\n- [OpenCode](https://opencode.ai) - AI coding assistant\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephengolub%2Fha-opencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephengolub%2Fha-opencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephengolub%2Fha-opencode/lists"}