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

Update Tuya RCBO quirk power factor calculation for home-assistant/core#107641 #2896

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

jeverley
Copy link
Contributor

@jeverley jeverley commented Jan 9, 2024

Proposed change

Amend power_factor calculation to respect Zigbee cluster specification - required for release of zha fix:

home-assistant/core#107641

Additional information

This updates the power factor calculation to multiply by 100 rather than 1000, this is because the ElectricalMeasurement attribute is supposed to expose values between -100 and 100 (see the pre-requisite PR 107641 for details).

The current code exposes values between 0 and 1000, which is subsequently divided by 10 due to the behaviour of the zha cluster sensor corrected in home-assistant/core#107641

If released without home-assistant/core#107641 the value reported will be an order of magnitude too low.

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

@jeverley jeverley changed the title Update ts0601_rcbo.py Update quirk calculations of power_factor as pre-requisite for merging fix https://github.com/home-assistant/core/pull/107641 Jan 9, 2024
@jeverley jeverley changed the title Update quirk calculations of power_factor as pre-requisite for merging fix https://github.com/home-assistant/core/pull/107641 Update quirk calculations of power_factor as pre-requisite for merging home-assistant/core#107641 Jan 9, 2024
@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Jan 17, 2024
@jeverley jeverley force-pushed the power_factor_calculation_correct branch from 04c1ec9 to 6c7cfe2 Compare January 17, 2024 09:30
@TheJulianJES TheJulianJES changed the title Update quirk calculations of power_factor as pre-requisite for merging home-assistant/core#107641 Update Tuya RCBO quirk power factor calculation for home-assistant/core#107641 Jan 19, 2024
@TheJulianJES
Copy link
Collaborator

The Tuya quirks tests probably need to be corrected to expect the new value then. See:

(and ideally, the HA PR needs to have tests for the added code)

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (729bffd) 87.58% compared to head (9971d01) 87.60%.
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2896      +/-   ##
==========================================
+ Coverage   87.58%   87.60%   +0.02%     
==========================================
  Files         294      295       +1     
  Lines        9010     9030      +20     
==========================================
+ Hits         7891     7911      +20     
  Misses       1119     1119              

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

@jeverley jeverley force-pushed the power_factor_calculation_correct branch from 2180278 to 3c44240 Compare January 22, 2024 10:33
@dmulcahey
Copy link
Collaborator

@TheJulianJES once you are good with this you can merge this and the corresponding HA PR: home-assistant/core#107641

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.

LGTM, thanks!

@TheJulianJES TheJulianJES merged commit 547971c into zigpy:dev Jan 24, 2024
14 checks passed
lgraf pushed a commit to lgraf/zha-device-handlers that referenced this pull request May 6, 2024
…re#107641 (zigpy#2896)

Amend power_factor calculation to respect Zigbee cluster specification - required for release of ZHA fix:
home-assistant/core#107641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants