Repository navigation
homie: expose the bring-your-own-transport wiring contract (will, resync) - #17
Merged
Merged
Conversation
…ync) (#13) An injected MQTT client bypasses MqttClient.from_config, the only place the SDK wires on_connect, on_disconnect, and the LWT, so an injected client loses the will, the reconnect republish, and (tree-rooted Controller) the reconnect bookkeeping reset. The will rides the CONNECT packet and the SDK's on_connect is registered only on a client it constructs, so the SDK cannot install these on a client it is handed: the caller must wire them. Expose the pieces: - Device.will(): the root's $state=lost descriptor, factored out of connect_broker (which now uses it; owned-path value unchanged). - Device.refresh_tree(): documented as the on-connect republish hook. - Controller.resync(): the tree-rooted discovery reset, extracted from _on_connect (which now delegates); closes the Controller-side gap. Pure refactor + additive public API; no owned-client behavior change. The Device pieces are consumed when Device gains an injection point (#14). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Exposes the bring-your-own-transport wiring contract so an injected MQTT client can achieve the Homie behavior the SDK cannot install on a client it is merely handed, and fixes the Controller-side reconnect gap. Part of #13.
Background
An injected client bypasses
MqttClient.from_config(connect_broker/_connect_brokerreturn early whenself.mqttcis already set), which is the only place the SDK wireson_connect,on_disconnect, and the LWT. So an injected client loses its last will, its whole-tree reconnect republish, and (tree-rootedController) its reconnect bookkeeping reset.What this does
Pure refactor + additive public API. No owned-client path changes behavior.
Device.will()returns the root's$state=lostLWT descriptor, factored out ofconnect_broker(which now passeslwt=self.will(); identical value on the owned path). A BYO caller sets this on their client before connecting, since the will rides the CONNECT packet and cannot be added afterward.Device.refresh_tree()docstring documents it as the on-connect republish hook a BYO caller invokes from their own handler.Controller.resync()is the tree-rooted discovery reset, extracted from_on_connect(which now delegates to it). A BYO tree-rooted caller calls it on reconnect so the tree re-walks. Closes the Controller-side gap now.Scope
Devicepieces (will(),refresh_tree) are the contract that Device bring-your-own-transport: inject mqttc on a root Device (producer seam) #14 (the Device injection point) consumes; there is no injectedDeviceyet, so this enables that rather than changing current behavior.Controllerfix is shippable now (the injectedControllerhas existed since 0.13.0).Tests
+6 (
will()x3,resync()x3), 506 total pass.ruff checkandruff format --checkclean; CI covers 3.10-3.13 via #16.🤖 Generated with Claude Code