samrum / OnStarJS

NodeJS Library for making OnStar API requests
MIT License
85 stars 17 forks source link

Not Getting Output #195

Closed BennyDaBee closed 2 years ago

BennyDaBee commented 2 years ago

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?

BennyDaBee commented 2 years ago

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

BennyDaBee commented 2 years ago

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

samrum commented 2 years ago

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));
BennyDaBee commented 2 years ago

Getting Error

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

BennyDaBee commented 2 years ago

Looking through node_modules, onstarjs is not listed

BennyDaBee commented 2 years ago

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