itchannel / fordpass-ha

Fordpass integration for Home Assistant
278 stars 45 forks source link

Is there any ability to pull Ford EVSE Charge Station Data into the integration? #243

Open ziptbm opened 1 year ago

ziptbm commented 1 year ago

This isn't an "issue" per se, but really a question. Let me know if this should go somewhere else.

Is the FordPass integration able to access any of the EVSE Charge Station data? I'm trying to figure out how to extract the real-time charging data from the Ford Charge Station Pro into Home Assistant.

itchannel commented 1 year ago

I've never heard of the Ford charge station. But does it show data in your Fordpass app?

ziptbm commented 1 year ago

I've never heard of the Ford charge station. But does it show data in your Fordpass app?

On FordPass app on iPhone, tap account and then scroll down to Charge Station. I’m not sure if it actually is getting data in app, but it is connected and authenticated via FordPass. It looks like it’s loading a webpage that provides the data. Here are two screenshots.

What I’m really after is the real-time charge data in kW.

18B4DC74-A43C-4757-B169-3824AF086559 AAE0F977-C73C-464D-9A88-F96B268EED4D

itchannel commented 1 year ago

From the screenshots it appears to be a separate website and not exposed by the API. If you could proxy some traffic from your mobile device to Ford I may be able to look into it. But unfortunately I don't have an electric car or the relevant charger so can't do any debugging on my end.

ziptbm commented 1 year ago

Yes, it is. I believe it’s navigating to https://prod.ocpp.ford.com/ but this site will not load for me anywhere else since there must be some sort of authentication coming from FordPass. Is there any specific data I should try to proxy? It’s using encryption, so I haven’t been able to figure out how it’s pulling the data specifically.

I’ve made some requests to Ford about exposing this data since it’s ultimately coming from a Siemens-built charger they have white labeled and locked the data behind this one button in FordPass. I’m not expecting much, but exploring every option I can.

itchannel commented 1 year ago

Looks like it does have an API and potentially uses the same tokens as Fordpass. However you would need to use something like Burp and then intercept the traffic between the fordpass application and your phone to see how the API interacts when visiting that page in the app.

https://api.pd01e.gcp.ford.com/api/wallbox/v1/

It doesn't appear to be documented in the Ford Developer portal and I don't have access as I don't have a wall charger.

ziptbm commented 1 year ago

Thank you @itchannel I"ll look into Burp and see what I can find. Is there anything, in particular, I should be looking for?

In the meantime, I have found that if I visit the local IP of the device, I get a "login" page with no ability to actually login. If I then try other URLs, I get some more information on the Page Not Found 404 error. Sharing in case this helps.

Using the URLconf defined in evse_app.urls, Django tried these URL patterns, in this order:

^/?$
^login
api/v1/access [name='access']
api/v1/datakey [name='datakey']
api/v1/connect [name='connect']
api/v1/refresh [name='refresh']
api/v1/chargerinfo [name='chargerinfo']
api/v1/wifinetworklist [name='wifinetworklist']
api/v1/wlanconfig [name='wlanconfig']
api/v1/configstatus [name='configstatus']
api/v1/blepairing [name='blepairing']
api/v1/pairstatus [name='pairstatus']
api/v1/pairlist [name='pairlist']
api/v1/managePairing [name='managePairing']
api/v1/networkinfo [name='networkinfo']
api/v1/inverterinfo [name='inverterinfo']
api/v1/initistate [name='factoryreset']
api/v1/pairconfirm [name='pairconfirm']
^static\/(?P<path>.*)$
The current path, api/wallbox/v1, didn't match any of these.
ziptbm commented 1 year ago

I got Burp installed, configured it as a proxy from my mobile device, and went through the app to see what I can find. I'm seeing traffic to the same URL you shared above. I'm not exactly sure what I'm looking for, but I did see this when going through the insights, which shows the historical consumption. This in particular is showing the 11.826 kwh consumed today.

Anything here helpful? Any other pointers for what to look for?

Request:

`GET /api/wallbox/v1/chargepoints/<REDACTED>/chargeEvents?fromDate=2023-01-29T00%3A00%3A00.000-05%3A00&toDate=2023-01-29T23%3A59%3A59.999-05%3A00&fetchLimit=5&page=0 HTTP/1.1
Host: api.pd01e.gcp.ford.com
Application-Id: 3A8A4966-50EC-4F9B-B299-51B737547D5A
Accept: application/json, text/plain, */*
Origin: https://prod.ocpp.ford.com
Accept-Encoding: gzip, deflate
Auth-Token: <REDACTED>
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Referer: https://prod.ocpp.ford.com/
Accept-Language: en-US,en;q=0.9
Connection: close`

Response:

`HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 30 Jan 2023 02:00:03 GMT
Content-Type: application/json
Connection: close
access-control-allow-credentials: true
access-control-allow-origin: https://prod.ocpp.ford.com
cache-control: no-cache, no-store, max-age=0, must-revalidate
expires: 0
pragma: no-cache
strict-transport-security: max-age=31536000 ; includeSubDomains
vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers
x-application-info: name=Smart Wallbox; version=@gradle.properties.version@;
x-content-type-options: nosniff
x-request-info: timestamp=1675044003; execution=218; referenceId=<REDACTED>;
x-vcap-request-id: <REDACTED>
x-xss-protection: 1; mode=block
access-control-expose-headers: *
x-request-id: <REDACTED>
Content-Length: 233

{"result":{"chargePointId":<REDACTED>,"fromDate":"Jan 29, 2023","toDate":"Jan 29, 2023","page":0,"fetchLimit":5,"count":1,"chargingEventRecordList":[{"data":11.826,"unit":"kWh","eventTime":"Sunday, Jan 29, 2023, 09:59 AM"}]},"error":null}`

Also, I noticed these other items appear when looking at active charge session in the FordPass app. This isn't from the wall charger, but the actual vehicle.

GET /api/vpoi/chargestations/v3/plugstatus HTTP/2 Host: api.mps.ford.com

POST /api/cevs/v1/chargestatus/retrieve HTTP/2 Host: api.mps.ford.com

SquidBytes commented 8 months ago

@ziptbm This would be cool to add. But there have been large changes to this integration since the last comment (as I know you know)

I'm curious if this is still something you're looking for, or if the new data returned satisfies your goal? It could still be integrated, I just do not have the Ford charger so we would still need you to help.

ziptbm commented 8 months ago

@ziptbm This would be cool to add. But there have been large changes to this integration since the last comment (as I know you know)

I'm curious if this is still something you're looking for, or if the new data returned satisfies your goal? It could still be integrated, I just do not have the Ford charger so we would still need you to help.

I'd be happy to help, but need some direction on what specifically to do and gather.

With that said, I have little faith in the Ford Charge Station Pro as it's one of the most unreliable and useless "smart" devices I've ever owned. e.g. I just checked right now and this "connected" charger is offline. There's absolutely no reason for it to be the case... AP is line of sight with no obstacles, tuned channels through UniFi, and no other WiFi devices in the area have this unreliable connection. And the kicker, the only way to get it to temporarily rejoin the network is to flip the 100A breaker on/off. And when it is connected, none of the data collected while it was offline is uploaded so there are large gaps in the data that is only accessible via the Fordpass app on a mobile device.

So, I ended up gathering charging data from an Emporia Vue 2 instead to give me the charging data I'm looking for as a workaround. It'd be great if this were reliable and integrated into the sensor, but I am cautious on my ownership experience of this device over the last 9 months.

SquidBytes commented 8 months ago

I'd be happy to help, but need some direction on what specifically to do and gather.

You would have to have a rooted Android and setup Burp to view the API calls, and where the data is coming from. I am still in the process of setting this up myself, and even after rooting a phone - the app behaves oddly and is very difficult.

That is very unfortunate to hear about the Charger. But, after the few updates to the FordPass app....I am not that surprised. It seems like Ford just isn't worried about the "software" side of things. They just are not fixing anything, or adding useful features. The more I use my FordPass app the more I despise it, which is when I started working on this integration.....because the app is just not good.

I think the only hope for a better app, and hopefully fixing those charger issues - is if Ford opens up their API.

MephistoJB commented 5 months ago

I was searchinh for exactly the same thing to enable communication between my pv and the wallbox. Do you have any news on this?

SquidBytes commented 2 months ago

With the new Connected API this may be able to be integrated - but I haven't yet looked into anything with the new API