When I learned that someone had Reversed Engineered the Jaguar InControl API, I thought it would be fun to see if I could connect Google Sheets to the API, and download the trips from my Jaguar I-Pace for my own analysis and visualization.
In this blog post I share my Google Sheets solution, and explain how you can download your own Jaguar InControl trips to Google Sheets automagically. Although I have only used Jaguar I-Pace data in the development of this solution, if you own a Jaguar fossil car with an Jaguar InControl Account, I think it should also work for you (although all the special calculations are mainly made for Jaguar EV).
Do also check out my 2 other related blog posts:
- Jaguar InControl API for Google Sheets – Part 2
- Here I explain what data you get about your trips, which part of the Jaguar InControl API I use, and also the Google Apps Script code I wrote.
- Analyze your Jaguar I-Pace trips in Google Data Studio
- Here you get a Google Data Studio Dashboard that let you analyze and visualize your own Jaguar I-Pace Trips.
- Moved calculations from the Google Apps Script to a seperate Sheet.
- Improved “removeDuplicates” from the Google Apps Script.
- Added possibility to calculate a more correct Average Consumption.
- Added support for selecting the correct Jaguar if you have more than 1 car.
- Improved effeciency of the script that is fetching trips. Script now uses less time in fetching trips and writing trips to Google Sheet.
Download your Jaguar InControl Trips to Google Sheets, a Step-by-Step Guide
There are unfortunately quite a few steps you have to go through to download your Jaguar InControl Trips to Google Sheets.
Google will throw some “red flags & warnings” at you in the process, since you will have to authorize the script that connects to the Jaguar InControl API. I don’t collect any of your data. I will see if I can get those warnings fixed.
The reward you will get for going through all these steps, is that you will get 50+ columns of data about your Jaguar InControl Trips. Although this is much information, detailed information like all the waypoints for each trip will not be downloaded. That is a different part of the Jaguar InControl API. Maybe – one day – I will share a solution for this as well.
1. Open the Google Sheets example, and make a Copy
- Open the “Jaguar InControl Trips Sheet example”
- Make a Copy.
The Sheet contains 3 different Sheets:
- Jaguar InControl Trips API Data
- Data from the Jaguar InControl API is saved to this sheet. You can ignore this sheet and hide it if you like.
- Jaguar InControl Trips
- Here we do some calculations and add some more data, based on the data in the “Jaguar InControl Trips API Data” sheet. This is the sheet you should use for reporting and analysing your own trip data.
2. Fill out the “Settings” Sheet
In the “Settings” Sheet, fill in “Username” & “Password” from your Jaguar InControl account.
The “Trip Count” field defines how many rows of data that should be downloaded from the Jaguar InControl API. Sometimes I get 3 months of data, sometimes I get more. The first time you run the “Jaguar InControl API” script, choose a “Trip Count” number high enough to download at least 3 months of data.
I explain under the headline “How to Download your Trip Data on a Daily Basis (or more often)?”, how you can get more than 3 months of data (if only 3 months is returned).
In the “Overwrite Data” settings field, choose “Yes” the first time you run the scripts.
The Jaguar InControl API needs something called an X-Device ID. The script I have written will create a random X-Device ID if you leave this field empty. If this for some reason doesn’t work, try a value from the Online UUID Generator.
3. Running the Jaguar InControl Script for the First Time
- From the Menu, choose “Tools -> Script editor”.
- You will now be revealed to the Google Apps Script that I have written. Don’t worry, you don’t have to do any coding. 🙂
- Make sure that “AuthJaguarInControlApi” where the Red Arrow is pointing is selected.
- Click on the “Play Button” where the Green Arrow is pointing.
Go through the Authorization Process
As mentioned, Google will throw some “red flags and warnings” at you in the authorization process the first time.
You can at any time remove access to this solution in your Google Account if you regret that you gave the authorization.
If you made it so far, the Google Apps Script which I have called “Jaguar InControl API” will now run, and download your trips to the “Jaguar InControl Trips” Sheet. If not, click the “Play Button” again.
The script will also update some information about your Jaguar InControl Account in the “Settings” Sheet.
4. How to Download your Trip Data on a Daily Basis (or more often)?
As mentioned, you will maybe only get 3 months of trip data from the API. However, we are not limited to only 3 months moving forward.
- Go to the “Settings” Sheet again. Change the settings “Overwrite Data” to “No”.
- From now on and moving forward, new trip data will be added to the existing data.
- Change the “Trip Count” value to a number that it is hight enough to get at least trip data for 2-3 days. I have experimented with 20 as the Trip Count. You may need a higher number.
- Why 2-3 days? If you run the script once a day, it may fail 1 day, but then the data will still be captured the second or third day.
Create 2 Google Apps Script Triggers
- Go to the Google Apps Script again (“Tools -> Script editor”).
- From the Menu, choose “Edit -> Current project’s triggers”
- Click on “Add Trigger”
- We are going to add 2 Triggers as shown below.
|This Trigger Adds Trip Data to the Sheet.||This Trigger Removes Duplicate Trip Data from the Sheet.|
- The first Trigger will Add Trips to the Sheet. How often you should run the trigger is up to you. I run the trigger every night.
- The second Trigger will Remove Duplicate Trips from the Sheet.
- When Trips are added to the Sheet, duplicate Trips will be added. This Trigger starts a function that Remove Duplicates.
- This Trigger should be started after the first trigger have finished. As you can see from my setup, I run the first Trigger between 3 & 4 in the night, and the second trigger between 4 & 5 in the morning.
- If you want a more frequent update, a rule of thumb is that a Google Apps Script will run for maxium 6 minutes, so your second trigger must start at least 6 minutes after the the first trigger.
If you have made it so far, congratulations! Your Jaguar InControl Trips will now automagically be downloaded to Google Sheets.
Some Closing Words
No cats where harmed in the development. I do however admit that the Jaguar InControl API did miaows to me several times with error messages before I got the Google Apps Script working.
This solution is built upon an Unofficial Jaguar InControl API, so I don’t guarantee for the future. I do not know who did the job creating the API. If you know, please let me know so I can give credit to the(se) person(s). Paw Whack to you!
This solution is in no way a product of Jaguar or related to Jaguar. I’m just a happy Jaguar I-Pace owner that happens to work with data, and thought it was great fun to write the Google Apps Script and create the Google Sheet.
Happy driving and analyzing your Jaguar car!