Skip to content

Examples: adopt ebus-service-discovery for mDNS discovery and advertising - #104

Merged
dcj merged 2 commits into
mainfrom
dcj/adopt-service-discovery
Oct 8, 2026
Merged

dcj merged 2 commits into
mainfrom
dcj/adopt-service-discovery

Conversation

@dcj

@dcj dcj commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #100.

The mdns extra now installs ebus-service-discovery[zeroconf]>=0.4.0 in place of bare zeroconf, and both examples use it instead of their own browse code.

  • simple-span-controller browses _secure-mqtt._tcp and accepts only the advertisement whose SRV target is span-<serial>.local (it matched a substring before). It connects by that host name, and to the panel's advertised address when this host cannot resolve .local names.
  • utility-meter --discover ranks and selects brokers with the library and stays within --discover-timeout. A plain broker config now also accepts _mqtt._tcp.
  • utility-meter advertises _ebus._tcp and _device-info._tcp (framework.md requirement 6) under its device id when the extra is installed; --no-advertise turns it off.

Behavior changes: discovery now waits for the browse window (5 s for the span controller, 3 s per meter attempt) instead of returning on the first answer.

Verified live: simple-span-controller against a panel on the LAN found the same 25 devices and values as main, including with .local resolution forced to fail; utility-meter --discover found a locally advertised mosquitto, published, and appeared in an _ebus._tcp browse. 874 tests pass; ruff check and format pass on the repo and both extension-less examples.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T32pvgqCzp1qCz7K5gS9Wm

dcj and others added 2 commits October 8, 2026 16:24
The mdns extra now installs ebus-service-discovery[zeroconf]>=0.4.0.

- utility-meter --discover uses mdns.find_broker() and
  BrokerEndpoint.mqtt_cfg(), and the meter advertises _ebus._tcp and
  _device-info._tcp with mdns.Advertiser (--no-advertise opts out).
- simple-span-controller browses _secure-mqtt._tcp with mdns.browse(),
  accepts only the instance whose SRV target is span-<serial>.local, and
  connects by that host name.
- README, examples/README.md and CHANGELOG updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T32pvgqCzp1qCz7K5gS9Wm
- simple-span-controller connects to the matched SRV target (not the TXT
  `broker` value), and to the panel's most-preferred advertised address
  when this host cannot resolve `.local` names.
- utility-meter --discover browses with mdns.browse_many, rank_brokers
  and select_broker in a loop whose last browse is cut to the time left,
  so it returns by --discover-timeout. find_broker's fixed browse window
  overran it by up to 3 s.
- .ebus-spec.json notes describe the mdns extra as it now is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T32pvgqCzp1qCz7K5gS9Wm
@dcj
dcj merged commit 655951c into main Oct 8, 2026
5 checks passed
@dcj
dcj deleted the dcj/adopt-service-discovery branch October 8, 2026 23:40
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.

Adopt ebus-service-discovery for broker discovery and advertising

1 participant