Skip to content

Conversation

@TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Nov 13, 2025

Proposed change

This renames quirk_id to exposes_features internally and allows quirks to set multiple exposed features.

Why

This will be useful for a number of issues, including Frient sensors that expose other IAS bits (alarm 1/2 + tamper + test bit), so we don't have to use custom quirks v2 entities for all devices using standard ZCL functionality. It's also useful to remove certain features we currently expose for all siren entities, like a lot of the siren specific parameters or the configuration entities.

In v1/v2 quirks, we can simply add a line that's something like .exposes_feature(IAS_TAMPER_FEATURE) or .exposes_feature(SIREN_LIMITED_FEATURE) and ZHA will add or change the behavior of some entities for those devices.

Other notes

For now, I've left the attribute we check for the exposed features in v1 quirks called quirk_id. A previous iteration of this PR only renamed all internal references to quirk_ids, but I think we can just go ahead and rename it to exposes_features like done in this PR.
A small follow-up PR would add support from specifying exposed features in v2 quirks.

quirk_id can be a set[str]/list[str] or str as before, to make sure we don't break existing integrated v1 quirks or custom v1 quirks that may be used for some Tuya (plug) devices.

Additional information

Addresses (see for more background info):

Other related issues:

For a diff without the regenerated diagnostics, see: dev...TheJulianJES:zha:tjj/multiple_quirk_id_without_diagnostics

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (7ca9e13) to head (149f932).
⚠️ Report is 5 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #575      +/-   ##
==========================================
- Coverage   97.02%   97.00%   -0.03%     
==========================================
  Files          63       63              
  Lines       10535    10544       +9     
==========================================
+ Hits        10222    10228       +6     
- Misses        313      316       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TheJulianJES
Copy link
Contributor Author

TheJulianJES commented Nov 26, 2025

I think we could get this in as well. It does what the PR title says, but it only processes the (v1) quirk_id in this PR, though it can now also be a set, list, or str like before.
This is needed to keep backwards compatibility for custom quirks (mostly Tuya plug quirks).

Another PR would add the exposed features from the v2 quirks API, something like TheJulianJES/zha@tjj/multiple_quirk_id...TheJulianJES:zha:tjj/quirks_v2_exposed_features.

For a diff of this PR without the regenerated diagnostics (so GitHub dies less), see: dev...TheJulianJES:zha:tjj/multiple_quirk_id_without_diagnostics

@TheJulianJES TheJulianJES marked this pull request as ready for review November 26, 2025 01:19
@TheJulianJES
Copy link
Contributor Author

This would require one small change in Core here: https://github.com/home-assistant/core/blob/9ebc6cbb23f470c5c371b1b5abb189513a9086af/homeassistant/components/zha/helpers.py#L344

You're good with this PR?

Copy link
Contributor

@puddly puddly left a comment

Choose a reason for hiding this comment

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

LGTM!

@TheJulianJES TheJulianJES merged commit 34a92e6 into zigpy:dev Nov 26, 2025
8 of 9 checks passed
@TheJulianJES TheJulianJES deleted the tjj/multiple_quirk_id branch November 26, 2025 01:58
@TheJulianJES
Copy link
Contributor Author

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