From 66425b835adc487b39713ddbb095f37e0a8d3560 Mon Sep 17 00:00:00 2001 From: plips-nl <62832923+plips-nl@users.noreply.github.com> Date: Wed, 2 Mar 2022 10:36:50 +0100 Subject: [PATCH] added nodes driveinfo --- bluelinky.html | 44 ++++++++++++++++++++++++++++++++++++++++---- bluelinky.js | 33 +++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/bluelinky.html b/bluelinky.html index 9eb6544..80cc409 100644 --- a/bluelinky.html +++ b/bluelinky.html @@ -52,6 +52,23 @@ }); + + + @@ -329,6 +347,27 @@
[EU] Gets a report of last month
+ + + + diff --git a/bluelinky.js b/bluelinky.js index e3bbd88..9994913 100644 --- a/bluelinky.js +++ b/bluelinky.js @@ -448,6 +448,38 @@ module.exports = function (RED) { }); } + function GetDriveHistory(config) { + RED.nodes.createNode(this, config); + this.bluelinkyConfig = RED.nodes.getNode(config.bluelinky); + this.status(this.bluelinkyConfig.status); + this.connected = false; + const node = this; + + State.on('changed', (statusObject) => { + this.status(statusObject); + if (statusObject.text === 'Ready') { + this.connected = true; + } + }); + node.on('input', async function (msg) { + try { + if (!this.connected) { + return null; + } + await client.getVehicles(); + const car = await client.getVehicle(this.bluelinkyConfig.vin); + const result = await car.driveHistory(msg.payload); + node.send({ + payload: result, + }); + } catch (err) { + node.send({ + payload: err, + }); + } + }); + } + function Login(config) { RED.nodes.createNode(this, config); this.bluelinkyConfig = RED.nodes.getNode(config.bluelinky); @@ -505,4 +537,5 @@ module.exports = function (RED) { RED.nodes.registerType('set-navigation', SetNavigation); RED.nodes.registerType('get-monthlyreport', GetMonthlyReport); RED.nodes.registerType('get-tripinfo', GetTripInfo); + RED.nodes.registerType('get-drivehistory', GetDriveHistory); }; diff --git a/package.json b/package.json index a031313..ed60721 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-bluelinky", - "version": "0.0.27", + "version": "0.0.28", "description": "A Node Red Library for BlueLinky, a Hyundai and Kia 3rd-party wrapper", "main": "bluelinky.js", "scripts": {