Skip to content

Conversation

@Koenkk
Copy link
Owner

@Koenkk Koenkk commented Oct 28, 2025

Based on feedback given in Koenkk/zigbee2mqtt#11767

@Koenkk Koenkk requested review from Nerivec and Copilot October 28, 2025 21:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors socket and backup utility functions by consolidating them into a single src/adapter/utils.ts file. The changes eliminate code duplication and improve maintainability by centralizing common adapter utilities.

Key changes:

  • Moves isTcpPath and parseTcpPath functions from socketPortUtils.ts to utils.ts
  • Adds a new readBackup function to utils.ts for centralized backup file reading
  • Updates all adapter files to use the new centralized utility functions
  • Removes the obsolete socketPortUtils.ts file

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/adapter/utils.ts New centralized utility file containing TCP path parsing and backup reading functions
src/adapter/socketPortUtils.ts Deleted file - functionality moved to utils.ts
src/adapter/zoh/adapter/zohAdapter.ts Updated import to use new utils location
src/adapter/zigate/driver/zigate.ts Updated imports and function calls to use new utils location
src/adapter/zboss/uart.ts Updated imports and function calls to use new utils location
src/adapter/z-stack/znp/znp.ts Updated imports and function calls to use new utils location
src/adapter/z-stack/adapter/adapter-backup.ts Refactored to use new centralized readBackup function
src/adapter/ezsp/driver/uart.ts Updated imports and function calls to use new utils location
src/adapter/ezsp/adapter/backup.ts Refactored to use new centralized readBackup function
src/adapter/ember/uart/ash.ts Updated imports and function calls to use new utils location
src/adapter/ember/adapter/emberAdapter.ts Refactored to use new centralized readBackup function, removed unused imports
src/adapter/deconz/driver/driver.ts Updated imports and function calls to use new utils location
src/adapter/deconz/adapter/deconzAdapter.ts Refactored to use new centralized readBackup function

@Nerivec
Copy link
Collaborator

Nerivec commented Oct 28, 2025

Somewhat related, should LegacyBackupStorage be deprecated (removal in 3.0.0)?

Should also look into moving the entire "port" (serial or tcp) out of drivers, we can init it from Adapter, and send it to the driver.

@Koenkk
Copy link
Owner Author

Koenkk commented Oct 30, 2025

Agree with both points, I think the only con of removing LegacyBackupStorage is that users that update from very old z2m versions will get an error.

Ready for merge?

@Koenkk Koenkk merged commit fab29b6 into master Nov 2, 2025
4 checks passed
@Koenkk Koenkk deleted the fix/adapter-backup branch November 2, 2025 20:10
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.

3 participants