{
  "schemaVersion": "1.0",
  "item": {
    "slug": "ha-integration-patterns",
    "name": "Ha Integration Patterns",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/usimic/ha-integration-patterns",
    "canonicalUrl": "https://clawhub.ai/usimic/ha-integration-patterns",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/ha-integration-patterns",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=ha-integration-patterns",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/ha-integration-patterns"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/ha-integration-patterns",
    "agentPageUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent",
    "manifestUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "The Problem",
        "body": "By default, HA services are \"fire-and-forget\" and return empty arrays []."
      },
      {
        "title": "The Solution (HA 2023.7+)",
        "body": "Register service with supports_response:\n\nfrom homeassistant.helpers.service import SupportsResponse\n\nhass.services.async_register(\n    domain, \n    \"get_full_config\", \n    handle_get_full_config,\n    schema=GET_CONFIG_SCHEMA,\n    supports_response=SupportsResponse.ONLY,  # ← KEY PARAMETER\n)\n\nCall with ?return_response flag:\n\ncurl -X POST \"$HA_URL/api/services/your_domain/get_full_config?return_response\""
      },
      {
        "title": "Response Handler",
        "body": "async def handle_get_full_config(hass: HomeAssistant, call: ServiceCall):\n    \"\"\"Handle the service call and return data.\"\"\"\n    # ... your logic ...\n    return {\"entities\": entity_data, \"automations\": automation_data}"
      },
      {
        "title": "HTTP View vs Service: When to Use Each",
        "body": "Use CaseUseDon't UseReturn complex dataHTTP ViewService (without response support)Fire-and-forget actionsServiceHTTP ViewTrigger automationsServiceHTTP ViewQuery state/configHTTP ViewInternal storage APIs"
      },
      {
        "title": "HTTP View Pattern",
        "body": "For data retrieval APIs:\n\nfrom homeassistant.components.http import HomeAssistantView\n\nclass OpenClawConfigView(HomeAssistantView):\n    \"\"\"HTTP view for retrieving config.\"\"\"\n    url = \"/api/openclaw/config\"\n    name = \"api:openclaw:config\"\n    requires_auth = True\n\n    async def get(self, request):\n        hass = request.app[\"hass\"]\n        config = await get_config_data(hass)\n        return json_response(config)\n\n# Register in async_setup:\nhass.http.register_view(OpenClawConfigView())"
      },
      {
        "title": "Critical: Avoid Internal APIs",
        "body": "Never use underscore-prefixed APIs — they're private and change between versions.\n\n❌ Wrong:\n\nstorage_collection = hass.data[\"_storage_collection\"]\n\n✅ Right:\n\n# Use public APIs only\nfrom homeassistant.helpers.storage import Store\nstore = Store(hass, STORAGE_VERSION, STORAGE_KEY)"
      },
      {
        "title": "For Small Data (Settings, Cache)",
        "body": "from homeassistant.helpers.storage import Store\n\nSTORAGE_KEY = \"your_domain.storage\"\nSTORAGE_VERSION = 1\n\nstore = Store(hass, STORAGE_VERSION, STORAGE_KEY)\n\n# Save\ndata = {\"entities\": modified_entities}\nawait store.async_save(data)\n\n# Load\ndata = await store.async_load()"
      },
      {
        "title": "For Large Data (History, Logs)",
        "body": "Use external database or file storage, not HA storage helpers."
      },
      {
        "title": "Breaking Changes to Watch",
        "body": "ChangeVersionMigrationConversation agents2025.x+Use async_process directlyService response data2023.7+Add supports_response paramConfig entry migration2022.x+Use async_migrate_entry\n\nAlways check: https://www.home-assistant.io/blog/ for your target version range."
      },
      {
        "title": "HACS Integration Structure",
        "body": "custom_components/your_domain/\n├── __init__.py          # async_setup_entry\n├── config_flow.py       # UI configuration\n├── manifest.json        # Dependencies, version\n├── services.yaml        # Service definitions\n└── storage_services.py  # Your storage logic"
      },
      {
        "title": "Minimal manifest.json",
        "body": "{\n  \"domain\": \"your_domain\",\n  \"name\": \"Your Integration\",\n  \"codeowners\": [\"@yourusername\"],\n  \"config_flow\": true,\n  \"dependencies\": [],\n  \"requirements\": [],\n  \"version\": \"1.0.0\"\n}"
      },
      {
        "title": "Testing Checklist",
        "body": "Service calls return expected data (with ?return_response)\n HTTP views accessible with auth token\n No underscore-prefixed API usage\n Storage persists across restarts\n Config flow creates config entry\n Error handling returns meaningful messages"
      },
      {
        "title": "Documentation Resources",
        "body": "Integration basics: developers.home-assistant.io/docs/creating_integration_index\nService calls: developers.home-assistant.io/docs/dev_101_services\nHTTP views: developers.home-assistant.io/docs/api/webserver\nBreaking changes: home-assistant.io/blog/ (filter by version)\nHACS guidelines: hacs.xyz/docs/publish/start"
      },
      {
        "title": "Lesson Learned",
        "body": "From HA-OpenClaw Bridge attempt:\n\n\"80% of our issues were discoverable with 30-60 minutes of upfront docs reading. We jumped straight to coding based on assumptions rather than reading how HA actually works.\"\n\nUse skills/pre-coding-research/ methodology before starting."
      }
    ],
    "body": "Home Assistant Integration Patterns\nService Response Data Pattern\nThe Problem\n\nBy default, HA services are \"fire-and-forget\" and return empty arrays [].\n\nThe Solution (HA 2023.7+)\n\nRegister service with supports_response:\n\nfrom homeassistant.helpers.service import SupportsResponse\n\nhass.services.async_register(\n    domain, \n    \"get_full_config\", \n    handle_get_full_config,\n    schema=GET_CONFIG_SCHEMA,\n    supports_response=SupportsResponse.ONLY,  # ← KEY PARAMETER\n)\n\n\nCall with ?return_response flag:\n\ncurl -X POST \"$HA_URL/api/services/your_domain/get_full_config?return_response\"\n\nResponse Handler\nasync def handle_get_full_config(hass: HomeAssistant, call: ServiceCall):\n    \"\"\"Handle the service call and return data.\"\"\"\n    # ... your logic ...\n    return {\"entities\": entity_data, \"automations\": automation_data}\n\nHTTP View vs Service: When to Use Each\nUse Case\tUse\tDon't Use\nReturn complex data\tHTTP View\tService (without response support)\nFire-and-forget actions\tService\tHTTP View\nTrigger automations\tService\tHTTP View\nQuery state/config\tHTTP View\tInternal storage APIs\nHTTP View Pattern\n\nFor data retrieval APIs:\n\nfrom homeassistant.components.http import HomeAssistantView\n\nclass OpenClawConfigView(HomeAssistantView):\n    \"\"\"HTTP view for retrieving config.\"\"\"\n    url = \"/api/openclaw/config\"\n    name = \"api:openclaw:config\"\n    requires_auth = True\n\n    async def get(self, request):\n        hass = request.app[\"hass\"]\n        config = await get_config_data(hass)\n        return json_response(config)\n\n# Register in async_setup:\nhass.http.register_view(OpenClawConfigView())\n\nCritical: Avoid Internal APIs\n\nNever use underscore-prefixed APIs — they're private and change between versions.\n\n❌ Wrong:\n\nstorage_collection = hass.data[\"_storage_collection\"]\n\n\n✅ Right:\n\n# Use public APIs only\nfrom homeassistant.helpers.storage import Store\nstore = Store(hass, STORAGE_VERSION, STORAGE_KEY)\n\nStorage Patterns\nFor Small Data (Settings, Cache)\nfrom homeassistant.helpers.storage import Store\n\nSTORAGE_KEY = \"your_domain.storage\"\nSTORAGE_VERSION = 1\n\nstore = Store(hass, STORAGE_VERSION, STORAGE_KEY)\n\n# Save\ndata = {\"entities\": modified_entities}\nawait store.async_save(data)\n\n# Load\ndata = await store.async_load()\n\nFor Large Data (History, Logs)\n\nUse external database or file storage, not HA storage helpers.\n\nBreaking Changes to Watch\nChange\tVersion\tMigration\nConversation agents\t2025.x+\tUse async_process directly\nService response data\t2023.7+\tAdd supports_response param\nConfig entry migration\t2022.x+\tUse async_migrate_entry\n\nAlways check: https://www.home-assistant.io/blog/ for your target version range.\n\nHACS Integration Structure\ncustom_components/your_domain/\n├── __init__.py          # async_setup_entry\n├── config_flow.py       # UI configuration\n├── manifest.json        # Dependencies, version\n├── services.yaml        # Service definitions\n└── storage_services.py  # Your storage logic\n\nMinimal manifest.json\n{\n  \"domain\": \"your_domain\",\n  \"name\": \"Your Integration\",\n  \"codeowners\": [\"@yourusername\"],\n  \"config_flow\": true,\n  \"dependencies\": [],\n  \"requirements\": [],\n  \"version\": \"1.0.0\"\n}\n\nTesting Checklist\n Service calls return expected data (with ?return_response)\n HTTP views accessible with auth token\n No underscore-prefixed API usage\n Storage persists across restarts\n Config flow creates config entry\n Error handling returns meaningful messages\nDocumentation Resources\nIntegration basics: developers.home-assistant.io/docs/creating_integration_index\nService calls: developers.home-assistant.io/docs/dev_101_services\nHTTP views: developers.home-assistant.io/docs/api/webserver\nBreaking changes: home-assistant.io/blog/ (filter by version)\nHACS guidelines: hacs.xyz/docs/publish/start\nLesson Learned\n\nFrom HA-OpenClaw Bridge attempt:\n\n\"80% of our issues were discoverable with 30-60 minutes of upfront docs reading. We jumped straight to coding based on assumptions rather than reading how HA actually works.\"\n\nUse skills/pre-coding-research/ methodology before starting."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/usimic/ha-integration-patterns",
    "publisherUrl": "https://clawhub.ai/usimic/ha-integration-patterns",
    "owner": "usimic",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/ha-integration-patterns",
    "downloadUrl": "https://openagent3.xyz/downloads/ha-integration-patterns",
    "agentUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent",
    "manifestUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/ha-integration-patterns/agent.md"
  }
}