-
-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Refactor Vizio integration to use DataUpdateCoordinator #162188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a merge conflict.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Co-Authored-By: Claude Opus 4.5 <[email protected]>
acf581b to
3d60cf6
Compare
There was a problem hiding this 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 the Vizio integration to use the standard DataUpdateCoordinator pattern instead of custom polling logic, improving code maintainability and consistency with Home Assistant best practices.
Changes:
- Introduced
VizioDeviceCoordinatorto centralize device state polling and data management - Refactored
VizioDeviceentity to extendCoordinatorEntityand consume coordinator data - Migrated from
hass.datastorage to theruntime_datapattern with proper type hints viaVizioConfigEntrytype alias - Fixed test assertions to match actual behavior (volume calculations, sound mode handling, power state types)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/vizio/__init__.py |
Creates device and coordinators during setup, uses runtime_data pattern for storing integration data |
homeassistant/components/vizio/coordinator.py |
Adds new VizioDeviceCoordinator class to handle device state polling, device registry updates, and availability tracking |
homeassistant/components/vizio/media_player.py |
Refactored entity to extend CoordinatorEntity, removed custom polling logic, processes coordinator data via callbacks |
tests/components/vizio/conftest.py |
Updated mock paths from media_player to coordinator and init, added mock for get_current_app_config |
tests/components/vizio/test_media_player.py |
Fixed test assertions (volume calculations, power state types), updated mock paths, corrected logging expectations |
Co-Authored-By: Claude Opus 4.5 <[email protected]>
epenet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ensure that you use the new VizioConfigEntry in the coordinator typing
Co-authored-by: epenet <[email protected]>
Co-authored-by: epenet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Addresses PR review feedback: - Move type definitions to coordinator.py to keep typing consistent - Update coordinator classes to use VizioConfigEntry type - Import VizioConfigEntry from coordinator (canonical location) Co-Authored-By: Claude Opus 4.5 <[email protected]>
04dd42d to
5f558f2
Compare
Update async_get_options_flow to use VizioConfigEntry type. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Move VizioConfigEntry and VizioRuntimeData to top of file for better readability. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Move input list transformation to media_player platform. API manipulation and transformation logic should live in the platforms that consume them. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The None value is handled appropriately downstream. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Transform InputItem objects to strings in media_player.py since API manipulation logic belongs in the consuming platform. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Breaking change
Proposed change
Migrate the Vizio integration to use a proper DataUpdateCoordinator for device state polling instead of custom polling logic.
This PR is the prequel to a future new PR to add a remote entity platform so that users can send remote keys to their device. Since remotes also require the is_on state, it made sense to move everything to a coordinator first.
This change:
VizioDeviceCoordinatorto handle device state updatesruntime_datapattern instead ofhass.datafor storing device instanceVizioDeviceto extendCoordinatorEntityVizioConfigEntrytype alias for proper typingType of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: