ardevd / jlrpy

Python library for interacting with the JLR Remote Car API
MIT License
85 stars 28 forks source link

get_trips - define the time frame? #119

Closed wawibu closed 3 months ago

wawibu commented 4 months ago

when I'm using get_trips I get right now "only" the last 775 trips. Within the app / web of InControl I see all trips - so I assume the data is still available. So I assume that it gets cut due to the data volume. Does someone know how to add a time frame to the request so that I would be able to pull them in different junks. Would be a one-time request only to get the full history and from there I could start building it up by adding only the new trips.

ardevd commented 4 months ago

I'll look into it. Working on some updates in the near future which will overhaul requests with the latest InControl API spec.

wawibu commented 4 months ago

cool - thanks - and let me know if I can support you

shegnauer commented 3 months ago

The attached patch works for me:

jlrpy.patch

This defines a new function get_tripse that uses the 'startDate' and 'stopDate' query strings defined in the JLR API. The two dates are URL-encoded datetime strings, the example uses '2021-06-01T00:00:00+0000' as the default starting date + time. You can obviously define your own limits in the calling function (but they need to be URL-encoded, i.e. replace ':' by '%3a' and '+' by %2b')

Looks very simple and obvious when you see it, but has taken me quite a bit of head-scratching and trial-and-error. I did NOT check with different daytime values or time zone offsets. You may try that yourself. Also, there may be a simpler / combined function definition for the standard get_trips function to have just one function instead of two. Unfortunately I am not Python savvy enough for this :-)

Edit: note that once you have the trip ID's you can get the complete routes data as well with get_trip - even though they happened in a distant past ... JLR keeps them all !

ardevd commented 3 months ago

Thank you for the contribution. Feel free to create a PR :)

ardevd commented 3 months ago

Fixed.