filcole / pycarwings2

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

API stopped working: "The requested URL /api_v210707_NE/gdc/InitialApp_v2.php was not found on this server." #46

Open irekzielinski opened 5 months ago

irekzielinski commented 5 months ago

Im in the UK and noticed API stopped working (Nissan app works OK). This line of code fails:

image

Logged the error message:

`ERROR:pycarwings2.pycarwings2:Invalid JSON returned: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> \

404 Not Found

Not Found

The requested URL /api_v210707_NE/gdc/InitialApp_v2.php was not found on this server.

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/pycarwings2/pycarwings2.py", line 160, in _request j = json.loads(response.text) File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) ` Anyone else seeing this? Thanks!
remuslazar commented 5 months ago

Same here in Germany. The stock Nissan app works, though.

Ez2517-Git commented 5 months ago

Nissan changed the base URL, the new one can be found here:

https://github.com/joeshaw/carwings

irekzielinski commented 5 months ago

Nissan changed the base URL, the new one can be found here:

https://github.com/joeshaw/carwings

Great find! Indeed, this modification fixes the script:

image
josemi73 commented 5 months ago

Thank you @irekzielinski @Ez2517-Git , in my local HAOS I have just updated the BASE_URL:

  1. SSH to HAOS
  2. docker exec -it homeassistant bash
  3. sed -i 's/apiv210707/apiv230317/g' /usr/local/lib/python3.12/site-packages/pycarwings2/pycarwings2.py
  4. I restarted HAOS (I do not know if it is mandatory) and it is working again.
remuslazar commented 5 months ago

I have also crafted #47 which updates the BASE_URL configuration and was able to validate that everything works fine by using this PR on my HA instance.

badi19 commented 5 months ago

i am supprised that an external leaf app continues working. Checking the opensource discover that the endpoint on that app was changed 9 months ago. It seams the author of that app was informed earlier and didn't have to wait and discover the api's don't work anymore.

the app i am reffering to: "my leaf".

mihaicristianpetrescu commented 5 months ago

For anyone who needs access to lower level SSH on a local install check this out: https://developers.home-assistant.io/docs/operating-system/debugging/#generating-ssh-keys Then you can connect and run the commands from this post https://github.com/filcole/pycarwings2/issues/46#issuecomment-2118851968

callalillity commented 5 months ago

I apologise if this is a stupid question - but after i edit the file how do i save changes? When i restart home assistant the api link I've edited reverts back.

josemi73 commented 5 months ago

I apologise if this is a stupid question - but after i edit the file how do i save changes? When i restart home assistant the api link I've edited reverts back.

Press escape key, then write: :wq

remuslazar commented 5 months ago

I apologise if this is a stupid question - but after i edit the file how do i save changes? When i restart home assistant the api link I've edited reverts back.

Press escape key, then write: :wq

or: ESC, then ZZ

ik3huk commented 5 months ago

Nissan Leaf N-Connecta 2023 working again in Italy, thank you so much for the update

Ez2517-Git commented 5 months ago

2023 Leafs do not use Carwings any more, afaik...

Am 20. Mai 2024 00:34:37 MESZ schrieb ik3huk @.***>:

Nissan Leaf N-Connecta 2023 working again in Italy, thank you so much for the update

-- Reply to this email directly or view it on GitHub: https://github.com/filcole/pycarwings2/issues/46#issuecomment-2119380972 You are receiving this because you were mentioned.

Message ID: @.***> -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

josemi73 commented 5 months ago

Thank you @irekzielinski @Ez2517-Git , in my local HAOS I have just updated the BASE_URL:

  1. SSH to HAOS
  2. docker exec -it homeassistant bash
  3. sed -i 's/apiv210707/apiv230317/g' /usr/local/lib/python3.12/site-packages/pycarwings2/pycarwings2.py
  4. I restarted HAOS (I do not know if it is mandatory) and it is working again.

I have replaced the step 3, if anybody don't know how to use 'vi command'

jmason commented 5 months ago

I can confirm this also fixes the problem for me (I'm in Ireland).

Hein1966 commented 5 months ago

Thank you for the update. It works again on my Nissan Leaf 2018.

badi19 commented 5 months ago

I'm afraid this isn't gonna work for homeassistant-core.

Phatfishie commented 5 months ago

I'm afraid this isn't gonna work for homeassistant-core.

I have literally no idea of what to do here! Should I just wait for an HA update? How long might that take please?

Hein1966 commented 5 months ago

First you have to install a ssh terminal in HA: https://www.youtube.com/watch?v=dAmGYrKDpZE and then you can execuse line 2,3 of the solutions.

Phatfishie commented 5 months ago

First you have to install a ssh terminal in HA: https://www.youtube.com/watch?v=dAmGYrKDpZE and then you can execuse line 2,3 of the solutions.

Thanks for this. Have just followed it and it works perfectly!

badi19 commented 5 months ago

Works for me too now. I already had ssh and terminal installed. But not the advanced version. The non-advanced version obviously hasn't docker available. After installing the advanced version and following the instructions my Nissan is available.

Thanks!

arundalep commented 5 months ago

Works for me, (once I realised I needed the advanced ssh addon). Thank you

Tatouille7 commented 5 months ago

Works for me, (once I realised I needed the advanced ssh addon). Thank you

Same here. Thank you very much.

niklasgisselman commented 5 months ago

I'm afraid this isn't gonna work for homeassistant-core.

Any ideas how to solve it for core?

badi19 commented 5 months ago

I'm afraid this isn't gonna work for homeassistant-core.

Any ideas how to solve it for core?

Yes, just follow the instructions above. Bu sure to install the advanced ssh (also if you already installed the basic ssh)

1:

First you have to install a ssh terminal in HA: https://www.youtube.com/watch?v=dAmGYrKDpZE

2: During installation you selected to add terminal to your menu. And in the configuration: unset protectionmodus. Open terminal and perform the steps below beginning with step 2. (You can skip step 1, step 1 is done by opening terminal.

Thank you @irekzielinski @Ez2517-Git , in my local HAOS I have just updated the BASE_URL:

  1. SSH to HAOS
  2. docker exec -it homeassistant bash
  3. sed -i 's/apiv210707/apiv230317/g' /usr/local/lib/python3.12/site-packages/pycarwings2/pycarwings2.py
  4. I restarted HAOS (I do not know if it is mandatory) and it is working again.

In case you make any typo's on step 3 (i did on my mobile phone :-(, in the second part of the replacement apparently): You can also edit the pycarwings2.py using vi. It is not difficult to find the api url. Correct the typo and you're done.

OldSmurf56 commented 5 months ago

TBH, I didn't know what I was doing, but doing this

SSH to HAOS docker exec -it homeassistant bash sed -i 's/apiv210707/apiv230317/g' /usr/local/lib/python3.12/site-packages/pycarwings2/pycarwings2.py

magically worked!. I also restarted my HA. My HA is running as a VM on ESXi 6.7.

Thank you so much @irekzielinski @Ez2517-Git

TyzzyT commented 4 months ago

Not sure if I'm doing something wrong, or if HA changed their folder structure. But it looks like this fix is not working anymore with HA 2024.6.x release. When navigating to /usr/ there is no local folder. image

Using HA OS, running as a VM

badi19 commented 4 months ago

@TyzzyT

Not sure if I'm doing something wrong, or if HA changed their folder structure. But it looks like this fix is not working anymore with HA 2024.6.x release. When navigating to /usr/ there is no local folder.

Using HA OS, running as a VM

As mentioned above: use advanced ssh. I ran into the same problem by using the standard ssh.

TyzzyT commented 4 months ago

I'm using the VM console, which worked a few weeks ago with the HA 2024.5 release. I'll check the advanced SSH add-on.

Tatouille7 commented 4 months ago

I'm using the VM console, which worked a few weeks ago with the HA 2024.5 release. I'll check the advanced SSH add-on.

Advanced ssh worked fine Yesterday for me, as for the previous realeses of HA.

TyzzyT commented 4 months ago

I'm using the VM console, which worked a few weeks ago with the HA 2024.5 release. I'll check the advanced SSH add-on.

Advanced ssh worked fine Yesterday for me, as for the previous realeses of HA.

Advanced SSH add-on is working, thanks!

ORi0N commented 2 months ago

No solution for the pycarwings2 issue yet? Or we need to continue to push this patch after each update of HA?

remuslazar commented 2 months ago

@ORi0N See https://github.com/remuslazar/homeassistant-carwings

RPiSpy commented 1 month ago

Thanks to everyone who provided info for this issue. I finally got the original integration working again by editing the pycarwings2.py file via the Advanced SSH Terminal. I initially struggled to get the Advanced SSH addon to run until I realised that the standard SSH addon was using port 22. You either have to Stop that addon, or change the port that the Advanced SSH addon uses from 22 to something else. e.g. 23.

darnoldser commented 3 weeks ago

When can I expect that a solution makes it into the official Home assistant? So without HACS or workaround.

Thanks for the support on this to everyone who is contributing.