samrum/OnStarJS

Not Getting Output

Closed this issue · 6 comments

Hello, pretty new to scripting and looking to get this integrated into HA. I’m having an issue running scripts as it says it’s unable to find onstarjs. Where should I be putting the scripts?

Got that figured out, but now I’m having an issue where the script runs but there is no output of the vehicles on the account

I know I just have to be doing this wrong all around. When I try to create a js script, I get “Cannot import onstarjs outside a module” and it does not work at all when I try it as a ts script. I got it to work by doing import /home/bennythebee/OnStarJS/src/index, but that’s not letting some of the commands work and not getting valid outputs

If you're running node in CommonJS mode (the default), you'd need to use require to import the library. This is the equivalent CJS version of the sample (+ using promises instead of async/await):

const OnStar = require("onstarjs");

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

onStar
  .start()
  .catch((e) => console.error(e));

Getting Error

“Cannot Find Package “onstarjs” imported from /home/bennythebee/OnStarJS/test.js”

Looking through node_modules, onstarjs is not listed

Using onstar2mqtt solved my issues as that was what I was workign towards.