This is a hacky but effective technique to affect your ford with Home Assistant. I have a Bronco.
##FordPass API Signup Process
#Flow 1
- First, you MUST have a FordPass account. If you don't, you will need to do that first and that's outside of the scope for these instructions. Start here
- You need a developer account as well https://developer.ford.com/apis
- Follow the API instructions there to get the key things you need for this integration
- ClientId
- ClientSecret
- VehicleId
- ApplicationId
Your nodes are going to look like this:
- Injection node to run every 25 minutes to get a refresh token
- Function Node (code below) to set up refresh token call
msg.method = "POST";
msg.url = "https://dah2vb2cprod.b2clogin.com/914d88b1-3523-4bf6-9be4-1b96b4f6f919/oauth2/v2.0/token?p=B2C_1A_signup_signin_common";
msg.headers = {
"Content-Type": "application/x-www-form-urlencoded"
};
// Create the form-encoded payload
msg.payload = Object.entries({
"grant_type": "refresh_token",
"client_id": "YOUR CLIENT ID",
"client_secret": "YOUR SECRET",
"refresh_token": "YOUR REFRESH TOKEN"
}).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join('&');
return msg;
- An HTTP post node, all blank
- Function node to store your token
flow.set('access_token', msg.payload.access_token);
console.log(msg.payload.access_token);
return msg;
#Flow 2
- MQTT in Node. I have my topic set to home/ford/engine/start
- Function Node (code below) to set up refresh token call
msg.method = "POST";
msg.url = "https://api.mps.ford.com/api/fordconnect/v1/vehicles/{YOURVEHICLEID}/startEngine";
msg.headers = {
"Authorization": "Bearer " + flow.get('access_token'),
"Application-Id": "YOUR APPLICATION ID",
"Content-Type": "application/json"
};
msg.payload = {};
return msg;
- An HTTP post node, all blank