Skip to content

Commit

Permalink
Fix crash when publishing error message to commandStatusTopic
Browse files Browse the repository at this point in the history
  • Loading branch information
BigThunderSR committed Dec 25, 2023
1 parent 7c3a622 commit 7c29cdb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"homepage": "https://github.com/BigThunderSR/onstar2mqtt#readme",
"dependencies": {
"async-mqtt": "^2.6.3",
"circular-json": "^0.5.9",
"convert-units": "^2.3.4",
"dotenv": "^16.3.1",
"lodash": "^4.17.21",
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const {Diagnostic} = require('./diagnostic');
const MQTT = require('./mqtt');
const Commands = require('./commands');
const logger = require('./logger');
const CircularJSON = require('circular-json');



const onstarConfig = {
Expand Down Expand Up @@ -111,7 +113,7 @@ const configureMQTT = async (commands, client, mqttHA) => {
})
.catch((err)=> {logger.error('Command error', {command, err})
logger.info(commandStatusTopic);
client.publish(commandStatusTopic, JSON.stringify({"Command": err}), {retain: true})});
client.publish(commandStatusTopic, CircularJSON.stringify({"Command": err}), {retain: true})});
});
const topic = mqttHA.getCommandTopic();
logger.info('Subscribed to command topic', {topic});
Expand Down

0 comments on commit 7c29cdb

Please sign in to comment.