-
-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
Summary
Migrate the integration from individual entity polling (SCAN_INTERVAL + async_update) to Home Assistant's recommended DataUpdateCoordinator pattern for centralized, efficient data fetching.
Current Implementation
The integration currently uses the legacy polling pattern with:
SCAN_INTERVALdefined per platform (e.g., 30s for lights/switches, 10s for locks)- Individual
async_update()methods on each entity - Callback functions for push updates (
async_update_callback)
This results in:
- Multiple API calls when many entities of the same type exist
- No automatic deduplication of requests
- Manual error handling per entity
Proposed Changes
Adopt the DataUpdateCoordinator pattern as documented in Home Assistant Developer Docs.
Benefits
- Single API call fetches data for all entities of a type
- Automatic optimization - only polls when entities are listening
- Built-in error handling with retry logic and rate-limit backoff
- Reduced state writes when data hasn't changed (
always_update=False) - Cleaner code - entities extend
CoordinatorEntityfor automatic updates
Implementation Steps
- Create coordinator classes (e.g.,
WyzeLightCoordinator,WyzeSwitchCoordinator) - Override
_async_update_data()to fetch device data from wyzeapy - Use
async_config_entry_first_refresh()during setup - Migrate entity classes to extend
CoordinatorEntity - Remove
SCAN_INTERVALand individualasync_update()methods - Keep existing callback mechanism for push-based updates where applicable
Platforms to Migrate
-
light.py -
switch.py -
lock.py -
sensor.py -
climate.py -
camera.py -
binary_sensor.py -
alarm_control_panel.py
References
Metadata
Metadata
Assignees
Labels
No labels