Skip to content

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Nov 3, 2025

When working on #557 I ran into a bug: diagnostics could not be regenerated for a specific device. For some reason, the cluster handler-specific initialization code did not run.

The cluster handler computed something that realistically should be handled by the entity so I ported the code over into there. This has the benefit of now allowing the summation formatting to change at runtime.

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.91%. Comparing base (76550e0) to head (9b2d5ed).
⚠️ Report is 10 commits behind head on dev.

Files with missing lines Patch % Lines
zha/application/platforms/sensor/__init__.py 93.10% 2 Missing ⚠️
zha/application/platforms/sensor/helpers.py 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #565      +/-   ##
==========================================
- Coverage   96.95%   96.91%   -0.04%     
==========================================
  Files          63       63              
  Lines       10534    10544      +10     
==========================================
+ Hits        10213    10219       +6     
- Misses        321      325       +4     

☔ 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.

"version": 1,
"ieee": "ab:cd:ef:12:b5:0f:0b:2f",
"nwk": "0x5C8B",
"manufacturer": "_TZE200_a7sghmms",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, interesting that it affected this Tuya valve with a v2 quirk. We have a local Metering cluster for that and it's one of the few times we actually do not use kW(h) as the unit for it, but instead water/liters:
https://github.com/zigpy/zha-device-handlers/blob/928268cca5d22a048e72d45ae1c24a1b6dd92a9c/zhaquirks/tuya/builder/__init__.py#L128-L148

Copy link
Contributor

@TheJulianJES TheJulianJES Nov 10, 2025

Choose a reason for hiding this comment

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

Looked through the endpoint/ch initialization code and we skip important parts if "skip configuration" is enabled, both binding and attribute reporting in ch.async_configure but also the ch specific init code in ch.async_initialize, which later runs the ch specific init.
And sure enough, the quirk enables it: zhaquirks/tuya/tuya_valve.py#L115

So, that at least solves the why behind the cluster handler specific initialization code not running.

Moving the Metering cluster formatting out of the cluster handler might actually break the entity displaying the delivered summation, now that the code is executed.
But agreed this is something we should do.

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