theUNSTABLE
Well-known member
- First Name
- Ryan
- Joined
- Feb 5, 2023
- Threads
- 7
- Messages
- 83
- Reaction score
- 109
- Location
- Florida
- Website
- github.com
- Vehicles
- 2023 F150 Lightning Lariat
- Occupation
- Cyber Engineer
- Thread starter
- #1
I recently came across Ford's "public" API.
After discussing it with fellow members and conducting online research, I learned that while yes, Ford has a "public" API, it is not accessible to everyone....yet (tm)
It is still possible to access this API, but doing so carries the risk of having your account locked.
After several days of research and my attempt to gather information from Ford, I discovered the fordpass-ha integration for HomeAssistant (https://github.com/itchannel/fordpass-ha).
To use the API, I created a secondary account and set up a widget for my F-150 Lightning.
This journey led me down the rabbit hole for the desire to have a very nice, aesthetically pleasing dashboard that could display all my charge sessions.
This would enable me so that I can then have these for my own person use, and show the to people when I get asked all the questions.
After all....these charge logs are available in the FordPass app, so why can't I get them.
After collaborating with a friend and conducting tests, I decided to write my own script to download the charge logs.
This script downloads the available charge logs in a .json format.
Furthermore, I discovered that there is a wealth of charge data available through the API beyond what is initially displayed.
For example:
With this data, I have plans to create a dashboard to track charge logs, charge costs, speed, etc.
I can then set up an automation that retrieves the charge log when HomeAssistant detects that my plug state changes from ON to OFF, and so on.
It's important to note that 99% of the credit goes to the original creator for the python library I used
https://github.com/ianjwhite99
This repo hasn't been updated in a while, so I forked it
I thought that some people here might be interested in doing something similar, so I have shared this script on my GitHub.
https://github.com/SquidBytes/connected-car-python-sdk-lightning
(if you do this, you can't install via pip, you will need to download my repo)
Script can be found in `examples/downloadChargeLogs.py`
Also: Read
https://github.com/SquidBytes/connected-car-python-sdk-lightning/blob/stable/README.md#disclaimer
I have also requested this feature in the fordpass-ha integration.
That dev seems responsive so I believe it will be implemented soon, which is why I didn't base my script off of his work and used the python library instead.
Its also worth noting that it looks like the FordApp, and the API, only store around 20 or so charge logs so for all the fellow data nerds this can come in very handy.
FYI: If you want to make something similar - you can easily grab nice rendered photos of "your truck" by:
After discussing it with fellow members and conducting online research, I learned that while yes, Ford has a "public" API, it is not accessible to everyone....yet (tm)
It is still possible to access this API, but doing so carries the risk of having your account locked.
After several days of research and my attempt to gather information from Ford, I discovered the fordpass-ha integration for HomeAssistant (https://github.com/itchannel/fordpass-ha).
To use the API, I created a secondary account and set up a widget for my F-150 Lightning.
This journey led me down the rabbit hole for the desire to have a very nice, aesthetically pleasing dashboard that could display all my charge sessions.
This would enable me so that I can then have these for my own person use, and show the to people when I get asked all the questions.
After all....these charge logs are available in the FordPass app, so why can't I get them.
After collaborating with a friend and conducting tests, I decided to write my own script to download the charge logs.
This script downloads the available charge logs in a .json format.
Furthermore, I discovered that there is a wealth of charge data available through the API beyond what is initially displayed.
For example:
JSON:
[
{
"id": "<log_ID>",
"deviceId": "<vin>",
"eventType": "ChargeData",
"chargerType": "AC_BASIC",
"energyConsumed": 39.55016,
"timeStamp": "2023-09-20T19:38:18Z",
"preferredChargeAmount": 0,
"targetSoc": 85,
"plugDetails": {
"plugInTime": "2023-09-20T14:02:11Z",
"plugOutTime": "2023-09-20T19:38:16Z",
"totalPluggedInTime": 20165,
"plugInDte": 169.0,
"totalDistanceAdded": 167.0
},
"power": {
"min": 528.0,
"max": 7447.5,
"median": 0.0,
"average": 6137.942447272726,
"weightedAverage": 7172.509136015211
},
"stateOfCharge": {
"firstSOC": 46,
"lastSOC": 85,
"socDifference": 39
},
"energyTransferDuration": {
"begin": "2023-09-20T14:02:13Z",
"end": "2023-09-20T19:25:20Z",
"totalTime": 19387
},
"location": {
"id": 1,
"type": "SAVED",
"name": "<savedName>",
"address": {
"address1": "<address>",
"city": "<city>",
"state": "<state>",
"country": "USA",
"postalCode": "<postal>"
},
"geoHash": "<has>",
"latitude": <lat>,
"longitude": <long>,
"timeZoneOffset": "UTC-04:00",
"network": "UNKNOWN"
}
}
Code:
{
"id": "<ID>",
"deviceId": "<vin>",
"eventType": "ChargeData",
"chargerType": "DC_FAST",
"energyConsumed": 17.63482,
"timeStamp": "2023-09-03T19:58:51Z",
"preferredChargeAmount": 0,
"targetSoc": 90,
"plugDetails": {
"plugInTime": "2023-09-03T19:47:25Z",
"plugOutTime": "2023-09-03T19:58:48Z",
"totalPluggedInTime": 683,
"plugInDte": 226.8,
"totalDistanceAdded": 61.2
},
"power": {
"min": 3132.0,
"max": 148522.8,
"median": 0.0,
"average": 95268.9393014429,
"weightedAverage": 94790.04095710278
},
"stateOfCharge": {
"firstSOC": 65,
"lastSOC": 80,
"socDifference": 15
},
"energyTransferDuration": {
"begin": "2023-09-03T19:47:37Z",
"end": "2023-09-03T19:58:45Z",
"totalTime": 668
},
"location": {
"id": 0,
"type": "UNSAVED",
"name": "<name>",
"address": {
"address1": "<address>",
"city": "<city>",
"state": "<state>",
"country": "USA",
"postalCode": "<posta>"
},
"geoHash": "<hash>",
"latitude": <lat>,
"longitude":<long>,
"timeZoneOffset": "UTC-04:00",
"network": "Not Provided"
}
}
I can then set up an automation that retrieves the charge log when HomeAssistant detects that my plug state changes from ON to OFF, and so on.
It's important to note that 99% of the credit goes to the original creator for the python library I used
https://github.com/ianjwhite99
This repo hasn't been updated in a while, so I forked it
I thought that some people here might be interested in doing something similar, so I have shared this script on my GitHub.
https://github.com/SquidBytes/connected-car-python-sdk-lightning
(if you do this, you can't install via pip, you will need to download my repo)
Script can be found in `examples/downloadChargeLogs.py`
Also: Read
https://github.com/SquidBytes/connected-car-python-sdk-lightning/blob/stable/README.md#disclaimer
I have also requested this feature in the fordpass-ha integration.
That dev seems responsive so I believe it will be implemented soon, which is why I didn't base my script off of his work and used the python library instead.
Its also worth noting that it looks like the FordApp, and the API, only store around 20 or so charge logs so for all the fellow data nerds this can come in very handy.
FYI: If you want to make something similar - you can easily grab nice rendered photos of "your truck" by:
- logging into your Ford Account online, on a computer
- Go to your profile
- View your vehicle details
- Right Click on your truck
- Select "Open Image in new tab"
- From there you can then save the image
- Click up to the status bar on the image in the new tab
- Change '&angle=1' to '&angle=2', etc
Sponsored