core: Intermittent Wallbox connection errors
The problem
The integration usually works but maybe 1-2 times a week it fails with the following error:
Unexpected error fetching wallbox data:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/wallbox/__init__.py", line 118, in _get_data
data: dict[str, Any] = self._wallbox.getChargerStatus(self._station)
File "/usr/local/lib/python3.10/site-packages/wallbox/wallbox.py", line 73, in getChargerStatus
raise (err)
File "/usr/local/lib/python3.10/site-packages/wallbox/wallbox.py", line 71, in getChargerStatus
response.raise_for_status()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.wall-box.com/chargers/status/<id>
What version of Home Assistant Core has the issue?
2022.10.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
wallbox
Link to integration documentation on our website
https://www.home-assistant.io/integrations/wallbox
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 69 (32 by maintainers)
I too noticed it happening today, and appears to have started 3 days ago. Thanks for working on a fix for this so quickly, and I look forward to the fix becoming available.
Now that Home Assistant supports Bluetooth, any thought on interfacing with the Wallbox locally via Bluetooth to avoid future cloud API issues such as this?
All, thanks for you information. I found the root cause; I think something changed in the API code. To get this fixed I need to get some code merged in the Wallbox Python package (https://github.com/cliviu74/wallbox/pull/19). Afterwards, I also need to bump the package version used by hass. So, no quick fix alas, but I know what needs to be done.
def _authenticate(self) -> None: """Authenticate using Wallbox API.""" try: # Force authentication if the token is about to expire, necessary due to timegap between authenticate and get_data: self._wallbox.jwtToken = "" self._wallbox.authenticate()
This is the fix, you van change this method in the init package of the wallbox integration if you want.
The major release is each first Wednesday of a new month. The beta starts a week before that: the last Wednesday of the month before it.
For 2022.12, that means Wednesday 7 December. The beta for 2022.12 started yesterday (as yesterday was the last Wednesday of November).
Ref: https://www.home-assistant.io/faq/release/
The is an open PR in home assistant project that needs to be merged to fix the issue.
All, so I’m trying to get a very basic fix merged. Problem we are facing is that the Wallbox API token expires too early, causing the connection/security error. I’m now trying to merge a temp solution in which we update the token on every data update (by clearing it first, forcing an update). This works, but is not very nice, however, I haven’t been able to find a better, more reliable solution this weekend… So, temp solution for now. Hopefully something better later.
@hesselonline PR #81852 is scheduled for the next major release (2022.12)
That is correct, we didn’t have a major release in the last 22 days (we have a monthly release cycle for major releases).
If it was meant to be to go into a patch release, it should have been indicated. There are no indications provided in the PRs that they have been safe to put into a bugfix patch release.
When Wallbox becomes unavailable i use homeassistant.reload_config_entry to restart the instance . temp fix until the next bug fix
@hesselonline Sorry, for having a bad weekend because of this. You did great!