Add connect command
This commit is contained in:
parent
409d822978
commit
35e54024c0
233
src/commands.js
233
src/commands.js
@ -1,126 +1,141 @@
|
|||||||
|
|
||||||
class Commands {
|
class Commands {
|
||||||
static CONSTANTS = {
|
static CONSTANTS = {
|
||||||
ALERT_ACTION: {
|
ALERT_ACTION: {
|
||||||
FLASH: 'Flash',
|
FLASH: "Flash",
|
||||||
HONK: 'Honk',
|
HONK: "Honk",
|
||||||
},
|
},
|
||||||
ALERT_OVERRIDE: {
|
ALERT_OVERRIDE: {
|
||||||
DOOR_OPEN: 'DoorOpen',
|
DOOR_OPEN: "DoorOpen",
|
||||||
IGNITION_ON: 'IgnitionOn'
|
IGNITION_ON: "IgnitionOn",
|
||||||
},
|
},
|
||||||
CHARGE_OVERRIDE: {
|
CHARGE_OVERRIDE: {
|
||||||
CHARGE_NOW: 'CHARGE_NOW',
|
CHARGE_NOW: "CHARGE_NOW",
|
||||||
CANCEL_OVERRIDE: 'CANCEL_OVERRIDE'
|
CANCEL_OVERRIDE: "CANCEL_OVERRIDE",
|
||||||
},
|
},
|
||||||
CHARGING_PROFILE_MODE: {
|
CHARGING_PROFILE_MODE: {
|
||||||
DEFAULT_IMMEDIATE: 'DEFAULT_IMMEDIATE',
|
DEFAULT_IMMEDIATE: "DEFAULT_IMMEDIATE",
|
||||||
IMMEDIATE: 'IMMEDIATE',
|
IMMEDIATE: "IMMEDIATE",
|
||||||
DEPARTURE_BASED: 'DEPARTURE_BASED',
|
DEPARTURE_BASED: "DEPARTURE_BASED",
|
||||||
RATE_BASED: 'RATE_BASED',
|
RATE_BASED: "RATE_BASED",
|
||||||
PHEV_AFTER_MIDNIGHT: 'PHEV_AFTER_MIDNIGHT'
|
PHEV_AFTER_MIDNIGHT: "PHEV_AFTER_MIDNIGHT",
|
||||||
},
|
},
|
||||||
CHARGING_PROFILE_RATE: {
|
CHARGING_PROFILE_RATE: {
|
||||||
OFFPEAK: 'OFFPEAK',
|
OFFPEAK: "OFFPEAK",
|
||||||
MIDPEAK: 'MIDPEAK',
|
MIDPEAK: "MIDPEAK",
|
||||||
PEAK: 'PEAK'
|
PEAK: "PEAK",
|
||||||
},
|
},
|
||||||
DIAGNOSTICS: {
|
DIAGNOSTICS: {
|
||||||
ENGINE_COOLANT_TEMP: 'ENGINE COOLANT TEMP',
|
ENGINE_COOLANT_TEMP: "ENGINE COOLANT TEMP",
|
||||||
ENGINE_RPM: 'ENGINE RPM',
|
ENGINE_RPM: "ENGINE RPM",
|
||||||
LAST_TRIP_FUEL_ECONOMY: 'LAST TRIP FUEL ECONOMY',
|
LAST_TRIP_FUEL_ECONOMY: "LAST TRIP FUEL ECONOMY",
|
||||||
EV_ESTIMATED_CHARGE_END: 'EV ESTIMATED CHARGE END',
|
EV_ESTIMATED_CHARGE_END: "EV ESTIMATED CHARGE END",
|
||||||
EV_BATTERY_LEVEL: 'EV BATTERY LEVEL',
|
EV_BATTERY_LEVEL: "EV BATTERY LEVEL",
|
||||||
OIL_LIFE: 'OIL LIFE',
|
OIL_LIFE: "OIL LIFE",
|
||||||
EV_PLUG_VOLTAGE: 'EV PLUG VOLTAGE',
|
EV_PLUG_VOLTAGE: "EV PLUG VOLTAGE",
|
||||||
LIFETIME_FUEL_ECON: 'LIFETIME FUEL ECON',
|
LIFETIME_FUEL_ECON: "LIFETIME FUEL ECON",
|
||||||
HOTSPOT_CONFIG: 'HOTSPOT CONFIG',
|
HOTSPOT_CONFIG: "HOTSPOT CONFIG",
|
||||||
LIFETIME_FUEL_USED: 'LIFETIME FUEL USED',
|
LIFETIME_FUEL_USED: "LIFETIME FUEL USED",
|
||||||
ODOMETER: 'ODOMETER',
|
ODOMETER: "ODOMETER",
|
||||||
HOTSPOT_STATUS: 'HOTSPOT STATUS',
|
HOTSPOT_STATUS: "HOTSPOT STATUS",
|
||||||
LIFETIME_EV_ODOMETER: 'LIFETIME EV ODOMETER',
|
LIFETIME_EV_ODOMETER: "LIFETIME EV ODOMETER",
|
||||||
EV_PLUG_STATE: 'EV PLUG STATE',
|
EV_PLUG_STATE: "EV PLUG STATE",
|
||||||
EV_CHARGE_STATE: 'EV CHARGE STATE',
|
EV_CHARGE_STATE: "EV CHARGE STATE",
|
||||||
TIRE_PRESSURE: 'TIRE PRESSURE',
|
TIRE_PRESSURE: "TIRE PRESSURE",
|
||||||
AMBIENT_AIR_TEMPERATURE: 'AMBIENT AIR TEMPERATURE',
|
AMBIENT_AIR_TEMPERATURE: "AMBIENT AIR TEMPERATURE",
|
||||||
LAST_TRIP_DISTANCE: 'LAST TRIP DISTANCE',
|
LAST_TRIP_DISTANCE: "LAST TRIP DISTANCE",
|
||||||
INTERM_VOLT_BATT_VOLT: 'INTERM VOLT BATT VOLT',
|
INTERM_VOLT_BATT_VOLT: "INTERM VOLT BATT VOLT",
|
||||||
GET_COMMUTE_SCHEDULE: 'GET COMMUTE SCHEDULE',
|
GET_COMMUTE_SCHEDULE: "GET COMMUTE SCHEDULE",
|
||||||
GET_CHARGE_MODE: 'GET CHARGE MODE',
|
GET_CHARGE_MODE: "GET CHARGE MODE",
|
||||||
EV_SCHEDULED_CHARGE_START: 'EV SCHEDULED CHARGE START',
|
EV_SCHEDULED_CHARGE_START: "EV SCHEDULED CHARGE START",
|
||||||
FUEL_TANK_INFO: 'FUEL TANK INFO',
|
FUEL_TANK_INFO: "FUEL TANK INFO",
|
||||||
HANDS_FREE_CALLING: 'HANDS FREE CALLING',
|
HANDS_FREE_CALLING: "HANDS FREE CALLING",
|
||||||
ENERGY_EFFICIENCY: 'ENERGY EFFICIENCY',
|
ENERGY_EFFICIENCY: "ENERGY EFFICIENCY",
|
||||||
VEHICLE_RANGE: 'VEHICLE RANGE',
|
VEHICLE_RANGE: "VEHICLE RANGE",
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
constructor(onstar) {
|
constructor(onstar) {
|
||||||
this.onstar = onstar;
|
this.onstar = onstar;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAccountVehicles() {
|
async getAccountVehicles() {
|
||||||
return this.onstar.getAccountVehicles();
|
return this.onstar.getAccountVehicles();
|
||||||
}
|
}
|
||||||
|
|
||||||
async startVehicle() {
|
async startVehicle() {
|
||||||
return this.onstar.start();
|
return this.onstar.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelStartVehicle() {
|
async cancelStartVehicle() {
|
||||||
return this.onstar.cancelStart();
|
return this.onstar.cancelStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
async alert({action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
|
async connect() {
|
||||||
delay = 0, duration = 1, override = []}) {
|
return this.onstar.connect();
|
||||||
return this.onstar.alert({
|
}
|
||||||
action,
|
|
||||||
delay,
|
|
||||||
duration,
|
|
||||||
override
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async cancelAlert() {
|
async alert(
|
||||||
return this.onstar.cancelAlert();
|
{
|
||||||
}
|
action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
|
||||||
|
delay = 0,
|
||||||
|
duration = 1,
|
||||||
|
override = [],
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
return this.onstar.alert({
|
||||||
|
action,
|
||||||
|
delay,
|
||||||
|
duration,
|
||||||
|
override,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async lockDoor({delay = 0}) {
|
async cancelAlert() {
|
||||||
return this.onstar.lockDoor({delay});
|
return this.onstar.cancelAlert();
|
||||||
}
|
}
|
||||||
|
|
||||||
async unlockDoor({delay = 0}) {
|
async lockDoor({ delay = 0 }) {
|
||||||
return this.onstar.unlockDoor({delay});
|
return this.onstar.lockDoor({ delay });
|
||||||
}
|
}
|
||||||
|
|
||||||
async chargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW}) {
|
async unlockDoor({ delay = 0 }) {
|
||||||
return this.onstar.chargeOverride({mode});
|
return this.onstar.unlockDoor({ delay });
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelChargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE}) {
|
async chargeOverride(
|
||||||
return this.onstar.chargeOverride({mode});
|
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW },
|
||||||
}
|
) {
|
||||||
|
return this.onstar.chargeOverride({ mode });
|
||||||
|
}
|
||||||
|
|
||||||
async getChargingProfile() {
|
async cancelChargeOverride(
|
||||||
return this.onstar.getChargingProfile();
|
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE },
|
||||||
}
|
) {
|
||||||
|
return this.onstar.chargeOverride({ mode });
|
||||||
|
}
|
||||||
|
|
||||||
async setChargingProfile() {
|
async getChargingProfile() {
|
||||||
return this.onstar.setChargingProfile();
|
return this.onstar.getChargingProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLocation() {
|
async setChargingProfile() {
|
||||||
return this.onstar.location();
|
return this.onstar.setChargingProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
async diagnostics({diagnosticItem = [
|
async getLocation() {
|
||||||
Commands.CONSTANTS.DIAGNOSTICS.ODOMETER,
|
return this.onstar.location();
|
||||||
Commands.CONSTANTS.DIAGNOSTICS.TIRE_PRESSURE,
|
}
|
||||||
Commands.CONSTANTS.DIAGNOSTICS.AMBIENT_AIR_TEMPERATURE,
|
|
||||||
Commands.CONSTANTS.DIAGNOSTICS.LAST_TRIP_DISTANCE
|
async diagnostics({
|
||||||
]}) {
|
diagnosticItem = [
|
||||||
return this.onstar.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;
|
module.exports = Commands;
|
||||||
|
Loading…
Reference in New Issue
Block a user