Sponsored

Downloading Charge Logs

theUNSTABLE

Well-known member
First Name
Ryan
Joined
Feb 5, 2023
Threads
7
Messages
82
Reaction score
109
Location
Florida
Website
github.com
Vehicles
2023 F150 Lightning Lariat
Occupation
Cyber Engineer
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.
Ford F-150 Lightning Downloading Charge Logs lightning_hassCard

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"
        }
    }
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:
  1. logging into your Ford Account online, on a computer
  2. Go to your profile
  3. View your vehicle details
  4. Right Click on your truck
    1. Select "Open Image in new tab"
  5. From there you can then save the image
You can append more numbers to the end of the URL (I believe it is 1 through 5)

  1. Click up to the status bar on the image in the new tab
  2. Change '&angle=1' to '&angle=2', etc
Sponsored

 

srspring551

Well-known member
First Name
Scott
Joined
Mar 31, 2023
Threads
5
Messages
81
Reaction score
57
Location
WI
Vehicles
F150 Lightning Lariat 2023 ER, delivered 10-28-23
Nice! I still don't have my truck yet, but this is awesome info. I am not very good at Python yet, so I need some dedicated time to study it better, and I'm hoping my ChatGPT subscription helps me with coding (I know, I know - it's not a substitute for coding knowledge but it might hold my hand a little). It would be great if we could use a ChatGPT API key for an app to do some AI heavy lifting for data and alerts, possibly?
 
OP
OP
theUNSTABLE

theUNSTABLE

Well-known member
First Name
Ryan
Joined
Feb 5, 2023
Threads
7
Messages
82
Reaction score
109
Location
Florida
Website
github.com
Vehicles
2023 F150 Lightning Lariat
Occupation
Cyber Engineer
I'm working with the dev for the fordpass-ha integration.
The repo for connected car would be for people who want to use the python integration for their own projects

The Home assistant integration would be for automation and things.

If I end up getting a nice graph and some automation logging setup I don't mind sharing the code. I'm just still figuring out what the best way forward would be
 

Zprime29

Well-known member
First Name
Brandon
Joined
Jul 26, 2022
Threads
37
Messages
1,852
Reaction score
1,901
Location
Tucson, AZ
Vehicles
Honda Pilot, 2022 Lightning ER
Following.

I haven't done anything with Home Assistant, but I am pretty handy with Python. I'll try to check it it this week. Nice job!
 

Sponsored

TaxmanHog

Moderator
Moderator
First Name
Noel
Joined
Jan 19, 2022
Threads
165
Messages
11,626
Reaction score
12,093
Location
SE. Mass.
Vehicles
2022 Lightning Lariat-ER Max Tow
Occupation
Retired
Very cool stuff !

Would this at all jeopardize FordPass access, or is is that no longer a thing ?

https://www.macheforum.com/site/thr...-use-can-disable-your-fordpass-account.13893/

I recall a tid bit of news in recent months that they were looking to collaborate with external developers, I would hope anyone "registered" to work with them are exempt from enforcement and locking of accounts if they have a list of participating VIN's and logon accounts.

On the other hand, thinking back to my days at IRS, we developed all new code and maintenance of old code in an ecosystem disconnected from the production systems to prevent rogue & buggy code from seizing up the live daily business. A select class of developers and testers like myself had access but the general population of employees and customers could not get to it.
 
OP
OP
theUNSTABLE

theUNSTABLE

Well-known member
First Name
Ryan
Joined
Feb 5, 2023
Threads
7
Messages
82
Reaction score
109
Location
Florida
Website
github.com
Vehicles
2023 F150 Lightning Lariat
Occupation
Cyber Engineer

bluxombie

New member
First Name
Shane
Joined
Oct 22, 2023
Threads
0
Messages
1
Reaction score
0
Location
US
Vehicles
2023 F150 Lighting Lariat ER - Antimatter Blue
I like this idea.
I work for elastic (data and security stuffs) so data is my jam.
I get my truck tomorrow and love what you're doing here.
I'm going to work an angle I'm more familiar with: Ingest this data into elasticsearch, then visualize in kibana.
I'll go over to your other post as well for more information.

This has me wondering...can we also pull geo data? It would be fun to see where I drive. Start and stop times. Power use. All the things. Then split the dashboards up to see executive summary data on the landing page, and have drill downs where I want more fidelity.
Ooo man. You got me excited! Thank you!
Sponsored

 
 





Top