filcole / pycarwings2

Python library for interacting with the NissanConnect EV (aka CARWINGS) telematics service.
Apache License 2.0
33 stars 20 forks source link

User Agent problem again? #28

Closed andbad closed 3 years ago

andbad commented 3 years ago

From this morning, the integration doesn't work anymore. I delete the useragent from pycarwings2.py, at line 125, from: headers={"User-Agent": "pycarwings2/2.10"} to

headers={"User-Agent": ""} and now works.

By(t)e

MaxVandenbussche commented 3 years ago

Hello, I had the same issue starting yesterday. Removing the user-agent from the headers indeed solved the problem.

Thanks a lot!

jymbob commented 3 years ago

Well, that's annoying of them. Clearly an explicit change to make life harder for unofficial integrations. Can confirm that setting an empty string is working here.

bwduncan commented 3 years ago

That's extremely annoying. It seems like it fails with User-Agent "pycarwings2/2.0" but not "" or "Mozilla/5.0" so they are clearly upset at this use of the API. My leaf app did not stop working at the same time. Maybe someone should try to get in touch with Nissan and find out what has prompted this change?

jmason commented 3 years ago

I can confirm this issue (and the fix). Is there any chance we could get a 2.11 release with the empty string User-Agent in the meantime?

denilsonsa commented 3 years ago

I wonder if we should just fake the exact User Agent that the official Nissan Leaf app also uses. That would probably future-proof it (or make it harder to detect). Or replace the User Agent with a message to the Nissan developers.

jmason commented 3 years ago

@filcole I'd be happy to get a PR together if you like...

andbad commented 3 years ago

Or replace the User Agent with a message to the Nissan developers.

Ahaha, good idea. :-D

By(t)e

jmason commented 3 years ago

Here's a PR: https://github.com/filcole/pycarwings2/pull/29 . It just reverts back to sending an empty string, since I know that works, and I suspect Nissan will block any other identifiable User-Agent :(

pnlrogue1 commented 3 years ago

@filcole Any chance of a merge? The PR is consistent with the discussion in this thread

pnlrogue1 commented 3 years ago

Made the change proposed here and my app started running normally again

staspika commented 3 years ago

How about, instead of hardcoding the user agent, let "pycarwings2/2.10" (or empty string, or whatever) be default in the library, but allow to override it from the user program?

TomTorger commented 3 years ago

Still experiencing this issue... I guess we have both a quick fix and a solution which will require a bit more coding?

andbad commented 3 years ago

Still experiencing this issue... I guess we have both a quick fix and a solution which will require a bit more coding?

At the moment I can't even log into the Nissan EV app. So, I think that the problem is in Nissan server, not in integration.

By(t)e

jmason commented 3 years ago

At the moment I can't even log into the Nissan EV app. So, I think that the problem is in Nissan server, not in integration.

I have a locally-hacked HomeAssistant with my workaround in place and it has been reliably reporting charge levels from my car for several months (including this morning).

TomTorger commented 3 years ago

Same here, works. :-) However, I have to re-do the change every time I update my home assistant image... Could perhaps split the pycarwings directory out as a separate volume... Or sell the car. A lot of nice electric cars out there these days :-)

DrGomek commented 3 years ago

I’m running a pretty stock rpi home assistant and don’t really know how to incorporate this fix into my environment.

I’m happy to take some coaching on doing so, but would be more interested in learning what it would take to get this “fix” incorporated into the main build.

bwduncan commented 3 years ago

@filcole I hope you are OK. It would be good to get this fixed in a more sustainable way, without having to fork this repo.