DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 29 forks source link

Toyota integration is no more working #91

Closed vladurash closed 8 months ago

vladurash commented 2 years ago

Describe the bug

Logger: homeassistant.components.device_tracker
Source: custom_components/toyota/device_tracker.py:19
Integration: Device tracker (documentation, issues)
First occurred: December 2, 2021, 1:23:40 AM (4 occurrences)
Last logged: December 2, 2021, 1:31:48 AM

Error while setting up toyota platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/toyota/device_tracker.py", line 19, in async_setup_entry
    for index, _ in enumerate(coordinator.data):
TypeError: 'NoneType' object is not iterable

HA installed on RPI4 8GB over docker, having buster version of Debian SO. Suddenly stopped to work a week ago.

DurgNomis-drol commented 2 years ago

Have you tried restarting Home Assisting or reloading the integration? It is a known issue that this error can happen, but it should fix it self it integration have been setup, though i am trying to fix it

DurgNomis-drol commented 2 years ago

Just got the same error after a restart. I then restart Home Assistant again and it fixed it. Hope this helps :smile:

vladurash commented 2 years ago

Yes, HA was reloaded,restarted. Also restarted RPI, same error.

DurgNomis-drol commented 2 years ago

Can you add this to configuration.yaml, this will enable better logging and give me some more information about this problem? Remember to restart HA after. After this please post you logs, private information should be censored, but please doublecheck :smiley:

logger:
  default: critical
  logs:
    # log level for HA core
    custom_components.toyota: debug
    mytoyota: debug
vladurash commented 2 years ago

I found following errors during today:

`2021-12-05 09:46:55 DEBUG (MainThread) [httpx._client] HTTP Request: POST https://ssoms.toyota-europe.com/isTokenValid "HTTP/1.1 502 Bad Gateway" 2021-12-05 09:46:55 ERROR (MainThread) [custom_components.toyota] Error when trying to check token:

502 Bad Gateway

502 Bad Gateway

`

and

2021-12-05 09:47:57 ERROR (Recorder) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 186, in state return STATE_ON if self.is_on else STATE_OFF File "/config/custom_components/toyota/binary_sensor.py", line 315, in is_on self.coordinator.data[self.index].sensors.windows, TypeError: 'NoneType' object is not subscriptable

But it seems that now this integration is working again. I suppose that here was an error on Toyota platform.

DurgNomis-drol commented 2 years ago

Thanks! this will help in fixing the problem :smiley:

daha76 commented 2 years ago

Toyota integration isn't working for me and I enabled logging and I saw there a HTTP 400 error. I made several restarts but still the same. Here is the log output, maybe it help :

`Toyota Connected Services This is a custom integration! If you have any issues with this you need to open an issue here: https://github.com/DurgNomis-drol/ha_toyota/issues

2022-03-23 19:49:09 DEBUG (MainThread) [mytoyota] Performing first login 2022-03-23 19:49:09 DEBUG (MainThread) [mytoyota] Getting new token... 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Extracting token from result 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Token is the correct format 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Saving token and uuid 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Getting list of vehicles associated with the account 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': 'L', 'Cookie': 'iPlanetDirectoryPro=L', 'uuid': '2'} 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Base headers: {'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, /*', 'Sec-Fetch-Dest': 'empty', 'X-TME-BRAND': 'TOYOTA'} - Timeout: 15 2022-03-23 19:49:18 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Getting status for vehicle - JTMR63FV7****... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': 'L***', 'Cookie': 'iPlanetDirectoryPro=L***', 'uuid': '2*'} 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Base headers: {'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, /', 'Sec-Fetch-Dest': 'empty', 'X-TME-BRAND': 'TOYOTA'} - Timeout: 15 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': 'L', 'Cookie': 'iPlanetDirectoryPro=L', 'uuid': '2'} 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Base headers: {'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, /*', 'Sec-Fetch-Dest': 'empty', 'X-TME-BRAND': 'TOYOTA'} - Timeout: 15 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': 'L***', 'Cookie': 'iPlanetDirectoryPro=L***', 'uuid': '2*'} 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Base headers: {'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, /', 'Sec-Fetch-Dest': 'empty', 'X-TME-BRAND': 'TOYOTA'} - Timeout: 15 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': 'L', 'Cookie': 'iPlanetDirectoryPro=L', 'uuid': '2***'} 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Base headers: {'Content-Type': 'application/json;charset=UTF-8', 'Accept': 'application/json, text/plain, /', 'Sec-Fetch-Dest': 'empty', 'X-TME-BRAND': 'TOYOTA'} - Timeout: 15 2022-03-23 19:49:20 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-23 19:49:21 DEBUG (MainThread) [custom_components.toyota] HTTP: 400 - {"timestamp":1648061361581,"status":400,"error":"Bad Request","message":"X-TME-APP-VERSION not provided","errorCode":"CMA400"} 2022-03-23 19:49:21 DEBUG (MainThread) [custom_components.toyota] Finished fetching toyota data in 3.414 seconds (success: True)`

DurgNomis-drol commented 2 years ago

@daha76 Please follow your bug over at #101

PGutti commented 2 years ago

Hi, i just re-installed the integration, but still get the python error:

 File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/toyota/sensor.py", line 41, in async_setup_entry
    for index, _ in enumerate(coordinator.data):
TypeError: 'NoneType' object is not iterable

I though it is fixed.. no?

DurgNomis-drol commented 2 years ago

Different things are causing it, the latest one should be fixed, but it can still happen. The Toyota API is unstable sometime without any apparent reason. Usually it will fix it self or you can add it again. Also please make sure you running the latest version.

I am in the middel of rewriting some things in the this integration, but this have been put on hold as i don't have much time right now.

CM000n commented 8 months ago

We recently released version 2.0.0 of the Custom Component with major changes and support for the new Mytoyota API. As we unfortunately cannot provide support for Custom Component versions < v2.0.0, I hereby close your issue. If the issue still applies to the current version, you are of course free to open a new issue. 😊