homebridge-fordpass
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -41,2 +41,8 @@ { | ||
"properties": { | ||
"batteryName": { | ||
"title": "Battery Name", | ||
"description": "The name to be used for the battery indicator.", | ||
"type": "string", | ||
"default": "Fuel Level" | ||
}, | ||
"autoRefresh": { | ||
@@ -43,0 +49,0 @@ "title": "Auto-refresh", |
@@ -18,3 +18,6 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const authUrl = 'https://fcis.ice.ibmcloud.com/'; | ||
const authUrl = 'https://sso.ci.ford.com/'; | ||
const applicationId = '71A3AD0A-CF46-4CCF-B473-FC7FE5BC4592'; | ||
const clientId = '9fb503e0-715b-47e8-adfd-ad4b7770f73b'; | ||
const userAgent = 'FordPass/5 CFNetwork/1325.0.1 Darwin/21.1.0'; | ||
class Connection { | ||
@@ -33,6 +36,6 @@ constructor(config, log) { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'User-Agent': 'fordpass-na/353 CFNetwork/1121.2.2 Darwin/19.3.0', | ||
'User-Agent': userAgent, | ||
}, | ||
data: querystring_1.default.stringify({ | ||
client_id: '9fb503e0-715b-47e8-adfd-ad4b7770f73b', | ||
client_id: clientId, | ||
grant_type: 'password', | ||
@@ -45,5 +48,19 @@ username: this.config.username, | ||
const result = yield (0, axios_1.default)(options); | ||
if (result.status === 200) { | ||
this.config.access_token = result.data.access_token; | ||
return true; | ||
if (result.status === 200 && result.data.access_token) { | ||
const nextResult = yield axios_1.default.put('https://api.mps.ford.com/api/oauth2/v1/token', { | ||
code: result.data.access_token, | ||
}, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'User-Agent': userAgent, | ||
'Application-Id': applicationId, | ||
}, | ||
}); | ||
if (nextResult.status === 200 && nextResult.data.access_token) { | ||
this.config.access_token = nextResult.data.access_token; | ||
return true; | ||
} | ||
else { | ||
this.log.error(`Auth failed with status: ${nextResult.status}`); | ||
} | ||
} | ||
@@ -50,0 +67,0 @@ else { |
@@ -20,3 +20,3 @@ "use strict"; | ||
'Content-Type': 'application/json', | ||
'User-Agent': 'fordpass-na/353 CFNetwork/1121.2.2 Darwin/19.3.0', | ||
'User-Agent': 'FordPass/5 CFNetwork/1325.0.1 Darwin/21.1.0', | ||
}; | ||
@@ -23,0 +23,0 @@ const fordAPIUrl = 'https://usapi.cv.ford.com/'; |
@@ -37,2 +37,3 @@ "use strict"; | ||
configureAccessory(accessory) { | ||
var _a; | ||
const self = this; | ||
@@ -48,3 +49,3 @@ this.log.info(`Configuring accessory ${accessory.displayName}`); | ||
const switchService = fordAccessory.createService(hap.Service.Switch); | ||
const batteryService = fordAccessory.createService(hap.Service.Battery, 'Fuel Level'); | ||
const batteryService = fordAccessory.createService(hap.Service.Battery, ((_a = this.config.options) === null || _a === void 0 ? void 0 : _a.batteryName) || 'Fuel Level'); | ||
lockService.setCharacteristic(hap.Characteristic.LockCurrentState, defaultState); | ||
@@ -83,5 +84,5 @@ lockService | ||
.on("get", (callback) => __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
var _b; | ||
let lockNumber = hap.Characteristic.LockTargetState.UNSECURED; | ||
const lockStatus = (_a = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _a === void 0 ? void 0 : _a.lockStatus.value; | ||
const lockStatus = (_b = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _b === void 0 ? void 0 : _b.lockStatus.value; | ||
if (lockStatus === 'LOCKED') { | ||
@@ -119,4 +120,4 @@ lockNumber = hap.Characteristic.LockTargetState.SECURED; | ||
.on("get", (callback) => __awaiter(this, void 0, void 0, function* () { | ||
var _b; | ||
const engineStatus = ((_b = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _b === void 0 ? void 0 : _b.remoteStartStatus.value) || 0; | ||
var _c; | ||
const engineStatus = ((_c = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _c === void 0 ? void 0 : _c.remoteStartStatus.value) || 0; | ||
callback(undefined, engineStatus); | ||
@@ -140,5 +141,5 @@ const status = yield vehicle.status(); | ||
.on("get", (callback) => __awaiter(this, void 0, void 0, function* () { | ||
var _c, _d, _e, _f, _g, _h, _j, _k; | ||
const fuel = (_d = (_c = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _c === void 0 ? void 0 : _c.fuel) === null || _d === void 0 ? void 0 : _d.fuelLevel; | ||
const battery = (_f = (_e = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _e === void 0 ? void 0 : _e.batteryFillLevel) === null || _f === void 0 ? void 0 : _f.value; | ||
var _d, _e, _f, _g, _h, _j, _k, _l; | ||
const fuel = (_e = (_d = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _d === void 0 ? void 0 : _d.fuel) === null || _e === void 0 ? void 0 : _e.fuelLevel; | ||
const battery = (_g = (_f = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _f === void 0 ? void 0 : _f.batteryFillLevel) === null || _g === void 0 ? void 0 : _g.value; | ||
let level = fuel || battery || 100; | ||
@@ -154,5 +155,5 @@ if (level > 100) { | ||
if (status) { | ||
const fuel = (_g = status.fuel) === null || _g === void 0 ? void 0 : _g.fuelLevel; | ||
const battery = (_h = status.batteryFillLevel) === null || _h === void 0 ? void 0 : _h.value; | ||
const chargingStatus = (_k = (_j = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _j === void 0 ? void 0 : _j.chargingStatus) === null || _k === void 0 ? void 0 : _k.value; | ||
const fuel = (_h = status.fuel) === null || _h === void 0 ? void 0 : _h.fuelLevel; | ||
const battery = (_j = status.batteryFillLevel) === null || _j === void 0 ? void 0 : _j.value; | ||
const chargingStatus = (_l = (_k = vehicle === null || vehicle === void 0 ? void 0 : vehicle.info) === null || _k === void 0 ? void 0 : _k.chargingStatus) === null || _l === void 0 ? void 0 : _l.value; | ||
let level = fuel || battery || 100; | ||
@@ -159,0 +160,0 @@ if (level > 100) { |
{ | ||
"displayName": "Homebridge FordPass", | ||
"name": "homebridge-fordpass", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Fordpass plugin for homebridge: https://homebridge.io/", | ||
@@ -11,6 +11,2 @@ "main": "dist/index.js", | ||
{ | ||
"type": "individual", | ||
"url": "https://www.buymeacoffee.com/L1FgZTD" | ||
}, | ||
{ | ||
"type": "github", | ||
@@ -62,16 +58,16 @@ "url": "https://github.com/sponsors/Brandawg93" | ||
"@types/jest": "^27.0.3", | ||
"@types/node": "^16.11.9", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"eslint": "^8.2.0", | ||
"@types/node": "^17.0.5", | ||
"@typescript-eslint/eslint-plugin": "^5.8.1", | ||
"@typescript-eslint/parser": "^5.8.1", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^25.2.4", | ||
"eslint-plugin-jest": "^25.3.2", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"homebridge": "^1.3.6", | ||
"jest": "^27.3.1", | ||
"prettier": "^2.4.1", | ||
"homebridge": "^1.3.9", | ||
"jest": "^27.4.5", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.5.2" | ||
"ts-jest": "^27.1.2", | ||
"typescript": "^4.5.4" | ||
} | ||
} |
@@ -12,3 +12,2 @@ <p align="center"> | ||
[![PayPal](https://img.shields.io/badge/paypal-donate-blue?logo=paypal)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=CEYYGVB7ZZ764&item_name=homebridge-fordpass¤cy_code=USD&source=url) | ||
[![BuyMeACoffee](https://img.shields.io/badge/coffee-donate-orange?logo=buy-me-a-coffee&logoColor=yellow)](https://www.buymeacoffee.com/L1FgZTD) | ||
@@ -61,4 +60,4 @@ [![verified-by-homebridge](https://img.shields.io/badge/homebridge-verified-blueviolet?color=%23491F59)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins) | ||
## Donate to Support homebridge-fordpass | ||
This plugin was made with you in mind. If you would like to show your appreciation for its continued development, please consider making [a small donation](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=CEYYGVB7ZZ764&item_name=homebridge-fordpass¤cy_code=USD&source=url). | ||
This plugin was made with you in mind. If you would like to show your appreciation for its continued development, please consider [sponsoring me on Github](https://github.com/sponsors/Brandawg93). | ||
<sub><sup>**Disclaimer:** This plugin and its contributers are not affiliated with Ford Motor Company in any way.</sub></sup> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88999
631
62