BigThunderSR / onstar2mqtt

OnStarJS wrapper for MQTT
MIT License
17 stars 4 forks source link

Main function error #139

Closed pyther closed 7 months ago

pyther commented 8 months ago

When starting onstar2mqtt I get a main function error. Any suggestion on how to start debugging this? Thanks.

[root@kai ~]# podman logs onstar2mqtt

> onstar2mqtt@1.9.0 start
> node src/index.js

info: OnStar Config {"onstarConfig":{"allowCommands":true,"checkRequestStatus":true,"deviceId":"REDACTED","onStarPin":"REDACTED","password":"REDACTED","refreshInterval":1800000,"requestPollingIntervalSeconds":6,"requestPollingTimeoutSeconds":90,"username":"REDACTED","vin":"REDACTED"},"timestamp":"2024-03-11 15:42:08"}
info: MQTT Config {"mqttConfig":{"host":"127.0.0.1","namePrefix":"","password":"REDACTED","port":1883,"prefix":"homeassistant","tls":false,"username":"mqttuser"},"timestamp":"2024-03-11 15:42:08"}
info: Starting OnStar2MQTT Polling {"timestamp":"2024-03-11 15:42:08"}
info: Requesting vehicles {"timestamp":"2024-03-11 15:42:08"}
info: Vehicle request status {"status":"success","timestamp":"2024-03-11 15:42:11"}
info: Connecting to MQTT {"config":{"username":"mqttuser","will":{"payload":"false","retain":true,"topic":"homeassistant/REDACTED/available"}},"timestamp":"2024-03-11 15:42:11","url":"mqtt://127.0.0.1:1883"}
info: Connected to MQTT! {"timestamp":"2024-03-11 15:42:11"}
info: Subscribed to command topic: {"timestamp":"2024-03-11 15:42:11","topic":"homeassistant/REDACTED/command"}
error: Main function error: {"error":{},"timestamp":"2024-03-11 15:42:11"}
BigThunderSR commented 8 months ago

Based on https://github.com/BigThunderSR/onstar2mqtt/issues/134, I'm guessing you forgot to define "--env MQTT_ONSTAR_POLLING_STATUS_TOPIC=".

pyther commented 8 months ago

Thanks, that did the trick.

pyther commented 8 months ago

For some context, I switched from michaelwoods/onstar2mqtt to your version, due to https://github.com/michaelwoods/onstar2mqtt/issues/347 and just assumed it would be a drop in replacement. You've probably thought of this, but it might be useful to add some checks at startup to ensure necessary environment variables are set.

Anyways, really appreciate the effort in keeping this project active.

BigThunderSR commented 8 months ago

Done as requested in #140 and released in version 1.10.0. Please verify. Thanks.

pyther commented 7 months ago

Thanks, I pulled down the latest image and it seems to work as expected.

Mar 12 21:37:03 kai onstar2mqtt[25750]: /app/src/index.js:64
Mar 12 21:37:03 kai onstar2mqtt[25750]:         throw new Error(`"${mqttRequiredProperties[prop]}" is not defined`);
Mar 12 21:37:03 kai onstar2mqtt[25750]:         ^
Mar 12 21:37:03 kai onstar2mqtt[25750]:
Mar 12 21:37:03 kai onstar2mqtt[25750]: Error: "MQTT_ONSTAR_POLLING_STATUS_TOPIC" is not defined
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Object.<anonymous> (/app/src/index.js:64:15)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Module._compile (node:internal/modules/cjs/loader:1356:14)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Module.load (node:internal/modules/cjs/loader:1197:32)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Module._load (node:internal/modules/cjs/loader:1013:12)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
Mar 12 21:37:03 kai onstar2mqtt[25750]:     at node:internal/main/run_main_module:28:49
Mar 12 21:37:03 kai onstar2mqtt[25750]:
Mar 12 21:37:03 kai onstar2mqtt[25750]: Node.js v18.19.1