DurgNomis-drol / ha_toyota

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

TypeError: 'NoneType' object is not subscriptable #101

Closed thekillerpt closed 2 years ago

thekillerpt commented 2 years ago

Describe the bug error TypeError: 'NoneType' object is not subscriptable

To Reproduce Steps to reproduce the behavior:

first setup, just setup my toyota 30mn ago and tried to setup the integration

restart the HA server, HA multiple times, but no luck

no identities are created

with the debug logging this is what i'm getting:

2022-03-22 21:57:07 INFO (MainThread) [custom_components.toyota]

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-22 21:57:07 DEBUG (MainThread) [mytoyota] Performing first login 2022-03-22 21:57:07 DEBUG (MainThread) [mytoyota] Getting new token... 2022-03-22 21:57:09 INFO (MainThread) [pyipma.location] Using Lisboa (G.Coutinho) as weather station for Lisboa 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Extracting token from result 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Token is the correct format 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Saving token and uuid 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Getting list of vehicles associated with the account 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': '7', 'Cookie': 'iPlanetDirectoryPro=7', 'uuid': 'c'} 2022-03-22 21:57:09 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-22 21:57:09 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-22 21:57:09 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Getting status for vehicle - ****... 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': '7***', 'Cookie': 'iPlanetDirectoryPro=7***', 'uuid': 'c*'} 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-22 21:57:10 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-22 21:57:10 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': '7', 'Cookie': 'iPlanetDirectoryPro=7', 'uuid': 'c'} 2022-03-22 21:57:10 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-22 21:57:10 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-22 21:57:11 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': '7***', 'Cookie': 'iPlanetDirectoryPro=7***', 'uuid': 'c*'} 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-22 21:57:11 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-22 21:57:11 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Checking if token has expired... 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Constructing additional headers... 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Additional headers: {'X-TME-LC': 'en-gb', 'X-TME-LOCALE': 'en-gb', 'X-TME-TOKEN': '7', 'Cookie': 'iPlanetDirectoryPro=7', 'uuid': 'c***'} 2022-03-22 21:57:11 DEBUG (MainThread) [mytoyota] Creating client... 2022-03-22 21:57:11 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-22 21:57:11 DEBUG (MainThread) [mytoyota] Body: None - Parameters: None 2022-03-22 21:57:11 DEBUG (MainThread) [custom_components.toyota] HTTP: 400 - {"timestamp":1647986231648,"status":400,"error":"Bad Request","message":"X-TME-APP-VERSION not provided","errorCode":"CMA400"} 2022-03-22 21:57:11 DEBUG (MainThread) [custom_components.toyota] Finished fetching toyota data in 2.021 seconds (success: True)

felalex commented 2 years ago

Similar issue here: 2022-03-23 09:06:04 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up toyota platform for binary_sensor 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/binary_sensor.py", line 29, in async_setupentry for index, in enumerate(coordinator.data): TypeError: 'NoneType' object is not iterable 2022-03-23 09:06:04 ERROR (MainThread) [homeassistant.components.device_tracker] 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_setupentry for index, in enumerate(coordinator.data): TypeError: 'NoneType' object is not iterable 2022-03-23 09:06:04 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up toyota platform for sensor 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/sensor.py", line 41, in async_setupentry for index, in enumerate(coordinator.data): TypeError: 'NoneType' object is not iterable

lkucytowski commented 2 years ago

Same here, was working like a charm for 2 months and stopped

Logger: homeassistant.components.binary_sensor
Source: custom_components/toyota/binary_sensor.py:29 
Integration: Binary Sensor ([documentation](https://www.home-assistant.io/integrations/binary_sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+binary_sensor%22)) 
First occurred: 17:54:30 (1 occurrences) 
Last logged: 17:54:30

Error while setting up toyota platform for binary_sensor
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/binary_sensor.py", line 29, in async_setup_entry
    for index, _ in enumerate(coordinator.data):
TypeError: 'NoneType' object is not iterable
DurgNomis-drol commented 2 years ago

Thanks for reporting the bug guys! I don't have much time at the moment, but are investigating to see if i can make a quick and dirty fix, stay tuned for an update!

DurgNomis-drol commented 2 years ago

Update:

Found out what is causing the error. A new header is needed in the requests made to Toyota's servers. Hopefully I can get this fixed before this week is over. Stay tuned!

For reference, the missing header is: "X-TME-APP-VERSION": "4.4.0"

DurgNomis-drol commented 2 years ago

Just made a release that should fix this, please update 😃

thekillerpt commented 2 years ago

awesome! thanks a lot. i'll try it. is that immediatly available on hacs?

DurgNomis-drol commented 2 years ago

It should be, i just update my installation through HACS

thekillerpt commented 2 years ago

yes, updating :-)

daha76 commented 2 years ago

I just updated and issue is fixed, thanks a lot ;-) My car is back on HA ;-)

lkucytowski commented 2 years ago

Amazing stuff, working back again, thank you to all involved!

felalex commented 2 years ago

Thank you very much! Works again.