Skip to content

Conversation

@TheJulianJES
Copy link
Contributor

@TheJulianJES TheJulianJES commented Jan 29, 2026

This PR fixes an issue where multiple read/write methods overwrote the default manufacturer code with None, even though we should now be using UNDEFINED with the recent zigpy 0.91.x changes.

Since we use the UNDEFINED default in ZHA for reading attributes (during initialization), this also works around the issue of quirks overriding read_attributes with manufacturer=None as the default.

Due to the improved manufacturer code handling in zigpy, we do not need to determine the manufacturer code ourselves anymore. It should also fix an issue where batch-reading attributes during initialization always used a manufacturer code or not, messing up mixed reads.

manufacturer=UNDEFINED calls are expected in a lot of places in tests now.

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

Thanks! I've reverted the changes in the other PR to keep it small.

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

It looks like the other PR still needs the send_attributes_report from zigpy, as we do not account for the manufacturer code when creating the attribute reports.

@TheJulianJES
Copy link
Contributor Author

It's also needed in this PR, so uh, we can put it in this one and rename it? (or create a separate one)

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

Let's put it into this one

@TheJulianJES TheJulianJES force-pushed the tjj/fix_manufacturer_code_default branch from 7b28196 to 709bba0 Compare January 29, 2026 20:14
@TheJulianJES TheJulianJES changed the title Fix ZHA overriding default manufacturer code Update ZHA manufacturer code handling for zigpy 0.91.x Jan 29, 2026
@TheJulianJES
Copy link
Contributor Author

TheJulianJES commented Jan 29, 2026

The remaining error with the Tuya FrostLockResetButton seems a bit weird. TuyaClusterData seems to only use the manufacturer code for us. I guess we can just change the type there to also include UndefinedType. Still taking a look..
We may also wanna run zha-quirks tests (especially the fragile Tuya conversion) with the latest zigpy changes.

Failing test here:

 tests/test_button.py::test_frost_unlock - ValueError: Failed to convert manufacturer=<UndefinedType._singleton: 0> from type <enum 'UndefinedType'> to int | None

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

Looks like a few fail:

FAILED tests/test_bosch.py::test_bosch_radiator_thermostat_II_write_attributes - KeyError: None
FAILED tests/test_bosch.py::test_bosch_radiator_thermostat_II_read_attributes_paused - KeyError: None
FAILED tests/test_xiaomi.py::test_xiaomi_e1_thermostat_rw_redirection[system_mode-unoccupied_heating_setpoint] - KeyError: None
FAILED tests/test_xiaomi.py::test_xiaomi_e1_thermostat_rw_redirection[28-20] - KeyError: None

@TheJulianJES
Copy link
Contributor Author

If it's only the attribute redirection, I think that shouldn't affect ZHA with this PR, since we explicitly pass UNDEFINED now (which is also not ideal, but we can remove that when quirks are all updated I guess).

I'll take a look at zha-quirks, since it needs to be updated for the TuyaClusterData change anyway. We may be able to just update the defaults for the manufacturer in read_attributes/write_attributes.

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

I think most methods that override attribute reading/writing can probably pass through **kwargs, without needing to care about manufacturer

@puddly
Copy link
Contributor

puddly commented Jan 29, 2026

ZHA tests pass with the above quirks PR so I think this should resolve the manufacturer problem!

@TheJulianJES TheJulianJES force-pushed the tjj/fix_manufacturer_code_default branch from 709bba0 to a24b9e1 Compare January 30, 2026 01:25
@TheJulianJES TheJulianJES marked this pull request as ready for review January 30, 2026 01:26
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.29%. Comparing base (be4aa43) to head (a24b9e1).
⚠️ Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #637      +/-   ##
==========================================
- Coverage   97.29%   97.29%   -0.01%     
==========================================
  Files          62       62              
  Lines       10716    10712       -4     
==========================================
- Hits        10426    10422       -4     
  Misses        290      290              

☔ 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 merged commit 82bd715 into zigpy:dev Jan 30, 2026
9 checks passed
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