UnlockCharger Giving Error
Closed this issue · 5 comments
I am a super noob with Python so very well could be an issue on my end. Please see below, and let me know if I need to provide anything else.
My script outputs the result of the line below correctly so I believe the unlock should work.
"print(f"Charger {charger_id} lock status {chargerStatus['config_data']['locked']}")"
If I add the line below to my script, I get errors. I've pasted them below.
w.unlockCharger(charger_id)
##############################################
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\josep\AppData\Roaming\Python\Python310\site-packages\wallbox\wallbox.py", line 108, in unlockCharger
raise (err)
File "C:\Users\josep\AppData\Roaming\Python\Python310\site-packages\wallbox\wallbox.py", line 106, in unlockCharger
response.raise_for_status()
File "C:\Users\josep\AppData\Roaming\Python\Python310\site-packages\requests\models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.wall-box.com/v2/charger/****** <-actual ID is here
##############################################
It looks like you are not authenticated, can you please share the code you are using to unlock the charger (please don't forget to redact your credentials - username and password)
If you want, you can use the test script provided in this repo example-get-chargers.py, not forgetting to set the environment variables with your crendentials
export WALLBOX_USER="your-user@domain.tld"
export WALLBOX_PASS="your-password"
python3 example-get-chargers.py
Thanks for the quick response. I put ***** in place of the actual information.
If I run the following code, I get the status:
from wallbox import Wallbox, Statuses
wallboxUsername = "*******"
wallboxPassword = "*******"
w = Wallbox(wallboxUsername, wallboxPassword)
# Authenticate with the credentials above
w.authenticate()
# Print a list of chargers in the account
print(f"Chargers under the account {wallboxUsername}: {w.getChargersList()}")
for chargerId in w.getChargersList():
print(f"Charger status for {chargerId}: {Statuses(w.getChargerStatus(chargerId)['status_id']).name}")
If I add the w.unlockCharger before the print, it doesn't work.
from wallbox import Wallbox, Statuses
wallboxUsername = "*******"
wallboxPassword = "*******"
w = Wallbox(wallboxUsername, wallboxPassword)
# Authenticate with the credentials above
w.authenticate()
# Print a list of chargers in the account
print(f"Chargers under the account {wallboxUsername}: {w.getChargersList()}")
for chargerId in w.getChargersList():
w.unlockCharger(chargerId)
print(f"Charger status for {chargerId}: {Statuses(w.getChargerStatus(chargerId)['status_id']).name}")
I'm getting the same error as before. Should it work the way I've put it together?
It looks like you are not authenticated, can you please share the code you are using to unlock the charger (please don't forget to redact your credentials - username and password)
If you want, you can use the test script provided in this repo example-get-chargers.py, not forgetting to set the environment variables with your crendentials
export WALLBOX_USER="your-user@domain.tld" export WALLBOX_PASS="your-password" python3 example-get-chargers.py
Hmm, that's interesting, an authentication error would need to return a 401 instead of 403.
The code you're using looks good to me (works on my machine :) ) so I don't see any reason not to work for you. But there may be a problem that's not showing up on my side.
Can you check a few things for:
- do you have more than 1 EV charger in your account?
- what is the charger model you are trying to set?
- can you please check the OCPP settings in the app (is OCPP Enabled)?
- does unlock work well in the app? I assume so ..
It's definitely something worth looking into as the 403 behavior is strange. May also be a sign of some restrictions on the Wallbox side, maybe some throttling of sorts.
Thanks!
Again thanks for the quick response!
It is working now. The account I was using was a "user" account. I made the account an "admin" account and now it works. I'm using multiple accounts to track the charging of more than one vehicle for two people. It is odd that the unlock works in the app with the "user" account but apparently not through the API with a "user" account.
Thank you for the help and the Python module.
- do you have more than 1 EV charger in your account? -- No, just 1
- what is the charger model you are trying to set? -- Pulsar Plus
- can you please check the OCPP settings in the app (is OCPP Enabled)? -- It is not enabled
- does unlock work well in the app? I assume so .. -- It does work in the app.
Ha, good catch, makes sense. Wallbox's user manual seems to suggest that regular users have only access to statistics.
Thanks for sharing this here.