Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api Coverage for Dacia Spring #488

Open
afaucogney opened this issue Jan 27, 2022 · 15 comments
Open

Api Coverage for Dacia Spring #488

afaucogney opened this issue Jan 27, 2022 · 15 comments

Comments

@afaucogney
Copy link
Contributor

Thanks for all this project, this is amazing !

I just get my fresh new Dacia Spring !

Thanks to the Api (cli), I succeed to do auth, and then here are my tests. Basic status is OK, but nothing about schedules on Hvac as well as Charge.

The mobile seems to be able to start/stop charge and hvac, but the api seems to do not work. Anyone get an idea ? Does any Spring user get the same payload / behaviour ?

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/battery-status" 
 => OK

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}/cockpit"
 => OK

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/location"
 => OK

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/notification-settings"
 => Error: ('err.tech.501', 'This feature is not technically supported by "AVN", vehicleID: "xxxxx"')

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/lock-status"
 => Error: ('err.tech.502', 'VNEXT an internal error occured while processing request : 403 FORBIDDEN')

// HVAC

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-history"
 => Error: ('err.func.400', "Required TargetPeriodType parameter 'type' is not present type is missing")

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-status"
 => OK

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-settings"
 => Error: ('err.tech.502', 'VNEXT an internal error occured while processing request : 403 FORBIDDEN')

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-sessions"
 => Error: ('err.func.400', 'must not be null, must not be null')

// CHARGE

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charges"
=> Error: ('err.func.400', "Required LocalDate parameter 'start' is not present start is missing")

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-mode"
 => Error: ('err.func.403', 'Access is denied for this resource')

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-history"
=> Error: ('err.func.400', 'must not be null, must not be null, must not be null')

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-settings"
=> Error: ('err.func.403', 'Access is denied for this resource')

Is there a way to know what is supported or not ? by the car or the api ?

Thanks for all !

@epenet
Copy link
Collaborator

epenet commented Jan 27, 2022

Sadly there is no official documentation - you have to unpack the apk manually!
When you have must not be null, must not be null it is because you are missing some parameters in the URL (for example startDate/endDate).

I have recently merged #479 but I do not have a sample carGateway information for the Dacia Spring.
Can you maybe create a PR with your result?
renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v2/cars/{vin}"

@afaucogney
Copy link
Contributor Author

@epenet I will have a look at he apk. I tried to sniff the code with MITM, by updating the apk with a new cert, but they use TrustKit that lock my investigation ...

the api about hvac start seems to work, but cancel return a huge amount of data without any effect on the car.
In the app, this is not working as well !

yes I can do PR, where should I put that file, that my second hour in this project ....

@epenet
Copy link
Collaborator

epenet commented Jan 27, 2022

tests/fixtures/kamereon/vehicle_gateway/spring.1.json

@epenet
Copy link
Collaborator

epenet commented Jan 27, 2022

Look at the files already in the folder

@afaucogney
Copy link
Contributor Author

@epenet done ! Hope I didn't push sensible data ...

@epenet
Copy link
Collaborator

epenet commented Jan 28, 2022

Please take a look at PR #459 for the charge start/stop

@epenet
Copy link
Collaborator

epenet commented Jan 28, 2022

I was previously able to use fiddler on my machine - but I haven't tested it recently.
I also know that IOS and Android have different protection mechanism...

@slater0013
Copy link
Contributor

Hello, Spring owner here !
Big thanks for your work here ! would be glad to help with Spring custom configuration !
HVAC and Charge can be launched through the mobile app. But there is no scheduling.

GS

@jumpjack
Copy link

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/lock-status"
=> Error: ('err.tech.502', 'VNEXT an internal error occured while processing request : 403 FORBIDDEN')

I think this works only on Nissan cars, as many others endpoints (horn-lights, engine-start, door-lock,...).

// HVAC

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-history"
=> Error: ('err.func.400', "Required TargetPeriodType parameter 'type' is not present type is missing")

The format for charges-history is:

charge-history?start=STARTDATE&end=ENDDATE&type=TYPE

See here for details: https://github.com/jumpjack/myRenaultLC/wiki/Syntax-of-%22charge-history%22,-and-related-errors

Possibly it's the same for hvac-history.... but I can't get it working anyway on Renault Capur and Renault Zoe50:

{
    "status": "Not Implemented",
    "code": "501",
    "title": "Not supported Feature",
    "detail": "This feature is not technically supported by this gateway"
}

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/hvac-sessions"
=> Error: ('err.func.400', 'must not be null, must not be null')

Full error message:

{
    "errors": [
        {
            "status": "400",
            "code": "NotNull",
            "detail": "must not be null",
            "source": {
                "parameter": "end"
            }
        },
        {
            "status": "400",
            "code": "NotNull",
            "detail": "must not be null",
            "source": {
                "parameter": "start"
            }
        }
    ]
}

This means it has same syntax of charges-history ; but on Captur and Zoe50 I get:

{
    "status": "Not Implemented",
    "code": "501",
    "title": "Not supported Feature",
    "detail": "This feature is not technically supported by this gateway"
}

// CHARGE

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charges"
=> Error: ('err.func.400', "Required LocalDate parameter 'start' is not present start is missing")

Same syntax of charges-history; output format:

{
    "id": "xxx MY VIN xxx",
    "charges": [
        {
            "chargeStartDate": "2022-01-27T02:00:10Z",
            "chargeEndDate": "2022-01-27T03:56:24Z",
            "chargeStartBatteryLevel": 71,
            "chargeEndInstantaneousPower": 0
        },
        {
            "chargeStartDate": "2022-01-28T02:01:17Z",
            "chargeEndDate": "2022-01-28T05:45:30Z",
            "chargeStartBatteryLevel": 8,
            "chargeEndInstantaneousPower": 0
        },
        {
            "chargeStartDate": "2022-01-29T22:17:06Z",
            "chargeEndDate": "2022-01-30T01:52:08Z",
            "chargeStartBatteryLevel": 11,
            "chargeEndInstantaneousPower": 0
        }
    ]
}

renault-api --json http get "/commerce/v1/accounts/{account_id}/kamereon/kca/car-adapter/v1/cars/{vin}/charge-history"
=> Error: ('err.func.400', 'must not be null, must not be null, must not be null')

Syntax of charges-history

@epenet
Copy link
Collaborator

epenet commented Mar 11, 2022

@jumpjack why don't you provide a documentation PR here instead of linking to your repository?

@jumpjack
Copy link

You welcome.

@epenet
Copy link
Collaborator

epenet commented Apr 28, 2022

@jumpjack please take a look at #603 as a sample on how to contribute to the documentation

@andig
Copy link

andig commented Aug 20, 2022

I can only partially confirm this. With the Dacia I have here for testing I'm getting:

battery-status: Access is denied for this resource
charge-mode: Access is denied for this resource
cockpit: Access is denied for this resource
location: Access is denied for this resource
lock status: Access is denied for this resource
res state: Access is denied for this resource
hvac-status: Access is denied for this resource

Maybe there are differences between the cars?

@andig
Copy link

andig commented Aug 20, 2022

Funny. Running this once more an hour later it looks like this:

charge-mode: Access is denied for this resource
lock status: VNEXT an internal error occured while processing request : 403 FORBIDDEN
res state: Access is denied for this resource

Same car, nothing changed...

@eltoro0815
Copy link

@epenet I will have a look at he apk. I tried to sniff the code with MITM, by updating the apk with a new cert, but they use TrustKit that lock my investigation ...

the api about hvac start seems to work, but cancel return a huge amount of data without any effect on the car. In the app, this is not working as well !

yes I can do PR, where should I put that file, that my second hour in this project ....

You can use FRIDA to do what you want:
https://httptoolkit.com/blog/frida-certificate-pinning/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants