Add connect command

This commit is contained in:
Neil Hanlon 2023-03-31 18:16:05 -04:00
parent 409d822978
commit 35e54024c0
Signed by: neil
GPG Key ID: 705BC21EC3C70F34

View File

@ -1,59 +1,58 @@
class Commands {
static CONSTANTS = {
ALERT_ACTION: {
FLASH: 'Flash',
HONK: 'Honk',
FLASH: "Flash",
HONK: "Honk",
},
ALERT_OVERRIDE: {
DOOR_OPEN: 'DoorOpen',
IGNITION_ON: 'IgnitionOn'
DOOR_OPEN: "DoorOpen",
IGNITION_ON: "IgnitionOn",
},
CHARGE_OVERRIDE: {
CHARGE_NOW: 'CHARGE_NOW',
CANCEL_OVERRIDE: 'CANCEL_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'
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'
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',
}
}
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;
@ -71,13 +70,23 @@ class Commands {
return this.onstar.cancelStart();
}
async alert({action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
delay = 0, duration = 1, override = []}) {
async connect() {
return this.onstar.connect();
}
async alert(
{
action = [Commands.CONSTANTS.ALERT_ACTION.FLASH],
delay = 0,
duration = 1,
override = [],
},
) {
return this.onstar.alert({
action,
delay,
duration,
override
override,
});
}
@ -93,11 +102,15 @@ class Commands {
return this.onstar.unlockDoor({ delay });
}
async chargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW}) {
async chargeOverride(
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CHARGE_NOW },
) {
return this.onstar.chargeOverride({ mode });
}
async cancelChargeOverride({mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE}) {
async cancelChargeOverride(
{ mode = Commands.CONSTANTS.CHARGE_OVERRIDE.CANCEL_OVERRIDE },
) {
return this.onstar.chargeOverride({ mode });
}
@ -113,12 +126,14 @@ class Commands {
return this.onstar.location();
}
async diagnostics({diagnosticItem = [
async diagnostics({
diagnosticItem = [
Commands.CONSTANTS.DIAGNOSTICS.ODOMETER,
Commands.CONSTANTS.DIAGNOSTICS.TIRE_PRESSURE,
Commands.CONSTANTS.DIAGNOSTICS.AMBIENT_AIR_TEMPERATURE,
Commands.CONSTANTS.DIAGNOSTICS.LAST_TRIP_DISTANCE
]}) {
Commands.CONSTANTS.DIAGNOSTICS.LAST_TRIP_DISTANCE,
],
}) {
return this.onstar.diagnostics({ diagnosticItem });
}
}