examples/utility-meter: add --discover (mDNS broker discovery)#3
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 specbrokerTXT, falling back to the SRV target), and overrideshost/portin the broker config. The broker config still supplies the TLS material. On discovery timeout it falls back to the config'shost.Uses the existing optional
mdnsextra (zeroconf). Documented inexamples/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=8883thenutilityMeterReady, connects over mTLS, and publishes its Homie tree.🤖 Generated with Claude Code