Skip to content

Add Home Automation capability#217

Open
lewisthorpe1994 wants to merge 3 commits intopydantic:mainfrom
lewisthorpe1994:home-automation-capability
Open

Add Home Automation capability#217
lewisthorpe1994 wants to merge 3 commits intopydantic:mainfrom
lewisthorpe1994:home-automation-capability

Conversation

@lewisthorpe1994
Copy link
Copy Markdown

Summary

Adds a Home Automation capability backed by a Home Assistant REST API adapter.

This includes:

  • A backend protocol with normalized entity, state, service, service argument, and service-call result dataclasses.
  • A HomeAutomation capability and HomeAutomationToolset exposing service discovery, entity/state inspection, and service calls to agents.
  • A Home Assistant backend that validates /api/services and /api/states responses with Pydantic models, caches the service catalog, handles return_response service calls, and verifies service-call outcomes with changed states or follow-up state polling.
  • Capability-local README documentation and tests covering the backend contract, Home Assistant response mapping, service calls, polling, and exports.

Linked Issue

Fixes #125

Checklist

  • Linked issue exists and is referenced above
  • Tests added/updated for new behavior
  • make lint && make typecheck && make test passes locally (don't stress about CI -- we'll help)
  • No changes to pyproject.toml or uv.lock (dependency changes require a separate issue)
  • Docstrings use single backticks (not RST double backticks)

Local validation run:

  • make lint
  • make typecheck
  • make testcov (123 passed, 100% coverage)

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Author

Also tested this manually against a local Home Assistant instance using Gemma via llama.cpp.

Prompt: “turn off the computer room light”

The agent flow was:

  1. Called list_entities(domain='light')
  2. Selected light.computer_room_light from the returned entities
  3. Called call_service(domain='light', entity_id='light.computer_room_light', service_name='turn_off')
  4. Received ServiceCallResult(..., verified_state=EntityState(..., state='off'))

The physical light turned off and the backend returned a verified post-call state.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

View 3 additional findings in Devin Review.

Open in Devin Review

import asyncio
from typing import Any

import httpx
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 httpx is used but not declared as a direct dependency

The _backend.py module imports httpx directly at line 4, and the HomeAssistantBackend.__init__ constructs httpx.AsyncClient instances. However, httpx is not listed in pyproject.toml dependencies — it's only available transitively through pydantic-ai-slim. If pydantic-ai-slim ever makes httpx optional, this module would break at import time. Consider adding a home-automation optional dependency extra (similar to the code-mode extra for pydantic-monty) that includes httpx.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Home Automation capability (Home Assistant, Google Home, IoT)

1 participant