Skip to content

Implement quirks v2 unique_id_suffix #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Jan 26, 2025

DRAFT until zigpy bump is made and merged

Proposed change

This implements the quirks v2 unique_id_suffix that's appended to the existing unique_id of IEEE+endpoint+cluster (or something like that). So, it just replaces the default ZHA unique_id_suffix (which is the attribute name for v2 quirk entities by default)

This is needed when there are multiple quirks v2 entities for a specific attribute.
A test is also added that checks this for "write attr buttons" (writing the same attribute with different values).

Additional information

Corresponding zigpy PR:

Closes:

Comment on lines 358 to 361
if entity_metadata.unique_id_suffix:
self._unique_id_suffix = (
f"{self._unique_id_suffix}-{entity_metadata.unique_id_suffix}"
)
Copy link
Contributor Author

@TheJulianJES TheJulianJES Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that instead of appending the quirks v2 provided unique_id_suffix to the existing unique_id_suffix (created in the lines above), that we just replace it?
I guess that could work. The "attribute_name + extra suffix" is likely a bit unnecessary.

It would still be a suffix (to the original UID of IEEE +endpoint+cluster), so I'd keep the name the same probably and just change the implementation here. I don't think we should or even need to allow changing the whole UID (or the first part).

Changing just this suffix part to not append to the attr name should allow quirks v2 to take over ZHA/"v1" entities.

@TheJulianJES TheJulianJES force-pushed the tjj/quirks_v2_unique_id_sufffix branch from df4c30f to a1489ea Compare January 27, 2025 21:48
@TheJulianJES
Copy link
Contributor Author

TheJulianJES commented Jan 27, 2025

Changed the implementation to override the default attribute name unique_id_suffix for quirks v2 entities now, instead of appending it to the default.
This should allow us to replace ZHA/v1 entities from v2 quirks.

(Tests will fail until zigpy PR is merged + bump)

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.58%. Comparing base (5e1cef1) to head (2c1473b).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #362   +/-   ##
=======================================
  Coverage   96.58%   96.58%           
=======================================
  Files          61       61           
  Lines        9512     9514    +2     
=======================================
+ Hits         9187     9189    +2     
  Misses        325      325           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES TheJulianJES marked this pull request as ready for review January 28, 2025 19:59
@puddly puddly merged commit f6f4b6c into zigpy:dev Jan 28, 2025
9 checks passed
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.

2 participants