Skip to content

Add Homecast integration#166675

Open
robjampar wants to merge 1 commit intohome-assistant:devfrom
robjampar:add-homecast-integration
Open

Add Homecast integration#166675
robjampar wants to merge 1 commit intohome-assistant:devfrom
robjampar:add-homecast-integration

Conversation

@robjampar
Copy link
Copy Markdown

@robjampar robjampar commented Mar 27, 2026

Summary

Add a new integration for Homecast, which bridges Apple HomeKit smart home devices to open standards via a Mac/iOS relay app.

The integration connects to the Homecast API via OAuth 2.1 with PKCE and exposes HomeKit light devices as native Home Assistant entities. It supports two modes:

  • Cloud mode — connects to api.homecast.cloud with WebSocket push for real-time state updates (<1s latency) and REST polling every 5 minutes as a safety net
  • Community mode — connects to a local Mac server on the user's network

How it works

  1. User adds integration via UI → selects Cloud or Community → OAuth 2.1 flow with PKCE
  2. OAuth client is dynamically registered via RFC 7591 (no manual credential entry)
  3. WebSocket connection established for real-time push updates
  4. Individual characteristic changes applied incrementally to in-memory state
  5. REST polling every 5 minutes as safety-net resync
  6. Control commands sent via POST /rest/state

Uses pyhomecast as the third-party API client library.

Quality scale

Bronze tier checklist:

  • action-setup (exempt - no additional actions)
  • appropriate-polling (5 min safety-net, WebSocket push primary)
  • brands
  • common-modules
  • config-flow-test-coverage
  • config-flow
  • dependency-transparency
  • docs-actions (exempt - no additional actions)
  • docs-high-level-description
  • docs-installation-instructions
  • docs-removal-instructions
  • entity-event-setup
  • entity-unique-id
  • has-entity-name
  • runtime-data
  • test-before-configure
  • test-before-setup
  • unique-config-entry

Test plan

  • Unit tests for config flow (cloud flow, menu, already configured, parameterized error tests, reauth, register client failure)
  • Unit tests for init (setup, unload, connection error retry, auth error, token refresh errors)
  • Unit tests for light platform (setup, brightness, HS color, color temp, turn on/off, color modes, multi-home)
  • Unit tests for coordinator (WebSocket message handling, UUID mapping, group propagation, shutdown)
  • Manual end-to-end testing against staging

Companion PRs:

Copilot AI review requested due to automatic review settings March 27, 2026 08:34
Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @robjampar

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link
Copy Markdown

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Home Assistant core integration for the Homecast cloud service, enabling OAuth-based connectivity and exposing bridged HomeKit devices as native entities via periodic polling.

Changes:

  • Introduces the homecast integration (OAuth2 + coordinator) and entity platforms (light, switch, climate, lock, cover, fan, alarm, sensors).
  • Registers Homecast in generated integration/config-flow/application-credentials indices and updates CODEOWNERS.
  • Adds unit tests and fixtures for config flow and config entry setup/unload.

Reviewed changes

Copilot reviewed 23 out of 26 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
homeassistant/components/homecast/__init__.py Integration setup/unload; OAuth session bootstrapping; coordinator wiring.
homeassistant/components/homecast/alarm_control_panel.py Alarm control panel entity mapping and command sending.
homeassistant/components/homecast/application_credentials.py OAuth2 authorization server + PKCE implementation hookup.
homeassistant/components/homecast/binary_sensor.py Motion/contact/doorbell + low-battery binary sensor entities.
homeassistant/components/homecast/climate.py Thermostat/climate entity mapping and setpoint control.
homeassistant/components/homecast/config_flow.py OAuth2 config flow + connectivity validation + reauth steps.
homeassistant/components/homecast/const.py Integration constants (API URLs, scopes, polling interval).
homeassistant/components/homecast/coordinator.py Polling coordinator and state-setting helper.
homeassistant/components/homecast/cover.py Cover entity mapping for blinds/window coverings.
homeassistant/components/homecast/entity.py Base coordinator entity + device registry metadata + state write helper.
homeassistant/components/homecast/fan.py Fan entity mapping and speed control.
homeassistant/components/homecast/light.py Light entity mapping (brightness/HS/color temp) and control.
homeassistant/components/homecast/lock.py Lock entity mapping and lock/unlock control.
homeassistant/components/homecast/manifest.json Declares integration metadata and pyhomecast requirement.
homeassistant/components/homecast/quality_scale.yaml Bronze quality scale checklist assertions/exemptions.
homeassistant/components/homecast/sensor.py Temperature/illuminance sensors + companion battery level sensor.
homeassistant/components/homecast/strings.json UI strings for config flow, abort reasons, and entry creation text.
homeassistant/components/homecast/switch.py Switch/outlet entity mapping and on/off control.
homeassistant/generated/application_credentials.py Adds homecast to application-credentials registry list.
homeassistant/generated/config_flows.py Adds homecast to config-flow registry list.
homeassistant/generated/integrations.json Registers homecast integration metadata for frontend/registry.
tests/components/homecast/__init__.py Test package marker for the integration.
tests/components/homecast/conftest.py Test fixtures: mock client/state and application credentials setup.
tests/components/homecast/test_config_flow.py Tests OAuth config flow success + already-configured + error aborts.
tests/components/homecast/test_init.py Tests config entry setup/unload and connection error retry.
CODEOWNERS Adds code ownership for integration and its tests.

robjampar added a commit to robjampar/brands that referenced this pull request Mar 27, 2026
Add icon and logo for the Homecast core integration (HomeKit smart home bridge).

Companion PR: home-assistant/core#166675

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 27, 2026 09:26
@robjampar robjampar force-pushed the add-homecast-integration branch 4 times, most recently from 139dc8c to e603f27 Compare March 29, 2026 12:41
@robjampar robjampar marked this pull request as ready for review March 30, 2026 17:43
@robjampar robjampar force-pushed the add-homecast-integration branch 19 times, most recently from fe61ef4 to 84f5e45 Compare April 6, 2026 18:42
Copy link
Copy Markdown
Contributor

@erwindouna erwindouna left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, @robjampar! Here's an initial review. :)

@robjampar robjampar force-pushed the add-homecast-integration branch 3 times, most recently from a0c25de to 2bbb0ba Compare April 7, 2026 13:41
Add a new integration for Homecast, which bridges Apple HomeKit smart
home devices to open standards. The integration connects to the Homecast
cloud API via OAuth 2.1 with PKCE and exposes HomeKit devices as native
Home Assistant entities.

Features:
- OAuth 2.1 with PKCE (dynamic client registration via RFC 7591)
- WebSocket push for real-time state updates (<1s latency)
- Incremental characteristic + service group updates with group propagation
- REST polling every 5 minutes as safety-net resync
- Auth error detection triggers reauth flow
- Cloud and Community mode (local Mac server) support
- Light platform: on/off, brightness, HS color, color temperature
- Identifies as client_type=homeassistant in Homecast admin panel

Uses pyhomecast (PyPI) as the third-party API client library.
Additional platforms (switch, climate, lock, etc.) will follow in
subsequent PRs.
@robjampar robjampar force-pushed the add-homecast-integration branch from 2bbb0ba to 114c0b9 Compare April 7, 2026 14:24
@robjampar
Copy link
Copy Markdown
Author

@erwindouna I've addressed all your review comments — thanks for the detailed feedback! All CI is green and threads resolved. Ready for another look when you have time.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants