Compare commits
2 Commits
main
...
connect-co
Author | SHA1 | Date | |
---|---|---|---|
|
35e54024c0 | ||
|
409d822978 |
14
package-lock.json
generated
14
package-lock.json
generated
@ -12,7 +12,7 @@
|
||||
"async-mqtt": "^2.6.3",
|
||||
"convert-units": "^2.3.4",
|
||||
"lodash": "^4.17.21",
|
||||
"onstarjs": "^2.3.16",
|
||||
"onstarjs": "^2.3.18",
|
||||
"uuid": "^9.0.0",
|
||||
"winston": "^3.8.2"
|
||||
},
|
||||
@ -5243,9 +5243,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/onstarjs": {
|
||||
"version": "2.3.16",
|
||||
"resolved": "https://registry.npmjs.org/onstarjs/-/onstarjs-2.3.16.tgz",
|
||||
"integrity": "sha512-tGqHJGliiC79C1YnYp+Sdp7ouM7MjNOHvPFBWwFmOPairtuaAaN3gTE8Dd/UTyTwu5qGcV1TWPN2yFFS+x6oNw==",
|
||||
"version": "2.3.18",
|
||||
"resolved": "https://registry.npmjs.org/onstarjs/-/onstarjs-2.3.18.tgz",
|
||||
"integrity": "sha512-veTeNono7cTu7psLC7MmSLg/s9G5zFvDMb7R2Ju+A5ECuwEFASfCUSTbTEjU+TDVkZSbV/wM6V4caBccI57SQw==",
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
@ -10440,9 +10440,9 @@
|
||||
}
|
||||
},
|
||||
"onstarjs": {
|
||||
"version": "2.3.16",
|
||||
"resolved": "https://registry.npmjs.org/onstarjs/-/onstarjs-2.3.16.tgz",
|
||||
"integrity": "sha512-tGqHJGliiC79C1YnYp+Sdp7ouM7MjNOHvPFBWwFmOPairtuaAaN3gTE8Dd/UTyTwu5qGcV1TWPN2yFFS+x6oNw==",
|
||||
"version": "2.3.18",
|
||||
"resolved": "https://registry.npmjs.org/onstarjs/-/onstarjs-2.3.18.tgz",
|
||||
"integrity": "sha512-veTeNono7cTu7psLC7MmSLg/s9G5zFvDMb7R2Ju+A5ECuwEFASfCUSTbTEjU+TDVkZSbV/wM6V4caBccI57SQw==",
|
||||
"requires": {
|
||||
"axios": "^0.21.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
|
@ -32,7 +32,7 @@
|
||||
"async-mqtt": "^2.6.3",
|
||||
"convert-units": "^2.3.4",
|
||||
"lodash": "^4.17.21",
|
||||
"onstarjs": "^2.3.16",
|
||||
"onstarjs": "^2.3.18",
|
||||
"uuid": "^9.0.0",
|
||||
"winston": "^3.8.2"
|
||||
},
|
||||
|
231
src/commands.js
231
src/commands.js
@ -1,126 +1,141 @@
|
||||
|
||||
class Commands {
|
||||
static CONSTANTS = {
|
||||
ALERT_ACTION: {
|
||||
FLASH: 'Flash',
|
||||
HONK: 'Honk',
|
||||
},
|
||||
ALERT_OVERRIDE: {
|
||||
DOOR_OPEN: 'DoorOpen',
|
||||
IGNITION_ON: 'IgnitionOn'
|
||||
},
|
||||
CHARGE_OVERRIDE: {
|
||||
CHARGE_NOW: 'CHARGE_NOW',
|
||||
CANCEL_OVERRIDE: 'CANCEL_OVERRIDE'
|
||||
},
|
||||
CHARGING_PROFILE_MODE: {
|
||||
DEFAULT_IMMEDIATE: 'DEFAULT_IMMEDIATE',
|
||||
IMMEDIATE: 'IMMEDIATE',
|
||||
DEPARTURE_BASED: 'DEPARTURE_BASED',
|
||||
RATE_BASED: 'RATE_BASED',
|
||||
PHEV_AFTER_MIDNIGHT: 'PHEV_AFTER_MIDNIGHT'
|
||||
},
|
||||
CHARGING_PROFILE_RATE: {
|
||||
OFFPEAK: 'OFFPEAK',
|
||||
MIDPEAK: 'MIDPEAK',
|
||||
PEAK: 'PEAK'
|
||||
},
|
||||
DIAGNOSTICS: {
|
||||
ENGINE_COOLANT_TEMP: 'ENGINE COOLANT TEMP',
|
||||
ENGINE_RPM: 'ENGINE RPM',
|
||||
LAST_TRIP_FUEL_ECONOMY: 'LAST TRIP FUEL ECONOMY',
|
||||
EV_ESTIMATED_CHARGE_END: 'EV ESTIMATED CHARGE END',
|
||||
EV_BATTERY_LEVEL: 'EV BATTERY LEVEL',
|
||||
OIL_LIFE: 'OIL LIFE',
|
||||
EV_PLUG_VOLTAGE: 'EV PLUG VOLTAGE',
|
||||
LIFETIME_FUEL_ECON: 'LIFETIME FUEL ECON',
|
||||
HOTSPOT_CONFIG: 'HOTSPOT CONFIG',
|
||||
LIFETIME_FUEL_USED: 'LIFETIME FUEL USED',
|
||||
ODOMETER: 'ODOMETER',
|
||||
HOTSPOT_STATUS: 'HOTSPOT STATUS',
|
||||
LIFETIME_EV_ODOMETER: 'LIFETIME EV ODOMETER',
|
||||
EV_PLUG_STATE: 'EV PLUG STATE',
|
||||
EV_CHARGE_STATE: 'EV CHARGE STATE',
|
||||
TIRE_PRESSURE: 'TIRE PRESSURE',
|
||||
AMBIENT_AIR_TEMPERATURE: 'AMBIENT AIR TEMPERATURE',
|
||||
LAST_TRIP_DISTANCE: 'LAST TRIP DISTANCE',
|
||||
INTERM_VOLT_BATT_VOLT: 'INTERM VOLT BATT VOLT',
|
||||
GET_COMMUTE_SCHEDULE: 'GET COMMUTE SCHEDULE',
|
||||
GET_CHARGE_MODE: 'GET CHARGE MODE',
|
||||
EV_SCHEDULED_CHARGE_START: 'EV SCHEDULED CHARGE START',
|
||||
FUEL_TANK_INFO: 'FUEL TANK INFO',
|
||||
HANDS_FREE_CALLING: 'HANDS FREE CALLING',
|
||||
ENERGY_EFFICIENCY: 'ENERGY EFFICIENCY',
|
||||
VEHICLE_RANGE: 'VEHICLE RANGE',
|
||||
}
|
||||
}
|
||||
static CONSTANTS = {
|
||||
ALERT_ACTION: {
|
||||
FLASH: "Flash",
|
||||
HONK: "Honk",
|
||||
},
|
||||
ALERT_OVERRIDE: {
|
||||
DOOR_OPEN: "DoorOpen",
|
||||
IGNITION_ON: "IgnitionOn",
|
||||
},
|
||||
CHARGE_OVERRIDE: {
|
||||
CHARGE_NOW: "CHARGE_NOW",
|
||||
CANCEL_OVERRIDE: "CANCEL_OVERRIDE",
|
||||
},
|
||||
CHARGING_PROFILE_MODE: {
|
||||
DEFAULT_IMMEDIATE: "DEFAULT_IMMEDIATE",
|
||||
IMMEDIATE: "IMMEDIATE",
|
||||
DEPARTURE_BASED: "DEPARTURE_BASED",
|
||||
RATE_BASED: "RATE_BASED",
|
||||
PHEV_AFTER_MIDNIGHT: "PHEV_AFTER_MIDNIGHT",
|
||||
},
|
||||
CHARGING_PROFILE_RATE: {
|
||||
OFFPEAK: "OFFPEAK",
|
||||
MIDPEAK: "MIDPEAK",
|
||||
PEAK: "PEAK",
|
||||
},
|
||||
DIAGNOSTICS: {
|
||||
ENGINE_COOLANT_TEMP: "ENGINE COOLANT TEMP",
|
||||
ENGINE_RPM: "ENGINE RPM",
|
||||
LAST_TRIP_FUEL_ECONOMY: "LAST TRIP FUEL ECONOMY",
|
||||
EV_ESTIMATED_CHARGE_END: "EV ESTIMATED CHARGE END",
|
||||
EV_BATTERY_LEVEL: "EV BATTERY LEVEL",
|
||||
OIL_LIFE: "OIL LIFE",
|
||||
EV_PLUG_VOLTAGE: "EV PLUG VOLTAGE",
|
||||
LIFETIME_FUEL_ECON: "LIFETIME FUEL ECON",
|
||||
HOTSPOT_CONFIG: "HOTSPOT CONFIG",
|
||||
LIFETIME_FUEL_USED: "LIFETIME FUEL USED",
|
||||
ODOMETER: "ODOMETER",
|
||||
HOTSPOT_STATUS: "HOTSPOT STATUS",
|
||||
LIFETIME_EV_ODOMETER: "LIFETIME EV ODOMETER",
|
||||
EV_PLUG_STATE: "EV PLUG STATE",
|
||||
EV_CHARGE_STATE: "EV CHARGE STATE",
|
||||
TIRE_PRESSURE: "TIRE PRESSURE",
|
||||
AMBIENT_AIR_TEMPERATURE: "AMBIENT AIR TEMPERATURE",
|
||||
LAST_TRIP_DISTANCE: "LAST TRIP DISTANCE",
|
||||
INTERM_VOLT_BATT_VOLT: "INTERM VOLT BATT VOLT",
|
||||
GET_COMMUTE_SCHEDULE: "GET COMMUTE SCHEDULE",
|
||||
GET_CHARGE_MODE: "GET CHARGE MODE",
|
||||
EV_SCHEDULED_CHARGE_START: "EV SCHEDULED CHARGE START",
|
||||
FUEL_TANK_INFO: "FUEL TANK INFO",
|
||||
HANDS_FREE_CALLING: "HANDS FREE CALLING",
|
||||
ENERGY_EFFICIENCY: "ENERGY EFFICIENCY",
|
||||
VEHICLE_RANGE: "VEHICLE RANGE",
|
||||
},
|
||||
};
|
||||
|
||||
constructor(onstar) {
|
||||
this.onstar = onstar;
|
||||
}
|
||||
constructor(onstar) {
|
||||
this.onstar = onstar;
|
||||
}
|
||||
|
||||
async getAccountVehicles() {
|
||||
return this.onstar.getAccountVehicles();
|
||||
}
|
||||
async getAccountVehicles() {
|
||||
return this.onstar.getAccountVehicles();
|
||||
}
|
||||
|
||||
async startVehicle() {
|
||||
return this.onstar.start();
|
||||
}
|
||||
async startVehicle() {
|
||||
return this.onstar.start();
|
||||
}
|
||||
|
||||
async cancelStartVehicle() {
|
||||
return this.onstar.cancelStart();
|
||||
}
|
||||
async cancelStartVehicle() {
|
||||
return this.onstar.cancelStart();
|
||||
}
|
||||
|
||||
async alert({action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
|
||||
delay = 0, duration = 1, override = []}) {
|
||||
return this.onstar.alert({
|
||||
action,
|
||||
delay,
|
||||
duration,
|
||||
override
|
||||
});
|
||||
}
|
||||
async connect() {
|
||||
return this.onstar.connect();
|
||||
}
|
||||
|
||||
async cancelAlert() {
|
||||
return this.onstar.cancelAlert();
|
||||
}
|
||||
async alert(
|
||||
{
|
||||
action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
|
||||
delay = 0,
|
||||
duration = 1,
|
||||
override = [],
|
||||
},
|
||||
) {
|
||||
return this.onstar.alert({
|
||||
action,
|
||||
delay,
|
||||
duration,
|
||||
override,
|
||||
});
|
||||
}
|
||||
|
||||
async lockDoor({delay = 0}) {
|
||||
return this.onstar.lockDoor({delay});
|
||||
}
|
||||
async cancelAlert() {
|
||||
return this.onstar.cancelAlert();
|
||||
}
|
||||
|
||||
async unlockDoor({delay = 0}) {
|
||||
return this.onstar.unlockDoor({delay});
|
||||
}
|
||||
async lockDoor({ delay = 0 }) {
|
||||
return this.onstar.lockDoor({ delay });
|
||||
}
|
||||
|
||||
async chargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW}) {
|
||||
return this.onstar.chargeOverride({mode});
|
||||
}
|
||||
async unlockDoor({ delay = 0 }) {
|
||||
return this.onstar.unlockDoor({ delay });
|
||||
}
|
||||
|
||||
async cancelChargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE}) {
|
||||
return this.onstar.chargeOverride({mode});
|
||||
}
|
||||
async chargeOverride(
|
||||
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW },
|
||||
) {
|
||||
return this.onstar.chargeOverride({ mode });
|
||||
}
|
||||
|
||||
async getChargingProfile() {
|
||||
return this.onstar.getChargingProfile();
|
||||
}
|
||||
async cancelChargeOverride(
|
||||
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE },
|
||||
) {
|
||||
return this.onstar.chargeOverride({ mode });
|
||||
}
|
||||
|
||||
async setChargingProfile() {
|
||||
return this.onstar.setChargingProfile();
|
||||
}
|
||||
async getChargingProfile() {
|
||||
return this.onstar.getChargingProfile();
|
||||
}
|
||||
|
||||
async getLocation() {
|
||||
return this.onstar.location();
|
||||
}
|
||||
async setChargingProfile() {
|
||||
return this.onstar.setChargingProfile();
|
||||
}
|
||||
|
||||
async diagnostics({diagnosticItem = [
|
||||
Commands.CONSTANTS.DIAGNOSTICS.ODOMETER,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.TIRE_PRESSURE,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.AMBIENT_AIR_TEMPERATURE,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.LAST_TRIP_DISTANCE
|
||||
]}) {
|
||||
return this.onstar.diagnostics({diagnosticItem});
|
||||
}
|
||||
async getLocation() {
|
||||
return this.onstar.location();
|
||||
}
|
||||
|
||||
async diagnostics({
|
||||
diagnosticItem = [
|
||||
Commands.CONSTANTS.DIAGNOSTICS.ODOMETER,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.TIRE_PRESSURE,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.AMBIENT_AIR_TEMPERATURE,
|
||||
Commands.CONSTANTS.DIAGNOSTICS.LAST_TRIP_DISTANCE,
|
||||
],
|
||||
}) {
|
||||
return this.onstar.diagnostics({ diagnosticItem });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Commands;
|
Loading…
Reference in New Issue
Block a user