Skip to content

examples/utility-meter: add --discover (mDNS broker discovery)#3

Merged
dcj merged 1 commit into
mainfrom
utility-meter-mdns-discover
Jun 28, 2026
Merged

examples/utility-meter: add --discover (mDNS broker discovery)#3
dcj merged 1 commit into
mainfrom
utility-meter-mdns-discover

Conversation

@dcj

@dcj dcj commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The utility-meter can now find its broker over mDNS instead of needing an explicit host in the broker config.

What

With --discover, the meter browses _secure-mqtt._tcp, resolves the advertised host/port (preferring the spec broker TXT, falling back to the SRV target), and overrides host/port in the broker config. The broker config still supplies the TLS material. On discovery timeout it falls back to the config's host.

Uses the existing optional mdns extra (zeroconf). Documented in examples/README.md.

Why

Lets the publisher discover and connect to a broker the spec-correct way (the consumer-side mirror of broker advertisement), e.g. against electrification-bus/broker-quickstart's laptop broker. Pairs with that repo's PR adding the mDNS advertisement + a discovery helper + a full-loop bench.

Validation

End to end on macOS: the meter logs brokerDiscovered,host=<host>.local,port=8883 then utilityMeterReady, connects over mTLS, and publishes its Homie tree.

🤖 Generated with Claude Code

The utility-meter can now find its broker over mDNS instead of needing an
explicit host in the broker config. With --discover it browses _secure-mqtt._tcp,
resolves the advertised host/port (preferring the spec `broker` TXT, falling back
to the SRV target), and overrides host/port in the broker config; the broker
config still supplies the TLS material. Falls back to the config host on timeout.

Uses the existing optional `mdns` extra (zeroconf). Documented in examples/README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dcj
dcj merged commit 587c767 into main Jun 28, 2026
1 check passed
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.

1 participant