fix(config-flow): re-pair already-bound devices instead of dead-ending (Closes #75)#76
Open
eldios wants to merge 1 commit into
Open
fix(config-flow): re-pair already-bound devices instead of dead-ending (Closes #75)#76eldios wants to merge 1 commit into
eldios wants to merge 1 commit into
Conversation
Closes aavdberg#75) A fountain that already holds a pairing secret (bound by the PetKit app or a prior HA setup) hit a hard abort that a factory reset often failed to clear, leaving setup stuck in a loop. The firmware accepts a fresh CMD 73 init without a reset (confirmed on a CTW3_100), so when a device reports as already initialised the config flow now shows a "Device Already Paired" menu with two choices: - Re-pair now — register a fresh secret, overwriting the existing pairing. - Cancel — abort the flow, leaving the device untouched. Re-pair failures abort with an actionable message instead of looping. Also fix a latent byte-order bug: async_check_initialized read the device id little-endian while build_init_payload writes big-endian, which would byte-swap a non-zero id on re-init. Extract parse_device_id (big-endian) so the id round-trips, with a regression test. Adds a Troubleshooting section to the README and translations (en/nl/uk).
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.
Summary
Fixes the "This device is already initialized with a secret" setup loop (#75). A fountain previously bound — by the PetKit app or an earlier Home Assistant install whose secret was lost — reported as already initialised and the flow hard-aborted, telling users to factory reset; the reset frequently didn't clear the binding, leaving setup stuck.
The firmware accepts a fresh
CMD 73init without a factory reset, so when a device reports as already initialised the flow now shows a "Device Already Paired" menu:Re-pair failures abort with an actionable message instead of looping.
Also fixes a latent byte-order bug:
async_check_initializedread the device id little-endian whilebuild_init_payloadwrites big-endian, byte-swapping a non-zero id on re-init. Extractedparse_device_id(big-endian) so the id round-trips, with a regression test. Adds a Troubleshooting section to the README and en/nl/uk translations.Test plan
Tested on a real Petkit CTW3_100 that was already paired with the PetKit app: setup previously dead-ended on the "already initialized" abort. With this change, the "Device Already Paired" menu appeared, Re-pair now registered a fresh secret and the device paired successfully — entities populate and controls work. The Cancel option aborted cleanly, leaving the device untouched. Automated suite (
pytest) passes 101/101 including the newparse_device_idround-trip test;ruff checkandruff format --checkare clean.