Skip to content

Comments

Refactor Zaptec integration for prepping to adopt to API policy#203

Merged
sveinse merged 4 commits intocustom-components:masterfrom
sveinse:feature-refactor-ha-integration
Jul 21, 2025
Merged

Refactor Zaptec integration for prepping to adopt to API policy#203
sveinse merged 4 commits intocustom-components:masterfrom
sveinse:feature-refactor-ha-integration

Conversation

@sveinse
Copy link
Collaborator

@sveinse sveinse commented Jul 19, 2025

This PR introduces a lot of refactoring to do several things

  • Modernize the way the integration is set up - move toward HA coding ideals, keeping the door open to future inclusion into HA.
  • Introduce a ZaptecManager that will later allow us to store multiple coordinator. This will be required to do the elaborate polling setup that Zaptec wants, see Zaptec polling intervals #202

Detailed improvements:

  • Introduced ZaptecManager to handle instance data and coordination of updates.
  • It is the preparation for running multiple coordinators
  • Updated async_setup_entry() to utilize the new manager
  • Refactored entity creation methods to be part of the manager
  • Check for zaptec attribute availability when creating the entity. If not available, skip the addition
  • Adjusted all platform files (binary_sensor, button, lock, number, sensor, switch, update) to align with the new structure.
  • Fix how ZaptecBaseEntity._handle_coordinator_update() is managing error and logging - simplifies footprint in each entity
  • Update diagnostics. Now working for both device and config entry use.
  • Cleaned up unnecessary imports and comments, enhancing code readability.
  • Removed YAML import step from config flow as it is no longer needed.

…anization and maintainability

- Introduced ZaptecManager to handle instance data and coordination of updates.
- It is preparations for running multiple coordinators
- Updated async_setup_entry to utilize the new manager
- Refactored entity creation methods to be part of the manager
- Adjusted all platform files (binary_sensor, button, lock, number, sensor, switch, update) to align with the new structure.
- Cleaned up unnecessary imports and comments, enhancing code readability.
- Removed YAML import step from config flow as it is no longer needed.
@sveinse sveinse added this to the v0.8 milestone Jul 20, 2025
* Check for zaptec attribute availability when creating the entity. If not available, skip the addition
* Remove `ZaptecBaseEntity.async_added_to_hass()` - no longer needed
* Fix how `ZaptecBaseEntity._handle_coordinator_update()` is managing error and logging - simplifies footprint in each entity
* Make a specific error `KeyUnavailableError` for dealing with unreachable zaptec attributes
* Update diagnostics. Now working for both device and config entry use.
@sveinse sveinse marked this pull request as ready for review July 20, 2025 23:32
@sveinse
Copy link
Collaborator Author

sveinse commented Jul 21, 2025

@steinmn If you have the opportunity, it would be great if you could take a look at this. I have (finally) a working fix for the proper poll intervals, but I cannot add the PR before this has been merged.

Copy link
Contributor

@steinmn steinmn left a comment

Choose a reason for hiding this comment

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

Just nitpicks/comments/questions from my side, so I'll mark it as approved and let you decide if you want to ignore them, address them in this PR or in a followup.

@sveinse
Copy link
Collaborator Author

sveinse commented Jul 21, 2025

Thank you @steinmn . Good feedback. I've pushed an update that fixes all of them. Since they are all nitpicks, we don't need to go another round of reviews.

@sveinse sveinse merged commit 7031992 into custom-components:master Jul 21, 2025
1 check passed
@sveinse sveinse deleted the feature-refactor-ha-integration branch July 22, 2025 13:21
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