Skip to content

Add support for /.well-known/thread/br-rest API discovery - #271

Merged
puddly merged 2 commits into
home-assistant-libs:mainfrom
lboue:well-known-thread-api-discovery
Aug 19, 2026
Merged

Add support for /.well-known/thread/br-rest API discovery#271
puddly merged 2 commits into
home-assistant-libs:mainfrom
lboue:well-known-thread-api-discovery

Conversation

@lboue

@lboue lboue commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds OTBR.get_api_version(), which reads the RFC 8615 discovery resource GET /.well-known/thread/br-rest added in ot-br-posix PR #3330 (merged 2026-07-07)
  • Returns the router's advertised REST API semver string (e.g. "0.3.0"), or None on routers that predate that PR and don't expose the endpoint (a 404 is treated as "unknown", not an error)
  • Result is cached for the lifetime of the OTBR instance

Kept independent of _maybe_detect_key_format/KeyFormat: the discovery endpoint's JSON shape is unrelated to the PascalCase/camelCase dataset wire format, and this avoids touching the already well-tested detection flow.

Why

This is a first step towards feature-gating on the REST API version instead of relying only on reactive 404 handling. In particular it's meant as a foundation for #267 (ephemeral key / ePSKc client support): once ePSKc actually lands upstream in ot-br-posix with a version bump, we'll be able to use get_api_version() to detect support declaratively instead of only via try/except on the ePSKc endpoints. For now #267's reactive 404 detection is unaffected and remains the mechanism used for ePSKc, since the discovery resource's links don't currently list ba-epskc.

Test plan

  • pytest — full suite passes (81 tests, 7 new)
  • mypy — clean
  • pylint — 10/10
  • black/flake8 — clean

Adds OTBR.get_api_version(), which reads the RFC 8615 discovery
resource added in ot-br-posix PR #3330 (merged 2026-07-07) and
returns the router's advertised REST API semver string (e.g.
"0.3.0"), or None on routers that predate that PR.

This is a first step towards feature-gating (e.g. ePSKc, see home-assistant-libs#267)
on the API version instead of relying only on reactive 404 handling.
Kept independent of _maybe_detect_key_format/KeyFormat: the discovery
endpoint's JSON shape is unrelated to the PascalCase/camelCase dataset
wire format, and this avoids touching the already well-tested
detection flow.
Comment thread python_otbr_api/__init__.py Outdated
Comment thread python_otbr_api/__init__.py Outdated
- Trim the get_api_version() docstring to match the terser style used
  elsewhere in this module.
- Replace the (_api_version, _api_version_checked) pair with a single
  _UndefinedType sentinel, so the attribute is an honest tristate
  (not-yet-probed / probed-and-absent / probed-and-known) instead of
  two fields that could in theory disagree.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@lboue
lboue requested a review from puddly August 19, 2026 20:19
@puddly
puddly merged commit 9ff0126 into home-assistant-libs:main Aug 19, 2026
1 check passed
@lboue
lboue deleted the well-known-thread-api-discovery branch August 20, 2026 09: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.

2 participants