hacf-fr / renault-api

https://readthedocs.org/projects/renault-api/
MIT License
109 stars 38 forks source link

Setting charge mode started failing #1223

Open slyoldfox opened 5 months ago

slyoldfox commented 5 months ago

About a day or two ago, the /charge-mode endpoint started failing.

$ /renault-api --debug charge mode --set schedule_mode
WARNING:renault_api:Debug output enabled. Logs may contain personally identifiable information and account credentials! Be sure to sanitise these logs before sending them to a third party or posting them online.
DEBUG:renault_api.kamereon:Send Kamereon POST request to https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx/kamereon/kca/car-adapter/v1/cars/VIN/actions/charge-mode?country=BE with body: {"data": {"type": "ChargeMode", "attributes": {"action": "schedule_mode"}}}
DEBUG:renault_api.kamereon:Received Kamereon response 404 on POST to https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx/kamereon/kca/car-adapter/v1/cars/VIN/actions/charge-mode?country=BE: {"type":"FUNCTIONAL","messages":[{"code":"err.func.wired.not-found","message":"The specified url does not exist"}],"errors":[{"errorCode":"err.func.wired.not-found","errorMessage":"The specified url does not exist"}],"error_reference":"FUNCTIONAL"}
Error: ('err.func.wired.not-found', 'The specified url does not exist')

Retrieving still seems to work:

$ renault-api charge mode
Charge mode: schedule_mode
slyoldfox commented 5 months ago

This is on 0.2.3 by the way.

Also weird .. I had to revert hvacStatus back to hvacStatus: Optional[str] - is anyone else seeing this? Did they revert their change?

Zaphod-dev commented 5 months ago

Also weird .. I had to revert hvacStatus back to hvacStatus: Optional[str] - is anyone else seeing this? Did they revert their change?

I confirm that after having previously upgraded to 0.2.3 because of the hvacStatus change, I also just now had to revert int back to str - what the heck are they up to ?...

bizoo commented 5 months ago

This is on 0.2.3 by the way.

Also weird .. I had to revert hvacStatus back to hvacStatus: Optional[str] - is anyone else seeing this? Did they revert their change?

Same here, and same for set charge mode. Someone at Renault need to learn about managing api endpoint version...

epenet commented 5 months ago

Yeah - it's infuriating!!! It's not specific to this project - even the phone app seems to be breaking every other day with their dodgy endpoint changes.

I'm happy to take a PR to revert the original change - but how long will it last?

HomeACcessoryKid commented 5 months ago

same here, though the error message, while similar, is slightly different

2024-06-13 18:05:36.998 Error: Captur: Retrieve Error: ('err.func.vcps.ev.charge-mode.error', '{"errors":[{"errorCode":"400000","errorMessage":"Content-Type is not supported","errorLevel":"error","errorType":"functional"}],"error_reference":"rrt-0c763753ae4cd3205-b-eu-18225-55842039-109"}')

Using this script for Domoticz: https://github.com/HomeACcessoryKid/Domoticz-Renault-Plugin which uses this repo api

slyoldfox commented 5 months ago

@epenet how do you debug the endpoint changes locally? Do you have a rooted android/iOS device to hook into this?

I don't mind digging deeper in the latest changes, just interested in how you keep up with their app (endpoint) changes.

epenet commented 5 months ago

I no longer try to keep up. I originally used an https proxy but that no longer works so I rely on the community.

The worst part is that quite often even their app stops working!!!

slyoldfox commented 5 months ago

For reference I ended up downloading the My Renault android apk and uploading it to www.decompiler.com (https://www.decompiler.com/jar/591d0352c74840909291f718456bf807/base.apk), opened the decompiled code in Intellij CE.

I did find the endpoint and it doesn't seem to have changed (if indeed this is the last apk). While debugging it seems that this endpoint just started working again for me.

Is anyone else seeing this? @bizoo @HomeACcessoryKid @Zaphod-dev

HomeACcessoryKid commented 5 months ago

I still had issues, but just found the change in the json format. After fixing that, normal behaviour observed.

Up till recent, there was different vocabulary for reading (res) the chargeMode and for changing (cmd) the chargeMode. This has now been unified. The read vocabulary has been changed to use the change vocabulary.

so before:

        cmd={ self.CHARGE_ALWAYS:   "always_charging",
              self.CHARGE_SCHEDULED:"schedule_mode",
        res={ self.CHARGE_ALWAYS:   "always",
              self.CHARGE_SCHEDULED:"scheduled",

and now

        cmd={ self.CHARGE_ALWAYS:   "always_charging",
              self.CHARGE_SCHEDULED:"schedule_mode",
        res={ self.CHARGE_ALWAYS:   "always_charging",
              self.CHARGE_SCHEDULED:"schedule_mode",

PS. this is from my python script referenced before

epenet commented 5 months ago

Anyone willing to open a PR?

slyoldfox commented 5 months ago

I'm at a loss what has changed to be honest :-) I am not sure if this has always been this way but there is a difference between:

response = await vehicle.get_charging_settings()
response2 = await vehicle.get_charge_mode()

The first one will return scheduled for response.mode while response2.chargeMode returns schedule_mode.

Likewise when you set it to Instant in the app, there is a difference:

Charge settings: always
Charge mode: always_charging

I was gonna comment on the hvacStatus - it seems it has gone back to a string, but right now I can't confirm since gigya is throwing me an invalid loginID and password 🙄

HomeACcessoryKid commented 5 months ago

for me there is a new error, but if I do not call vehicle.get_charges(now,now) then all works fine for me.

The key issue seems to be that MAYBE renault is using API versions, but we seem to tap into latest always. If anyone could find a valid versioned URL, then a lot of stability will return IMHO

epenet commented 5 months ago

Side note: I have published a new release with a fix for hvacStatus