Skip to content

Commit

Permalink
Merge pull request #90 from olithissen/master
Browse files Browse the repository at this point in the history
Enriches the original msg instead of creating new msg
  • Loading branch information
Hacksore authored Jun 21, 2024
2 parents bcb31ca + 02bc112 commit 4d7494c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 50 deletions.
80 changes: 32 additions & 48 deletions bluelinky.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ module.exports = function (RED) {
refresh: config.dorefresh,
parsed: config.parsed,
});
node.send({
payload: status,
});
msg.payload = status;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -59,9 +58,8 @@ module.exports = function (RED) {
const status = await car.fullStatus({
refresh: config.dorefresh,
});
node.send({
payload: status,
});
msg.payload = status;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -91,9 +89,8 @@ module.exports = function (RED) {
const car = await client.getVehicle(this.bluelinkyConfig.vin);
this.status(this.bluelinkyConfig.status);
const result = await car.unlock();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -123,9 +120,8 @@ module.exports = function (RED) {
const car = await client.getVehicle(this.bluelinkyConfig.vin);
this.status(this.bluelinkyConfig.status);
const result = await car.startCharge();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -155,9 +151,8 @@ module.exports = function (RED) {
const car = await client.getVehicle(this.bluelinkyConfig.vin);
this.status(this.bluelinkyConfig.status);
const result = await car.stopCharge();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -187,9 +182,8 @@ module.exports = function (RED) {
const car = await client.getVehicle(this.bluelinkyConfig.vin);
this.status(this.bluelinkyConfig.status);
const result = await car.location();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -219,9 +213,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.odometer();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -250,9 +243,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.start(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -281,9 +273,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.stop(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -311,9 +302,8 @@ module.exports = function (RED) {
}
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.lock();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -342,9 +332,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.setChargeTargets(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -373,9 +362,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const limits = await car.getChargeTargets();
node.send({
payload: limits,
});
msg.payload = limits;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -404,9 +392,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.setNavigation(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -436,9 +423,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.monthlyReport();
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -468,9 +454,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.tripInfo(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down Expand Up @@ -500,9 +485,8 @@ module.exports = function (RED) {
await client.getVehicles();
const car = await client.getVehicle(this.bluelinkyConfig.vin);
const result = await car.driveHistory(msg.payload);
node.send({
payload: result,
});
msg.payload = result;
node.send(msg);
} catch (err) {
node.send({
payload: err,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

0 comments on commit 4d7494c

Please sign in to comment.