Support zigpy 2.0.0#179
Draft
TheJulianJES wants to merge 5 commits into
Draft
Conversation
zigpy 2.0.0 moved the quirks API out of zigpy into zha-device-handlers, so importing CustomDevice/CustomCluster from zigpy.quirks now fails with ModuleNotFoundError (zhaquirks is not, and must not be, a dependency). - Reimplement XBeeGroup/XBeeGroupResponse as plain Groups subclasses kept out of the global cluster registry via _skip_registry. - Reimplement XBeeCoordinator as a zigpy.device.Device that builds its coordinator endpoint and clusters directly instead of via a quirks CustomDevice 'replacement' dict. - Rewrite ControllerApplication.add_endpoint to register endpoints and clusters directly rather than mutating the quirks replacement dict. - Replace the deprecated Device.update_last_seen() call with a direct last_seen assignment.
zigpy 2.0.0 switched its serial layer from pyserial-asyncio-fast to serialx, whose Serial class does not expose a BAUDRATES attribute. The baudrate setter (used when entering AT command mode) relied on self._transport.serial.BAUDRATES and would raise AttributeError. - Define the standard baudrate list on Gateway and validate against it. - Drop the stale 'import serial_asyncio_fast' from the uart tests and patch zigpy.serial.create_serial_connection (what uart.connect actually calls) instead.
- Require zigpy>=2.0.0 (where the quirks API was moved out) instead of the long-outdated 0.70.0 floor. - Require Python >=3.11 to match zigpy 2.0.0, and update the tox env list (py311-py313) and pyupgrade target (--py311-plus) accordingly. - Drop the unused, unmaintained asynctest test dependency; the tests use unittest.mock.
The --py311-plus pyupgrade target rewrites the deprecated asyncio.TimeoutError alias to the builtin TimeoutError and replaces typing.Dict/Optional with builtin generics and PEP 604 unions; autoflake drops the now-unused imports.
CI runs via the shared zigpy/workflows workflow, not tox; the file is no longer referenced.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #179 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 718 736 +18
=========================================
+ Hits 718 736 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
puddly
reviewed
Jun 29, 2026
| {"status": foundation.Status}, | ||
| direction=foundation.Direction.Client_to_Server, | ||
| ), | ||
| } |
Contributor
Contributor
There was a problem hiding this comment.
I'm not actually seeing where this is used. #46 introduced the change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR updates zigpy-xbee to be more compatible with zigpy 2.0.0, without relying on the presence of zha-quirks.
As zha-quirks now depends on ZHA, which pulls in zigpy-xbee, I noticed some test failures of the deprecated
CustomClusterusage in all quirks tests. These are addressed by this.Do note this PR was not tested.
AI summary
Why
zigpy.quirksis now only a deprecation shim that lazily re-importsCustomDevice/CustomClusterfromzhaquirks.legacy. This gives zigpy-xbee an implicit, undeclared dependency onzhaquirks: under Home Assistant it kept working (ZHA installszha-quirks, so the shim resolves — onlyDeprecationWarnings were emitted), but a standalone install fails at import withModuleNotFoundError: No module named 'zhaquirks'. zigpy-xbee should not depend on zha-device-handlers at all.pyserial-asyncio-fasttoserialx, whoseSerialclass has noBAUDRATESattribute. This breaks the baudrate setter on the path that switches baud to auto-enter API mode (init_api_mode); a coordinator already in API mode does not hit it.Changes
XBeeGroup/XBeeGroupResponseas plainGroupssubclasses kept out of the global cluster registry (_skip_registry), andXBeeCoordinatoras azigpy.device.Devicethat builds its endpoint and clusters directly instead of via a quirksCustomDevice.add_endpointregisters endpoints directly rather than mutating a quirksreplacementdict.Device.update_last_seen()call.Gatewayso validation no longer depends on the serial backend.zigpy>=2.0.0(was0.70.0),requires-python>=3.11(was3.8); bump the pyupgrade target to--py311-plus; drop the unused, unmaintainedasynctesttest dependency.tox.ini, which is no longer used (CI runs via the sharedzigpy/workflowsworkflow).asyncio.TimeoutErroralias to the builtinTimeoutError, and replacetyping.Dict/Optionalwith builtin generics and PEP 604 unions (unused imports dropped).Testing
pytest: 105 passed, 100% coverage, withDeprecationWarningtreated as errors.pre-commit(black, flake8, isort, ruff, mypy, pyupgrade, autoflake, codespell) all pass.