-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Wallbox Integration, Reduce API impact by limiting the amount of API calls made #147618
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
Wallbox Integration, Reduce API impact by limiting the amount of API calls made #147618
Conversation
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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 reduces the number of API calls made by the Wallbox integration by reusing post request responses and removing redundant pre-setup checks. Key changes include updating the API call handling in the coordinator, revising the post response handling for number and lock entities, and adjusting tests to match the new API interaction patterns.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/components/wallbox/test_switch.py | Added patch for getChargerStatus to support reusing API post responses. |
tests/components/wallbox/test_select.py | Updated tests to patch getChargerStatus with new response structures based on mode. |
tests/components/wallbox/test_number.py | Modified mocks to reflect nested response structures and updated test function naming. |
tests/components/wallbox/test_lock.py | Updated lock tests to match the new response format from lockCharger and unlockCharger. |
homeassistant/components/wallbox/number.py | Removed redundant pre-setup checks and streamlined error handling. |
homeassistant/components/wallbox/lock.py | Removed pre-setup authorization checks for lock actions. |
homeassistant/components/wallbox/coordinator.py | Refactored setter methods to return updated data and use async_set_updated_data; revised error handling. |
homeassistant/components/wallbox/const.py | Added new keys for parsing nested post responses. |
Comments suppressed due to low confidence (1)
tests/components/wallbox/test_number.py:293
- [nitpick] Ensure consistent naming for tests and API method references. The switch from 'setIcpMaxCurrent' to 'setMaxChargingCurrent' in test names might confuse readers; consider aligning the naming consistently across tests to reflect the unified API.
async def test_wallbox_number_class_icp_energy_auth_error(
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.
Thanks, @hesselonline 👍
../Frenck
Proposed change
After a meeting with the Wallbox software team, it was agreed upon that we would try to limit the no of API requests necessary in the integration. This PR does so by:
Resulting test errors have been fixed, also, a missing mock for both the select and switch test has been added to ensure code coverage.
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: