Skip to content

Conversation

@darinlarimore
Copy link

Summary

Fixes a ValueError that occurs when processing device registry updates for devices with identifiers containing more than 2 elements (e.g., HomeKit devices use 3-element identifiers).

Problem

The current code assumes all device identifiers are 2-tuples (domain, id), but some integrations like HomeKit use 3-element identifiers (domain, id, type). This causes ValueError: too many values to unpack (expected 2) when those devices trigger registry updates.

Solution

Changed the unpacking to iterate over identifiers and safely extract the first two elements regardless of total length.

Before

for ident_type, ident_id in device_entry.identifiers:

After

for identifier in device_entry.identifiers:
    if len(identifier) >= 2:
        ident_type, ident_id = identifier[0], identifier[1]
    else:
        continue

Some integrations like HomeKit use 3-element identifiers (domain, id, type)
instead of the expected 2-element tuple. This caused:
ValueError: too many values to unpack (expected 2)

Changed to iterate over identifiers and safely extract the first two
elements regardless of total length.
jleinenbach pushed a commit to jleinenbach/bermuda that referenced this pull request Jan 26, 2026
…#727)

Some integrations (like HomeKit) use device identifiers with more than
2 elements (e.g., (domain, id, type)). The previous code assumed all
identifiers were 2-tuples, causing ValueError when iterating.

Changes:
- __init__.py: async_remove_config_entry_device() now handles variable-length identifiers
- coordinator.py: Device registry update handler now handles variable-length identifiers
- coordinator.py: Connection iteration also made defensive for consistency

This fix mirrors upstream PR agittins#727 (agittins/bermuda).

https://claude.ai/code/session_01LzNxUNSSL88K8KAb6tgdwJ
jleinenbach added a commit to jleinenbach/bermuda that referenced this pull request Jan 26, 2026
…-GKtxN

fix: handle device identifiers with 3+ elements (upstream PR agittins#727)
@darinlarimore
Copy link
Author

Yay looks like a fix has been merged in, Thank you!

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