Skip to content

Keep overriden functions async #4023

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 4 commits into from
Apr 29, 2025

Conversation

puddly
Copy link
Contributor

@puddly puddly commented Apr 23, 2025

Proposed change

Some functions, like read_attributes, are now async in zigpy but are overridden by a few quirks and replaced with sync overloads. This is functionally equivalent but results in ZHA test warnings:

Warning: coroutine 'Cluster.read_attributes' was never awaited

I've also converted the quirk for the affected device into a v2 quirk, since it did nothing but replace a single cluster.

Additional information

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

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 57.14286% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.17%. Comparing base (e4844d4) to head (164d89a).
Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
zhaquirks/eurotronic/__init__.py 25.00% 3 Missing ⚠️
zhaquirks/plaid/soil.py 66.66% 2 Missing ⚠️
zhaquirks/tuya/__init__.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4023      +/-   ##
==========================================
- Coverage   91.17%   91.17%   -0.01%     
==========================================
  Files         334      334              
  Lines       10858    10852       -6     
==========================================
- Hits         9900     9894       -6     
  Misses        958      958              

☔ 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 TheJulianJES added the bugfix This PR fixes a bug label Apr 26, 2025
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

Nice catch! Seems like we also have an old quirk doing this for write_attributes:

def write_attributes(self, attributes, manufacturer=None, **kwargs):
"""Override wrong writes to thermostat attributes."""
if "system_mode" in attributes:
host_flags = self._attr_cache.get(HOST_FLAGS_ATTR, 1)
_LOGGER.debug("current host_flags: %s", host_flags)
if attributes.get("system_mode") == 0x0:
return super().write_attributes(
{"host_flags": host_flags | SET_OFF_MODE_FLAG}, MANUFACTURER
)
if attributes.get("system_mode") == 0x4:
return super().write_attributes(
{"host_flags": host_flags | CLR_OFF_MODE_FLAG}, MANUFACTURER
)
return super().write_attributes(attributes, manufacturer, **kwargs)

@TheJulianJES TheJulianJES added the smash This PR is close to be merged soon label Apr 26, 2025
@puddly puddly merged commit 8b61c39 into zigpy:dev Apr 29, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR fixes a bug smash This PR is close to be merged soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants