home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.56k stars 30.74k forks source link

Nissan Leaf integration appears to be broken again. #49194

Closed DrGomek closed 3 years ago

DrGomek commented 3 years ago

This appears to be broken again.

HA log: carwings error INVALID PARAMS: -2010

An unknown error occurred while connecting to Nissan: <class ‘pycarwings2.pycarwings2.CarwingsError’>

Originally posted by @BakaNode in https://github.com/home-assistant/core/issues/43312#issuecomment-768790023

DrGomek commented 3 years ago
Version core-2021.4.4
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.7
Operating System Family Linux
Operating System Version 5.4.83-v7l
CPU Architecture armv7l
Timezone America/New_York

2021-04-13 20:21:18 DEBUG (SyncWorker_1) [homeassistant.components.nissan_leaf] Logging into You+Nissan 2021-04-13 20:21:18 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/InitialApp_v2.php 2021-04-13 20:21:18 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] params: { "RegionCode": "NNA", "custom_sessionid": "", "initial_app_str": "9s5rfKVuMrT03RtzajWNcA", "lg": "en-US" } 2021-04-13 20:21:19 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Status Code: 200 2021-04-13 20:21:19 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":200,"message":"success","baseprm":"88dSp7wWnV3bvv9Z88zEwg"}' 2021-04-13 20:21:19 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/UserLoginRequest.php 2021-04-13 20:21:19 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] params: { "Password": "REDACTED", "RegionCode": "NNA", "UserId": "REDACTED", "custom_sessionid": "", "initial_app_str": "9s5rfKVuMrT03RtzajWNcA" } 2021-04-13 20:21:22 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Status Code: 200 2021-04-13 20:21:22 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":"-2010","message":"INVALID PARAMS","resultKey":""}' 2021-04-13 20:21:22 ERROR (SyncWorker_1) [pycarwings2.pycarwings2] carwings error INVALID PARAMS: -2010 2021-04-13 20:21:22 ERROR (SyncWorker_1) [homeassistant.components.nissan_leaf] An unknown error occurred while connecting to Nissan: <class 'pycarwings2.pycarwings2.CarwingsError'>

probot-home-assistant[bot] commented 3 years ago

Hey there @filcole, mind taking a look at this issue as its been labeled with an integration (nissan_leaf) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

jmason commented 3 years ago

As noted here -- https://community.home-assistant.io/t/nissan-leaf-component-s-platform/38663/506 -- it appears that the Nissan servers are erroring based on a User-Agent field sent by the pycarwings2 library. I applied the fix mentioned in that comment, replacing the User-Agent field with an empty string, and it started working again for me.

Looks like the dodgy User-Agent was added here: https://github.com/filcole/pycarwings2/commit/4005247aa51127f8b999ebdbeb15c48bceb8390e and is new in pycarwings2 2.10.

DrGomek commented 3 years ago

I have updated to core-2021.8.8 which I thought consumed the new pycarwings2 library, but the error persists.

dcnoren commented 3 years ago

Still an issue in 2021.9

jmason commented 3 years ago

as described in https://github.com/filcole/pycarwings2/issues/26#issuecomment-919905673 , pycarwings 2.11 is now in HA 2021.9.6 and should be working, but unfortunately I think Nissan have made another breaking API change. details in that comment.