Closed BakaNode closed 1 year ago
I'm a new user who hasn't used this library before and I'm seeing the same INVALID PARAMS: -2010 error.
Here is a log with username and password (hopefully) redacted:
DEBUG:root:login = email@example.com, password = ----------, region = NE
Prepare Session
Login...
DEBUG:pycarwings2.pycarwings2:invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/InitialApp_v2.php
DEBUG:pycarwings2.pycarwings2:params: {
"RegionCode": "NE",
"custom_sessionid": "",
"initial_app_str": "9s5rfKVuMrT03RtzajWNcA",
"lg": "en-US"
}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com:443
DEBUG:urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /api_v190426_NE/gdc/InitialApp_v2.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: b'{"status":200,"message":"success","baseprm":"88dSp7wWnV3bvv9Z88zEwg"}'
DEBUG:pycarwings2.pycarwings2:invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/UserLoginRequest.php
DEBUG:pycarwings2.pycarwings2:params: {
"Password": "--------------------",
"RegionCode": "NE",
"UserId": "email@example.com",
"custom_sessionid": "",
"initial_app_str": "9s5rfKVuMrT03RtzajWNcA"
}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): gdcportalgw.its-mo.com:443
DEBUG:urllib3.connectionpool:https://gdcportalgw.its-mo.com:443 "POST /api_v190426_NE/gdc/UserLoginRequest.php HTTP/1.1" 200 None
DEBUG:pycarwings2.pycarwings2:Response HTTP Status Code: 200
DEBUG:pycarwings2.pycarwings2:Response HTTP Response Body: b'{"status":"-2010","message":"INVALID PARAMS","resultKey":""}'
ERROR:pycarwings2.pycarwings2:carwings error INVALID PARAMS: -2010
Traceback (most recent call last):
File "./get-latest-battery.py", line 47, in <module>
leaf = s.get_leaf()
File "/usr/local/lib/python3.5/dist-packages/pycarwings2/pycarwings2.py", line 217, in get_leaf
self.connect()
File "/usr/local/lib/python3.5/dist-packages/pycarwings2/pycarwings2.py", line 191, in connect
"Password": encodedPassword,
File "/usr/local/lib/python3.5/dist-packages/pycarwings2/pycarwings2.py", line 165, in _request
raise CarwingsError("INVALID PARAMS")
pycarwings2.pycarwings2.CarwingsError: INVALID PARAMS
I am in the UK, running this on Python 3.5.3 on a Raspberry Pi using the version installed via Pip3.
@filcole hope you are good. Same for me starting with a fresh HA install and your integration
2021-03-23 08:34:28 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] Response HTTP Status Code: 200 2021-03-23 08:34:28 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":"-2010","message":"INVALID PARAMS","resultKey":""}' 2021-03-23 08:34:28 ERROR (SyncWorker_3) [pycarwings2.pycarwings2] carwings error INVALID PARAMS: -2010 2021-03-23 08:34:28 ERROR (SyncWorker_3) [homeassistant.components.nissan_leaf] An unknown error occurred while connecting to Nissan: <class 'pycarwings2.pycarwings2.CarwingsError'>
Has anyone made any progress with this problem? I decided to check back in again with the latest version of pycarwings2 as I actually do want to use it for something now, but I'm still seeing the same problem with the latest version. And yes, I am running the patch in https://github.com/filcole/pycarwings2/pull/29 which changes the user agent to empty string, but it doesn't seem to be related to my issue.
I've noticed that the password parsing in the example scripts is really bad - I originally had a % character in my Nissan password and that was throwing a Python syntax error complaining about that character (it looks like python was trying to interpret it as a string function instead of passing it through as escaped data) so it occurs to me that the example scripts or pycarwings2 itself may not be handling certain punctuation in passwords very well, and potentially causing this error by mangling the password. (eg the INVALID params reported back by Nissan may just be due to the encoded password being incorrect after being mangled)
Unfortunately the Nissan website does actually require punctuation in the password!
Is anyone using this successfully who could offer any suggestions ? If it works for some people and not others with no apparent correlation maybe it is in fact handling of certain password characters that is the issue since everyone is using different passwords..
Ok, by hard coding the username/password into the s = pycarwings2.Session()
call I've ruled out the config parser module - while something here doesn't handle a percent sign in a password correctly, that's a separate issue and I have a password now which includes !
as the only punctuation to meet the requirement of the Nissan password change page. I'm seeing the same encoded password being sent to the server either way (config parser or hard coded) and still getting back the INVALID PARAMS response.
Not sure what to check next as unlike most other people here I have never had a working configuration, which is a bit harder to troubleshoot than an installation that has previously been working.
One thing I also forgot to mention earlier in this thread is that I have a 2016 30kWh Leaf - which uses the older Nissan Connect EV app, not the newer app used by mid 2018 Leaf 2 and later - could this have a bearing on my issue?
Found the problem. For anyone reading, this was in fact fixed by applying the user agent fix in https://github.com/filcole/pycarwings2/pull/29
I initially installed the pip version of pycarwings2 accidentally when I thought I was installing a locally downloaded copy of the PR with the fix included and didn't realise until I looked at the package in system site-files.
I am puzzled why I had the same issue all the way back in February though.
This is a duplicate of #28 (even though this issue was opened first, the other has more detail) so I'd be inclined to close this.
I think you may have seen this issue in February as well is because there was an intermediate fix #24 which was caused by a change in urllib3.
I'm still seeing this as using Home Assistant OS version: core-2021.9.3:
2021-09-06 12:02:11 DEBUG (SyncWorker_1) [homeassistant.components.nissan_leaf] Logging into You+Nissan
2021-09-06 12:02:11 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/InitialApp_v2.php
2021-09-06 12:02:11 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] params: {
"RegionCode": "NNA",
"custom_sessionid": "",
"initial_app_str": "9s5rfKVuMrT03RtzajWNcA",
"lg": "en-US"
}
2021-09-06 12:02:12 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Status Code: 200
2021-09-06 12:02:12 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":200,"message":"success","baseprm":"88dSp7wWnV3bvv9Z88zEwg"}'
2021-09-06 12:02:12 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/UserLoginRequest.php
2021-09-06 12:02:12 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] params: {
"Password": "REDACTED",
"RegionCode": "NNA",
"UserId": "REDACTED@REDACTED",
"custom_sessionid": "",
"initial_app_str": "9s5rfKVuMrT03RtzajWNcA"
}
2021-09-06 12:02:16 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Status Code: 200
2021-09-06 12:02:16 DEBUG (SyncWorker_1) [pycarwings2.pycarwings2] Response HTTP Response Body: b'{"status":"-2010","message":"INVALID PARAMS","resultKey":""}'
2021-09-06 12:02:16 ERROR (SyncWorker_1) [pycarwings2.pycarwings2] carwings error INVALID PARAMS: -2010
2021-09-06 12:02:16 ERROR (SyncWorker_1) [homeassistant.components.nissan_leaf] An unknown error occurred while connecting to Nissan: <class 'pycarwings2.pycarwings2.CarwingsError'>
The fix didn't make it into that release of Home Assistant -- I don't know why. Looking at the docker image for the current Home Assistant stable release it's still on pycarwings 2.10.
Yep, this has been working fine for me in the last couple of releases of homeassistant. Please see if you can reproduce using the https://github.com/filcole/pycarwings2/tree/master/examples examples with your login credentials.
Sorry if I missed the memo but I can't make heads or tails of this thing. Reading all the separate posts is confusing and fingers are pointing everywhere. I started my journey with HA about exactly a year ago with this Nissan integration and have had this exact problem since then and it's still crazy pants.
What exactly needs to be done to fix this by step?
Sorry for confusing previous posts. I'm now running pycarwings 2.11 and python3. When I do so, I get the same "INVALID PARAMS: -2010" message that I do through HA.
I've experimented, and this is the SAME message that I get when I give a bad username and/or password. This leads me to conclude that somehow my credentials aren't being accepted.
My username is an email address. My password is a fifteen character alphanumeric with a single underscore in the middle.
Does any of this seem unusual?
@DrGomek could it be the region?
@jmason I'm in the US, so I've been using NNA. I also tried NE, NML, and WORLD -- all with the same response
Note that I can set my username and password to ANYTHING and I get the same response.
I would suggest to try a password without '_'. I remember that I had a random password at first, which worked on the 'my leaf' web portal, but didn't work on Carwings. (however I dont recall which special chars I used back then)
Thanks for the suggestion. I updated my password - the only symbol is a "!" now, and I get the same result. :(
Yep, this has been working fine for me in the last couple of releases of homeassistant. Please see if you can reproduce using the https://github.com/filcole/pycarwings2/tree/master/examples examples with your login credentials.
I've had a try with the current HEAD of that tree and the get-leaf-info.py example script is working fine with my credentials at the moment (NE region).
The fix didn't make it into that release of Home Assistant -- I don't know why. Looking at the docker image for the current Home Assistant stable release it's still on pycarwings 2.10.
The good news is that pycarwings 2.11 is now showing up correctly in Home Assistant 2021.9.6 🎉 -- however I think the Nissan backend API change from https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/ to https://gdcportalgw.its-mo.com/api_v210707_NE/gdc/ is now breaking it?
I see this in the debug logs:
2021-09-15 11:35:18 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] invoking carwings API: https://gdcportalgw.its-mo.com/api_v190426_NE/gdc/InitialApp_v2.php
2021-09-15 11:35:18 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] params: {
"RegionCode": "NE",
"custom_sessionid": "",
"initial_app_str": ".......[omitted]",
"lg": "en-US"
}
2021-09-15 11:35:19 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] Response HTTP Status Code: 404
2021-09-15 11:35:19 DEBUG (SyncWorker_3) [pycarwings2.pycarwings2] Response HTTP Response Body: b'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /api_v190426_NE/gdc/InitialApp_v2.php was not found on this server.</p>\n</body></html>\n'
2021-09-15 11:35:19 ERROR (SyncWorker_3) [pycarwings2.pycarwings2] Invalid JSON returned
2021-09-15 11:35:19 ERROR (SyncWorker_3) [homeassistant.components.nissan_leaf] An unknown error occurred while connecting to Nissan: <class 'pycarwings2.pycarwings2.CarwingsError'>
I have hand-applied the change in commit 627f9e18bbead510d4a8f01ff87ddb7ffed08dc1 to my HA's version of pycarwings2 and that fixes it for me.
The base URL has been updated in pycarwings2 for over a year - this can be closed.
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’>