2.5.1 • Published 25 days ago

onstarjs v2.5.1

Weekly downloads
44
License
MIT
Repository
github
Last release
25 days ago

OnStarJS

npm version Build Status Coverage Status

An unofficial NodeJS library to make OnStar requests.

Use at your own risk. This is an unofficial library.

Usage

Use the Get Account Vehicles request to see which requests your vehicle supports if you don't already know.

Sample

Use a random version 4 uuid as a deviceId. Generator available here.

import OnStar from "onstarjs";

const onStar = OnStar.create({
  deviceId: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  vin: "1G2ZF58B774109863",
  username: "foo@bar.com",
  password: "p@ssw0rd",
  onStarPin: "1234",
});

try {
  await onStar.alert({
    action: ["Flash"],
  });

  await onStar.start();
} catch (e) {
  console.error(e);
}

Additional Configuration Options

Default Value: true

When false, requests resolve when the API returns an 'In Progress' response. For requests that return data, this option is ignored.

This is useful because, with the usual request polling to wait for a "Complete" response from the API, requests will take much longer to resolve.

Default Value: 6

When checkRequestStatus is true, this is how often status check requests will be made

Default Value: 60

When checkRequestStatus is true, this is how long a request will make subsequent status check requests before timing out.

Responses

For commands that return data like diagnostics or location, the data returned by the API is accessible via result.response.data

Commands

onStar.getAccountVehicles();
onStar.start();
onStar.cancelStart();
onStar.alert([options]);
OptionDefaultValid Values
action"Flash", "Honk""Flash", "Honk"
delay0Any integer (minutes)
duration1Any integer (minutes)
override"DoorOpen", "IgnitionOn""DoorOpen", "IgnitionOn"
onStar.cancelAlert();
onStar.lockDoor([options]);
OptionDefaultValid Values
delay0Any integer (minutes)
onStar.unlockDoor([options]);
OptionDefaultValid Values
delay0Any integer (minutes)

Locks the trunk but doesn't automatically close it.

onStar.lockTrunk([options]);
OptionDefaultValid Values
delay0Any integer (minutes)

Unlocks the trunk but doesn't automatically open it. All doors remain locked.

onStar.unlockTrunk([options]);
OptionDefaultValid Values
delay0Any integer (minutes)

Returns the location of the vehicle

onStar.location();

Example Response

{ location: { lat: '50', long: '-75' } }
onStar.chargeOverride([options]);
OptionDefaultValid Values
mode"CHARGE_NOW""CHARGE_NOW", "CANCEL_OVERRIDE"
onStar.getChargingProfile();
onStar.setChargingProfile([options]);
OptionDefaultValid Values
chargeMode"IMMEDIATE""DEFAULT_IMMEDIATE", "IMMEDIATE", "DEPARTURE_BASED", "RATE_BASED", "PHEV_AFTER_MIDNIGHT"
rateType"MIDPEAK""OFFPEAK", "MIDPEAK", "PEAK"
onStar.diagnostics([options]);
OptionDefaultValid Values
diagnosticItem"ODOMETER", "TIRE PRESSURE", "AMBIENT AIR TEMPERATURE", "LAST TRIP DISTANCE""ENGINE COOLANT TEMP", "ENGINE RPM", "LAST TRIP FUEL ECONOMY", "EV ESTIMATED CHARGE END", "EV BATTERY LEVEL", "OIL LIFE", "EV PLUG VOLTAGE", "LIFETIME FUEL ECON", "HOTSPOT CONFIG", "LIFETIME FUEL USED", "ODOMETER", "HOTSPOT STATUS", "LIFETIME EV ODOMETER", "EV PLUG STATE", "EV CHARGE STATE", "TIRE PRESSURE", "AMBIENT AIR TEMPERATURE", "LAST TRIP DISTANCE", "INTERM VOLT BATT VOLT", "GET COMMUTE SCHEDULE", "GET CHARGE MODE", "EV SCHEDULED CHARGE START", "FUEL TANK INFO", "HANDS FREE CALLING", "ENERGY EFFICIENCY", "VEHICLE RANGE"

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install

Tests

All

Run both unit and functional tests

pnpm test

Unit

pnpm test:unit

Functional

These tests will execute actual requests to the OnStar API. They will perform a Get Account Vehicles request followed by a Cancel Alert request.

Because of this, the test will require actual OnStar credentials to run. To provide them, copy .env.example to .env and replace the placeholder values inside.

pnpm test:functional

Credits

Made possible by mikenemat's work in gm-onstar-probe. Their work describing the process for remote start enabled the rest of the methods implemented here.

2.5.1

25 days ago

2.5.0

2 months ago

2.4.0

2 months ago

2.3.30

4 months ago

2.3.28

6 months ago

2.3.27

7 months ago

2.3.29

6 months ago

2.3.24

11 months ago

2.3.23

11 months ago

2.3.26

8 months ago

2.3.25

9 months ago

2.3.20

1 year ago

2.3.22

1 year ago

2.3.21

1 year ago

2.3.19

1 year ago

2.3.17

1 year ago

2.3.16

1 year ago

2.3.18

1 year ago

2.3.15

1 year ago

2.3.13

2 years ago

2.3.12

2 years ago

2.3.14

1 year ago

2.3.11

2 years ago

2.3.10

2 years ago

2.3.8

2 years ago

2.3.9

2 years ago

2.3.7

2 years ago

2.3.6

2 years ago

2.3.5

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.0

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.14

3 years ago

2.0.13

3 years ago

2.0.12

3 years ago

2.0.11

3 years ago

2.0.10

3 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago