Bug from Last Update to index.js and Proposed Fix
Closed this issue · 1 comments
BigThunderSR commented
I found a bug from your last update to index.js in commit ad3f292 which prevents the location data from being published to MQTT. I was able to fix the issue by changing the following code from (Note items showing **xx**
):
const commandFn = cmd.bind(commands);
logger.info('Command sent', {command});
commandFn(options || {})
.then(data => {
// TODO refactor the response handling for commands
logger.info('Command completed', {command});
**data** = _.get(data, 'response.data');
if (**data**) {
logger.info('Command response data', {**data**});
const location = _.get(data, 'response.data.commandResponse.body.location');
if (location) {
const topic = mqttHA.getStateTopic({name: command});
// TODO create device_tracker entity. MQTT device tracker doesn't support lat/lon and mqtt_json
// doesn't have discovery
client.publish(topic,
JSON.stringify({latitude: location.lat, longitude: location.long}), {retain: true})
.then(() => logger.info('Published location to topic.', {topic}));
}
}
})
To:
const commandFn = cmd.bind(commands);
logger.info('Command sent', { command });
commandFn(options || {})
.then(data => {
// TODO refactor the response handling for commands
logger.info('Command completed', { command });
**const responseData** = _.get(data, 'response.data');
if (**responseData**) {
logger.info('Command response data', { **responseData** });
const location = _.get(data, 'response.data.commandResponse.body.location');
if (location) {
const topic = mqttHA.getStateTopic({ name: command });
// TODO create device_tracker entity. MQTT device tracker doesn't support lat/lon and mqtt_json
// doesn't have discovery
client.publish(topic,
JSON.stringify({ latitude: location.lat, longitude: location.long }), { retain: true })
.then(() => logger.info('Published location to topic.', { topic }));
}
}
})
michaelwoods commented
Merged the above fix and pushed 1.5.4. Please confirm, I no longer have the OnStar package for commands on my car.