Closed andbad closed 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!
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.
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?
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?
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.
@filcole I'd be happy to get a PR together if you like...
Or replace the User Agent with a message to the Nissan developers.
Ahaha, good idea. :-D
By(t)e
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 :(
@filcole Any chance of a merge? The PR is consistent with the discussion in this thread
Made the change proposed here and my app started running normally again
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?
Still experiencing this issue... I guess we have both a quick fix and a solution which will require a bit more coding?
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
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).
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 :-)
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.
@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.
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"}
toheaders={"User-Agent": ""}
and now works.By(t)e