DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
143 stars 27 forks source link

"Unknown Error Occurred" message at the beginning of the setup #261

Open dentex opened 4 months ago

dentex commented 4 months ago

Describe the bug Cannot perform login, at the beginning of the integration's setup. Please see the Additional context section below.

To Reproduce Steps to reproduce the behavior:

  1. I installed this custom integration from HACS
  2. I restarted HASS
  3. Upon setting up the integration I simply typed username and password
  4. Error

Expected behavior Successful login or more clear error message.

Screenshots hacs_toyota

Additional context

  1. I had the old version working. I removed it some time ago when I migrated to the new Toyota Android app, that is working good. The old custom integration stopped working. I restarted/rebooted since then. I noticed that there is now the new version compatible with the new MyToyota API, so I wanted to try it.
  2. I double checked my username and password: they are correct.
  3. Your Python library is working on my laptop, where I used the same credentials:
(mytoyota) sam@mypc ~ $ python simple_client_example.py
Logging in...
Retrieving cars...
('Dashboard: odometer=[...]

I'm running HASS on a Raspberry Pi 4

Core 2024.2.2
Frontend 20240207.1
hmattiasl commented 1 month ago

I had the same issue. It was resolved when I updated Home Assistant to the latest version of Home Assistant Core 2024.7.3.

mkumot commented 1 month ago

I've the same issue: Raspberry 5, Python3.12 Home assistant Core 2024.7.3 Error recorded on the log is "ERROR (MainThread) [custom_components.toyota.config_flow] An unknown error occurred during login request: [Errno 13] Permission denied: '.cache'"

amaximus commented 3 weeks ago

I have the same issue in HA Core 2024.8.0, but it was the same in 2024.7.x as well. In debug mode it says:

2024-08-15 19:23:15.470 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/home/me/.cache/toyota_credentials_cache_contains_secrets', 'r') inside the event loop by custom integration 'toyota' at custom_components/toyota/config_flow.py, line 38: client = MyT( (offender: /home/me/ha_venv3_12/lib/python3.12/site-packages/mytoyota/controller.py, line 56: with open(str(CACHE_FILENAME), "r", encoding="utf-8") as f:), please create a bug report at https://github.com/DurgNomis-drol/ha_toyota/issues

followed by a long stack trace. Because of this in non-debug mode it says:

: 
  File "/home/atticus/ha_venv3_12/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
  File "/home/atticus/homeassistant_conf/custom_components/toyota/config_flow.py", line 38, in async_step_user
    client = MyT(
2024-08-15 19:23:15.531 ERROR (MainThread) [custom_components.toyota.config_flow] An unknown error occurred during login request: [Errno 13] Permission denied: '.cache'

while the file is readable:

(ha_venv3_12)~/homeassistant_conf $ls -l ../.cache/toyota_credentials_cache_contains_secrets
-rw-r--r-- 1 me me 2831 Jul 24 19:36 ../.cache/toyota_credentials_cache_contains_secrets
(ha_venv3_12) ~/homeassistant_conf $ file ../.cache/toyota_credentials_cache_contains_secrets
../.cache/toyota_credentials_cache_contains_secrets: JSON data
(ha_venv3_12) ~/homeassistant_conf $

According to the dev guides, file i/o operations should not be done inside the event loop, thus initialization of the MyT client should not be done on the event loop.

dentex commented 2 weeks ago

Same with latest V2.0.4

dentex commented 1 week ago

I updated python to v3.12.4, HA to latest 2024.8.3 and still same issue... Then, someone suggested me to delete this integration's cache, so I did

cd /home/homeassistant/.cache/
rm -rf toyota_credentials_cache_contains_secrets

and now it's working... Just for you to know.

amaximus commented 1 week ago

My comment from Aug 15 is still valid even if I remove the $HOME/.cache/toyota_credentials_cache_contains_secrets.

(ha_venv3_12) thin620t:~/homeassistant_conf $tail -1 home-assistant.log
2024-09-01 19:35:46.736 ERROR (MainThread) [custom_components.toyota.config_flow] An unknown error occurred during login request: [Errno 13] Permission denied: '.cache'
(ha_venv3_12) thin620t:~/homeassistant_conf $curl -H @hass_header.txt http://192.168.1.32:8123/api/states/update.toyota_connected_services_europe_update
{"entity_id":"update.toyota_connected_services_europe_update","state":"off","attributes":{"auto_update":false,"installed_version":"v2.0.5","in_progress":false,"latest_version":"v2.0.5","release_summary":null,"release_url":"https://github.com/DurgNomis-drol/ha_toyota/releases/v2.0.5","skipped_version":null,"title":null,"entity_picture":"https://brands.home-assistant.io/_/toyota/icon.png","friendly_name":"Toyota Connected Services Europe update","supported_features":23},"last_changed":"2024-08-31T18:19:11.052714+00:00","last_reported":"2024-08-31T18:19:11.052714+00:00","last_updated":"2024-08-31T18:19:11.052714+00:00","context":{"id":"01J6MTK7ACQA68JW2R9AVNABC3","parent_id":null,"user_id":null}}
(ha_venv3_12) thin620t:~/homeassistant_conf $curl -H @hass_header.txt http://192.168.1.32:8curl -H @hass_header.txt http://192.168.1.32:8123/api/states/sensor.current_version
{"entity_id":"sensor.current_version","state":"2024.8.3","attributes":{"friendly_name":"Current Version"},"last_changed":"2024-08-31T18:19:10.096740+00:00","last_reported":"2024-08-31T18:19:10.096740+00:00","last_updated":"2024-08-31T18:19:10.096740+00:00","context":{"id":"01J6MTK6CG7VXC1H17M771R38E","parent_id":null,"user_id":null}}
(ha_venv3_12) thin620t:~/homeassistant_conf $