Refactor: Move sync logic ownership from binary sensor to coordinator #730
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.
Proposed change
This refactoring addresses the "locks out of sync" issue by centralizing sync operations in the coordinator rather than having them scattered across the binary sensor entity.
Key changes:
Coordinator (
coordinator.py):async_request_sync()to execute set/clear operations with automatic retriesmark_synced()/mark_out_of_sync()for per-slot sync state managementget_sync_state()for binary sensor to read sync status_pending_retriesdict for per-slot retry trackingBinary sensor (
binary_sensor.py):is_onproperty from coordinator_retry_unsub,_retry_active,_schedule_retry,_perform_sync_operation,_cancel_retry- all moved to coordinatorInit (
__init__.py):async_update_listener(~240 lines) into focused helper functions:_ConfigDiffdataclass for computed differences_compute_config_diff(),_setup_new_platforms()_handle_locks_removed(),_handle_locks_added()_handle_slots_removed(),_handle_slots_added()_handle_slots_modified()Type of change
Additional information