d4v3y0rk / ffpass

Use the command line or HTTP requests to start/stop the engine and lock/unlock the doors on your Ford vehicle.
https://www.npmjs.com/package/ffpass
61 stars 13 forks source link

Force refresh from vehicle #11

Closed oisact closed 3 years ago

oisact commented 3 years ago

The Fordpass app has a command that forces an immediate refresh of the vehicle data. Otherwise the API simply returns the data from the last time the vehicle was active or was issued a command, which can be hours old. For things like polling whether or not the doors are currently locked, it is necessary to get the latest info from the vehicle.

Can you determine the Ford API for refreshing, and either add it to the library or provide it here?

d4v3y0rk commented 3 years ago

@oisact I did not see any way to refresh the data when I was intercepting the traffic from the app to the backend APIs I did not know you could force a refresh from within the app so I do not have any data on how it goes about doing that.

burges16 commented 3 years ago

Looks like refresh may be able to be forced via a PUT 'https://usapi.cv.ford.com/api/vehicles/v2/{vin}/status'

RESPONSE: '{"$id":"1","commandId":"blah","status":200,"version":"1.0.0"}'

This should return a commandId which can be queried for successful refresh 'https://usapi.cv.ford.com/api/vehicles/v3/{vin}/statusrefresh/{commandId}' RESPONSE: "vehiclestatus":{}

If individual status parameters come back as NULL or last known then they are considered out of date. if they come back as current then they should be currently valid.

There is some kind of time delay between updates that seems to prevent continuous update requests from producing a refresh from the vehicle.

Tested on a Mach-E

andig commented 3 years ago

We have a refresh implementation in evcc- let me know if I can help.

d-Rickyy-b commented 3 years ago

@andig mind cross referencing the lines of code? I'd love to implement this for ffpass.

d-Rickyy-b commented 3 years ago

Oh, I might have already found it - seems to be these lines of code:

https://github.com/andig/evcc/blob/0934a22563d110bd3ff76056cccfc4dec5d4a202/internal/vehicle/ford.go#L224-L265