Replies: 1 comment 2 replies
-
Widely untested but you could try something we refer to as "callback hell" 😬. client.on("ready", async () => {
const vehicle = client.getVehicle(bluelink_config.vin);
try {
const response = await vehicle.status();
mqtt_client.on("connect", function () {
mqtt_client.subscribe("kia/status", function (err) {
if (!err) {
mqtt_client.publish("kia/status", response);
}
});
});
mqtt_client.on("message", function (topic, message) {
// message is Buffer
console.log(message.toString());
mqtt_client.end();
});
} catch (err) {
// log the error from the command invocation
}
});
client.on("error", async (err) => {
// something went wrong with login
}); Hopefully someone has a better idea than this though. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
I am not so familiar with JS. Can someone help me in order to combine these two code snippets so they work?
Instead of console.log I want to pass the output via MQTT. I read that constant 'response' is not global and therefore unknown to the MQTT code below. I have no idea how to fix that
Beta Was this translation helpful? Give feedback.
All reactions