Skip to content

docs: fix invalid custom-domain quick-start example (#88)#95

Merged
Faerkeren merged 1 commit into
mainfrom
fix/issue-88-docs-custom-domain-example
May 27, 2026
Merged

docs: fix invalid custom-domain quick-start example (#88)#95
Faerkeren merged 1 commit into
mainfrom
fix/issue-88-docs-custom-domain-example

Conversation

@Faerkeren
Copy link
Copy Markdown
Contributor

Closes #88.

Validity assessment

Valid and actionable. Verified both claims directly against the source:

  • docs/index.md registered a fan DomainSpec, but the built-in fan
    domain is already registered at import time (src/haclient/domains/fan.py:345,
    imported via src/haclient/domains/__init__.py). DomainRegistry.register
    rejects duplicate names for a different class
    (src/haclient/core/plugins.py:245-269), so the documented snippet raised
    HAClientError immediately on copy/paste.
  • The other snippet showed fan.set_speed(75). The real public method on the
    fan entity is set_percentage() (src/haclient/domains/fan.py:244); no
    set_speed exists.

Fix

  • Replace the custom-domain example with a non-conflicting sprinkler domain
    and clarify that _call_service is extension implementation code.
  • Replace the stale fan.set_speed(75) snippet with a working
    ha.fan("ceiling").set_percentage(75) call.
  • Add a regression test (tests/test_plugins.py::test_docs_custom_domain_example_runs)
    that extracts the documented snippet and exec's it against an isolated
    DomainRegistry. Any future drift between the docs and the public API
    (renamed helper, removed export, duplicate built-in) will now fail CI.

Checks run

  • pytest tests/ --cov=haclient --cov-report=term-missing --cov-fail-under=95
    → 319 passed, coverage 97.18%.
  • ruff check src tests → clean.
  • ruff format --check src tests → clean (after formatting the new test).
  • mypy src → no issues found in 38 source files.

The quick-start re-registered the built-in 'fan' domain, which raises
HAClientError on import. Replace with a non-conflicting 'sprinkler'
example and update the generic-accessor snippet to call the real
set_percentage() method instead of the nonexistent set_speed().

Add a regression test that execs the documented snippet against an
isolated DomainRegistry, so any future drift between docs and the
public API fails CI.
@Faerkeren Faerkeren merged commit 7ad13a6 into main May 27, 2026
12 checks passed
@Faerkeren Faerkeren deleted the fix/issue-88-docs-custom-domain-example branch May 27, 2026 13:08
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.

Fix the invalid custom-domain quick start example

1 participant