Repository navigation
fix(homekit): keep the IIDs of paired Home apps on HAP-python 5.2 - #242
Merged
Merged
Conversation
HAP-python 5.2 adds an Active characteristic to every camera stream management service. Our three stream services come first, so every IID from the doorbell on moved by three, and IID 39, the gate until now, became the speaker. The Home app keys rooms, names and automations on those IIDs. The accessory now passes its own IIDManager to pyhap: the numbering of 5.0, with each of those Active characteristics given an IID of its own after ours.
Merged
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.
What and why
HAP-python 5.2 (the version #238 moves to, and the one Home Assistant 2026.12 ships) adds an
Activecharacteristic to everyCameraRTPStreamManagementservice. The accessory has three stream services, and pyhap creates them before ours. So with 5.2 every IID from the doorbell on moves:The Home app keys rooms, names and automations on the IIDs, which is why the ring button option already keeps them stable (
test_homekit_ring_button.py). On 5.2, IID 39, the gate until now, becomes the speaker.The accessory now passes its own
IIDManagerto pyhap. It numbers everything as pyhap 5.0 did, and gives theActivecharacteristic of each stream service an IID of its own from 101 up, after all of ours. Nothing depends on the version number. With 5.0 nothing changes: that characteristic does not exist there.Follow-up to #241.
Tests
to_HAP()lists 43 distinct IIDs, and pyhap findsActiveat IID 101.Tested on Windows 11, Python 3.13, with both versions:
HAP-python 5.0.0: CHECK VERDE, 2506 passed, 32 skipped, coverage 97.2%
HAP-python 5.2.0: CHECK VERDE, 2506 passed, 32 skipped, coverage 97.22%
The CI pins HAP-python 5.0.0 until #238, and there the first test passes without the fix too: the proof is the 5.2.0 run above. The second test checks that 5.2 really adds three characteristics, so it cannot pass empty.
Home apps that already reconnected to 1.0.30 on HAP-python 5.2 saw the shifted IIDs. With this change they move back to the 5.0 ones, which those Home apps had until then.
Not tested: a Home app that was paired with 5.0 reading the accessory after an update to 5.2. Test at the intercom: not needed (no SIP, media, door or registration code is touched).
Changelog: Bug fixes - With HAP-python 5.2 (Home Assistant 2026.12) the HomeKit doorbell keeps the identifiers it already has in the Home app, so rooms, names and automations of the gate stay as they are.
Before you update: if your doorbell was already paired in the Home app and you ran an earlier version on Home Assistant 2026.12, open the Home app once after updating and check the gate's room, name and automations.