itchannel / fordpass-ha

Fordpass integration for Home Assistant
310 stars 56 forks source link

Tips/Notes regarding AutonomicData, specifically with EV/Trip data specifics? #452

Open cr08 opened 10 months ago

cr08 commented 10 months ago

I recently discovered after having this integration installed in my HA instance for a while that the AutonomicData script existed and all the juicy details provided from it. I'm interested in knowing if there's any kind of documentation or tips around regarding what each data point is for? Some are painfully obvious, but ones like the xev... keys are a bit confusing, especially in regards to how some of this was previously surfaced in Ford's own apps.

To explain what I'm trying to accomplish here: I currently own a C-Max Energi which is one of Ford's 'older' PHEVs and originally operated on the old MyFord Mobile app before being migrated to FordPass when the 4G TCU upgrades took place. Originally in MFM there was some very useful trip data including stuff such as EV only miles during a 'mixed-fuel' trip compared to the overall trip distance, energy used, etc.. I happened to find a screenshot online from the old app showing the kind of data that WAS available at the time. I can only guess from some of the data points on the JSON file produced here that all that is still being reported?

image

But ultimately Ford removed almost all of the useful EV related functions from FordPass for these older vehicles. No more trip data, charge logs/notifications, no Value Charge/Scheduled Charging or Go Times/Departure Times functions. Just basic start/lock/unlock and fuel/battery status at best. So I'm wanting to see if I can develop a better dashboard/database for all of this outside HA, similar to @SquidBytes LightningRod project.

I've also attached a redacted JSON here of what data I am receiving. 2013-C-Max_Energi_status_2023-12-02_13_52_41_REDACTED.json

As a side note and semi-unrelated: I did see an issue/discussion here that I can no longer find talking about some of the other endpoints on Ford's end that aren't used in this integration. I'm curious if there's been any work there specifically on the previously mentioned Scheduled Charging/Departure Times functions? It'd be kinda nice to get those back. Just theorizing based on what I've learned so far is it feels like all the functions are still there between the vehicle/TCU and Ford's backend but they've given up making it available on the app side of things for us with the older vehicles.

SquidBytes commented 10 months ago

I understand your frustration. I started this journey because I was unhappy with the FordPass app for my electric vehicle. I noticed a few data points disappearing, and I have a 2023 F-150 Lightning. I can only imagine how much worse it has been on an older vehicle.

Charge Log specifically, I think you should be able to use my code in LightningROD to download whatever logs are available via the API. I'm guessing its the same URL/endpoint. It will download and save a json data, you don't need to have a database setup for that to work. You can open an issue on that projects page if you would like help with that, as I am still working on it.

From glancing at the JSON you provided (thanks for that) here are the notable items and if/where you should be able to find them in the HA integration (if you haven't found them out yet)

xevBatteryRange Will be your High Voltage Battery Range (mapped to elVeh sensor in HA) tripFuelEconomy should be the most recent trips fuel economy (even if it still says "trip in progress") (mapped under the speed sensor in HA) tripXevBatteryRangeRegenerated - This should be the range returned from using regenerative braking (mapped under the elVeh sensor) tripXevBatteryChargeRegenerated - From testing, I believe this value is the "Driving Score" (mapped under elVeh sensor)

Keep in mind the values in the json are metric.

In other json data I have seen keys like accumulated-deceleration-coaching-score accumulated-vehicle-speed-cruising-coaching-score accumulated-acceleration-coaching-score etc Which I believe would be the "Brake Score" and other "Scores" unfortunately I do not believe your vehicle now "supports" that functionality.

There could be a way to get your recent trip report for EV Miles used vs Gas Miles There are various keys that could be used like custom:trip-sum-length, fuel range, custom:vehicle-trip-fuel-consumption, etc. These values in addition to the value change of your Battery Range there could be some logic to estimate those numbers. However, that would require to have the data before and after a trip. It would also require more code, and most likely out of the scope of the HA integration.

I do not recall seeing any discussion on the other endpoints "available" or unused, but I do not have any information on that. itchannel has done most of the work on that part, I have just been helping where I can and improving things related to the EV side of the integration.

I've also been out for a bit for person reasons, and will continue to be unavailable here and there.

I'm curious if there's been any work there specifically on the previously mentioned Scheduled Charging/Departure Times functions? It'd be kinda nice to get those back.

I agree, I would also love a way for this integration to Start/Stop charging. I have hopes that I'll be able to look into this soon, but it could also go nowhere....or change suddenly :/

cr08 commented 10 months ago

Thanks for all the input! I think the one odd duck out here that I want to sort out first is the tripFuelEconomy key. The value recorded last was 5.796 but the previous trip it should correlate to was approximately 15 hybrid only miles at ~40mpg. Even considering the unit conversion, I'm unsure what it is tracking. But I think I'll have to sit down and make a few trips, document the in-vehicle trip computer, and compare.

I did happen to look over your LightningROD project a bit more and looks like you managed to get all the authentication stuff sorted out so it should be a good start to get stuff logged more readily and potentially doing some more fun stuff with it without relying completely on the HA integration.

Sadly the first red flag I'm seeing is that it looks like there are no longer any charge logs available from Ford's end. I did try pulling those and I just got an empty response:

{
    "energyTransferLogs": []
}

As for the endpoints: I found the comment I was reading previously over under https://github.com/itchannel/fordpass-ha/issues/121#issuecomment-1015880975. However it appears that was before the recent API change which makes it all moot. But as a long shot I started decompiling the Android FordPass app to see if I can surface anything useful and I did initially find some, a few of these already being used here:

v1beta/telemetry/sources/fordpass/vehicles/{vin}:query
/v1/command/vehicles/{vin}/commands
/v1beta/command/vehicles/{vin}/commands
/v1/command/vehicles/{vin}/commands
/api/v1/RetrieveCCSSettingsChangeStatus/
/api/v1/SendCCSSettings/
v1/auth/oidc/token
/api/vinauthorizationutility/retail/v1/getCommandStatus/{vin}/{tmcCorrelationId}
/api/vinauthorizationutility/retail/v1/getAuthorizationStatus/{vin}
/api/authorization/retail/v2/primary/{vin}
/api/authorization/retail/v1/accessRequest/{vin}
/api/reset/retail/v1/userReset/{vin}

I haven't went through it all completely yet. However if I do come across anything that looks interesting, I'll make sure to share.

cr08 commented 10 months ago

Ok. Did a short trip and immediately gathered the JSON data and compared. Here's what I am seeing:

tripFuelEconomy - This seems it may be the actual EV miles for the trip? In the previous example above where it was hybrid only operation it makes more sense. 5.796km comes out to about 3.6 miles which seems like it would be appropriate for that gas mileage and total trip range (without having the actual trip summary from the in-vehicle display to compare against). This evening was an EV only trip and this data point it showing 2.8805 which is about 1.78 miles which is what the trip computer showed (1.7 EV miles). Scratch all of this. Another short trip and I'm seeing numbers that simply don't line up. I'll wait and make sure I have a variety of trips made first with plenty of data points before I make any further guesses. tripXevBatteryChargeRegenerated - Appears to be the Brake Score here. 97.6 reported and the trip computer shows 97%. There's no driving score displayed in the vehicle but there are basic bar graphs for brake/driving/cruising. I'll have to do more checks on this later.

Those are the immediate things I was able to confirm. The remainder seem to track with what you've already mentioned. Seems like a number of these the vehicle is always rounding down decimal places on the in-car displays?

I am planning on taking a longer ~3h trip this weekend that will be 95% hybrid operation so that'll be another good test.

Another one that is really confusing to me is the torque data points. Not quite sure what units of measurement are used here.

Cellivar commented 10 months ago

When Ford announced our C-Max vehicles were getting a lot of features dropped from FordPass I had a strong hunch it was a car-side problem. We're seeing a migration into a very different API system and I would bet money it's an entirely different team building the new one.

Older vehicles weren't worth bringing along for the ride, hence the spotty API support.

Curious if you find more new and interesting endpoints buried in the app. Something to consider is modern APIs often have an aspect of self-description, so it could be that the app asks for a manifest of even more URLs to call for more information.

cr08 commented 9 months ago

Didn't take my longer trip but had a few smaller ones in the meantime with some gas usage and I think I've nailed down all the important bits, including some of the more confusing ones. As already noted, they are all in metric.

The one that really confused me was the tripFuelEconomy value which as SquidBytes already mentioned, it is the trip's fuel economy value but reported in litres/100km and the conversion being 'reversed' from MPG threw me the first time around. The one caveat here that I have seen from not only FordPass but also the old MyFord Mobile app is depending on whether you have the units in the vehicle set to MPGe or MPG will be how it is reported here and it doesn't seem like that is indicated in the JSON anywhere that I'm able to find. The numbers will differ quite a bit depending on the unit used. MPGe actually takes electric efficiency into account whereas MPG only factors in gas usage. So the latter will max out at 999 MPG if running all electric while the former for example in my own use may see around 130-140 MPGe in warmer weather. This only applies to the early model years/IPCs. Mine is a 2013 and has the option for MPGe. I think around 2016/17 the newer clusters removed it so they only report MPG. I briefly swapped in a 2017 unit in mine and this behavior followed.

The custom metrics values towards the top of the JSON:

trip-sum-length is what it says. Total trip length in km trip-fuel-consumption - This is the actual gas used for the trip in litres

One item I'm still not able to find is the kwh used as that used to be reported in MFM and is part of the trip summary in vehicle. But this research is still a work in progress. I just wanted to put an update out. Seems like most of the important data points are figured out for these vehicles. I'm still very curious what the torque units are.

One final fun note: I haven't had a chance to confirm it yet but it has displayed in FordPass and so I'm assuming it'll be in the JSON as well under the right conditions: While a trip is underway and the plug-in charge is depleted and thus the vehicle operating in hybrid mode, the battery gauge in FP will reflect the hybrid charge level.

EDIT: Torque units are in newton meters. In retrospect, should have been obvious but not a unit of measurement I run into regularly. 😛

Sometime in the near future I think I'm going to write up a quick doc in markdown detailing all these data points and will either PR it here or in LightningROD if the respective authors deem its suitable to add.