jrester / tesla_powerwall

Python API for Tesla Powerwall
MIT License
73 stars 24 forks source link

tesla_powerwall.error.AccessDeniedError #23

Closed lordyavin closed 3 years ago

lordyavin commented 3 years ago

Since a while I can't connect to my powerwall anymore. Although I'm using the correct credentials I always get

Traceback (most recent call last):
  File "...\powerwallmon\src\powerwallmon\__main__.py", line 104, in main
    log(host, customer, password)
  File "...\powerwallmon\src\powerwallmon\__init__.py", line 46, in log
    with connect(host, customer, password) as powerwall:
  File "...\powerwallmon\src\powerwallmon\__init__.py", line 41, in connect
    powerwall.login_as(User.CUSTOMER, customer, password)
  File "...\powerwallmon\.venv\lib\site-packages\tesla_powerwall\powerwall.py", line 64, in login_as
    response = self._api.login(user, email, password, force_sm_off)
  File "...\powerwallmon\.venv\lib\site-packages\tesla_powerwall\api.py", line 156, in login
    return self.post(
  File "...\powerwallmon\.venv\lib\site-packages\tesla_powerwall\api.py", line 146, in post
    return self._process_response(response)
  File "...\powerwallmon\.venv\lib\site-packages\tesla_powerwall\api.py", line 90, in _process_response
    self._handle_error(response)
  File "...\powerwallmon\.venv\lib\site-packages\tesla_powerwall\api.py", line 66, in _handle_error
    raise AccessDeniedError(
tesla_powerwall.error.AccessDeniedError: Access denied for resource /api/login/Basic: bad credentials: Login Error

python -version:

Python 3.9.1

pip freeze:

certifi==2020.12.5
chardet==4.0.0
idna==2.10
packaging==20.9
pyparsing==2.4.7
requests==2.25.1
tesla-powerwall==0.3.8
urllib3==1.26.3

Powerwall SW Version:

20.49.0

Someone an idea what is going on?

jrester commented 3 years ago

The order of password and username has changed to allow password only login without a username. You should change the line

powerwall.login_as(User.CUSTOMER, customer, password)

to

powerwall.login_as(User.CUSTOMER, password, customer)
lordyavin commented 3 years ago

Thanks