Skip to content
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

Refactor Tuya EnchantedDevice to use custom configuration #3414

Merged

Conversation

TheJulianJES
Copy link
Collaborator

@TheJulianJES TheJulianJES commented Oct 11, 2024

Proposed change

This PR refactors the Tuya spell code in EnchantedDevice to use the apply_custom_configuration hook in BaseCustomDevice (introduced in recent zha/zigpy versions).

This allows us to remove the workarounds of "enchantable" clusters where bind() was hijacked and called the Tuya spells.
With this PR, we can call the Tuya spell code way easier (and slightly earlier).

A bunch of now irrelevant documentation and tests are also removed. The tests can likely be reduced a bit more in future PRs, as we no longer need to test that every device/quirk correctly casts the spell, but it also doesn't hurt anything.
So, if we want to change the "spell tests" further, I'd push that to a future PR.

Additional information

Requires:

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

@TheJulianJES TheJulianJES added Tuya Request/PR regarding a Tuya device code quality Improvement to code quality labels Oct 11, 2024
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.69%. Comparing base (a29ad2f) to head (a4b7d40).
Report is 5 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3414      +/-   ##
==========================================
- Coverage   88.71%   88.69%   -0.03%     
==========================================
  Files         306      306              
  Lines        9820     9815       -5     
==========================================
- Hits         8712     8705       -7     
- Misses       1108     1110       +2     

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

@TheJulianJES

This comment was marked as resolved.

@TheJulianJES TheJulianJES merged commit 7402ba3 into zigpy:dev Oct 16, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improvement to code quality Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants