bt-sensors-plugin-sk 1.2.0-beta.0.0.3 → 1.2.0-beta.0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BTSensor.js +7 -6
- package/Queue.js +3 -3
- package/index.js +8 -5
- package/package.json +1 -1
- package/plugin_defaults.json +98 -10
- package/sensor_classes/ATC.js +2 -3
- package/sensor_classes/Aranet/AranetSensor.js +4 -0
- package/sensor_classes/Aranet2.js +16 -15
- package/sensor_classes/Aranet4.js +23 -17
- package/sensor_classes/GoveeH50xx.js +10 -12
- package/sensor_classes/GoveeH510x.js +2 -5
- package/sensor_classes/IBeacon.js +4 -7
- package/sensor_classes/Inkbird.js +2 -2
- package/sensor_classes/JBDBMS.js +31 -23
- package/sensor_classes/KilovaultHLXPlus.js +32 -15
- package/sensor_classes/LancolVoltageMeter.js +4 -3
- package/sensor_classes/RenogyBattery.js +15 -13
- package/sensor_classes/RenogyRoverClient.js +2 -3
- package/sensor_classes/RuuviTag.js +35 -27
- package/sensor_classes/ShellySBHT003C.js +17 -17
- package/sensor_classes/SwitchBotMeterPlus.js +8 -12
- package/sensor_classes/SwitchBotTH.js +11 -16
- package/sensor_classes/VictronACCharger.js +5 -5
- package/sensor_classes/VictronBatteryMonitor.js +40 -23
- package/sensor_classes/VictronDCDCConverter.js +14 -5
- package/sensor_classes/VictronDCEnergyMeter.js +26 -7
- package/sensor_classes/VictronGXDevice.js +2 -5
- package/sensor_classes/VictronInverter.js +18 -14
- package/sensor_classes/VictronInverterRS.js +2 -2
- package/sensor_classes/VictronLynxSmartBMS.js +3 -5
- package/sensor_classes/VictronOrionXS.js +2 -2
- package/sensor_classes/VictronSmartBatteryProtect.js +4 -6
- package/sensor_classes/VictronSmartLithium.js +18 -18
- package/sensor_classes/VictronSolarCharger.js +31 -18
- package/sensor_classes/VictronVEBus.js +2 -5
- package/sensor_classes/XiaomiMiBeacon.js +17 -18
- package/testqueue.js +64 -0
package/BTSensor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Variant } = require('dbus-next');
|
|
2
2
|
const { log } = require('node:console');
|
|
3
3
|
const EventEmitter = require('node:events');
|
|
4
|
-
const AutoQueue =
|
|
4
|
+
const AutoQueue = require("./Queue.js")
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @author Andrew Gerngross <oh.that.andy@gmail.com>
|
|
@@ -314,11 +314,6 @@ class BTSensor extends EventEmitter {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
}
|
|
318
|
-
async init(){
|
|
319
|
-
this.currentProperties = await this.constructor.getDeviceProps(this.device)
|
|
320
|
-
this.initSchema()
|
|
321
|
-
|
|
322
317
|
|
|
323
318
|
//create the 'name' parameter
|
|
324
319
|
this.addDefaultParam("name")
|
|
@@ -331,6 +326,12 @@ class BTSensor extends EventEmitter {
|
|
|
331
326
|
this.addDefaultPath("RSSI","sensors.RSSI")
|
|
332
327
|
this.getPath("RSSI").read=()=>{return this.getRSSI()}
|
|
333
328
|
this.getPath("RSSI").read.bind(this)
|
|
329
|
+
|
|
330
|
+
}
|
|
331
|
+
async init(){
|
|
332
|
+
this.currentProperties = await this.constructor.getDeviceProps(this.device)
|
|
333
|
+
this.initSchema()
|
|
334
|
+
|
|
334
335
|
this.initListen()
|
|
335
336
|
}
|
|
336
337
|
|
package/Queue.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
2
|
see: https://stackoverflow.com/questions/53540348/js-async-await-tasks-queue
|
|
3
3
|
*/
|
|
4
|
-
class Queue {
|
|
4
|
+
class Queue {
|
|
5
5
|
constructor() { this._items = []; }
|
|
6
6
|
enqueue(item) { this._items.push(item); }
|
|
7
7
|
dequeue() { return this._items.shift(); }
|
|
8
8
|
get size() { return this._items.length; }
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
class AutoQueue extends Queue {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
this._pendingPromise = false;
|
|
@@ -45,4 +45,4 @@ class Queue {
|
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
module.exports = AutoQueue
|
|
48
|
+
module.exports = AutoQueue
|
package/index.js
CHANGED
|
@@ -20,6 +20,10 @@ class MissingSensor {
|
|
|
20
20
|
this.config=config
|
|
21
21
|
this.addPath=BTSensor.prototype.addPath.bind(this)
|
|
22
22
|
this.addParameter=BTSensor.prototype.addParameter.bind(this)
|
|
23
|
+
this.addDefaultPath=BTSensor.prototype.addDefaultPath.bind(this)
|
|
24
|
+
this.addDefaultParam=BTSensor.prototype.addDefaultPath.bind(this)
|
|
25
|
+
this.addDefaultParam=BTSensor.prototype.addDefaultPath.bind(this)
|
|
26
|
+
this.getPath=BTSensor.prototype.getPath.bind(this)
|
|
23
27
|
|
|
24
28
|
this.getJSONSchema = BTSensor.prototype.getJSONSchema.bind(this)
|
|
25
29
|
this.initSchema = BTSensor.prototype.initSchema.bind(this)
|
|
@@ -50,6 +54,7 @@ class MissingSensor {
|
|
|
50
54
|
initGATTConnection(){
|
|
51
55
|
|
|
52
56
|
}
|
|
57
|
+
|
|
53
58
|
getGATTDescription(){
|
|
54
59
|
return ""
|
|
55
60
|
}
|
|
@@ -342,15 +347,13 @@ module.exports = function (app) {
|
|
|
342
347
|
//filter options which can cause issues with Device::Connect()
|
|
343
348
|
//turning off Discovery
|
|
344
349
|
//try {await adapter.startDiscovery()}
|
|
345
|
-
const _transport = transport?plugin.schema.properties.transport.default:transport
|
|
346
350
|
try{
|
|
347
|
-
if (
|
|
348
|
-
app.debug(`Setting Bluetooth transport option to ${
|
|
351
|
+
if (transport) {
|
|
352
|
+
app.debug(`Setting Bluetooth transport option to ${transport}`)
|
|
349
353
|
await adapter.helper.callMethod('SetDiscoveryFilter', {
|
|
350
|
-
Transport: new Variant('s',
|
|
354
|
+
Transport: new Variant('s', transport)
|
|
351
355
|
})
|
|
352
356
|
}
|
|
353
|
-
adapter._transport=_transport
|
|
354
357
|
await adapter.helper.callMethod('StartDiscovery')
|
|
355
358
|
}
|
|
356
359
|
catch (error){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bt-sensors-plugin-sk",
|
|
3
|
-
"version": "1.2.0-beta.0.0.
|
|
3
|
+
"version": "1.2.0-beta.0.0.5",
|
|
4
4
|
"description": "Bluetooth Sensors for Signalk -- support for Victron devices, RuuviTag, Xiaomi, ATC and Inkbird, Ultrasonic wind meters, Mopeka tank readers, Renogy Battery and Solar Controllers, Aranet4 environment sensors, SwitchBot temp and humidity sensors, KilovaultHLXPlus smart batteries, and Govee GVH51xx temp sensors",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
package/plugin_defaults.json
CHANGED
|
@@ -6,29 +6,117 @@
|
|
|
6
6
|
"location":{
|
|
7
7
|
"description": "Sensor location",
|
|
8
8
|
"examples": ["inside", "outside", "galley", "freezer", "refrigerator", "head", "cabin", "engine", "deck", "cockpit"]
|
|
9
|
+
},
|
|
10
|
+
"zone":{
|
|
11
|
+
"description": "Zone where sensor operates on boat AKA location ",
|
|
12
|
+
"examples": ["inside", "outside", "galley", "freezer", "refrigerator", "head", "cabin", "engine", "deck", "cockpit"]
|
|
13
|
+
},
|
|
14
|
+
"batteryID":{
|
|
15
|
+
"description": "Battery ID",
|
|
16
|
+
"examples": ["starter", "house"]
|
|
17
|
+
},
|
|
18
|
+
"id":{
|
|
19
|
+
"description": "Sensor ID"
|
|
9
20
|
}
|
|
10
21
|
},
|
|
11
22
|
"environment":{
|
|
12
|
-
"temperature":
|
|
23
|
+
"temperature":
|
|
13
24
|
{
|
|
14
25
|
"unit":"K",
|
|
15
|
-
"default": "environment.{
|
|
26
|
+
"default": "environment.{zone}.temperature"
|
|
16
27
|
},
|
|
17
28
|
"humidity":
|
|
18
29
|
{
|
|
19
30
|
"unit":"ratio",
|
|
20
|
-
"default":"environment.{
|
|
31
|
+
"default":"environment.{zone}.humidity"
|
|
32
|
+
},
|
|
33
|
+
"relativeHumidity":
|
|
34
|
+
{
|
|
35
|
+
"title":"Current relative humidity",
|
|
36
|
+
"unit":"ratio",
|
|
37
|
+
"default":"environment.{zone}.humidity"
|
|
38
|
+
},
|
|
39
|
+
"pressure":
|
|
40
|
+
{
|
|
41
|
+
"title": "Current outside air ambient pressure",
|
|
42
|
+
"unit":"Pa",
|
|
43
|
+
"default":"environment.{zone}.humidity"
|
|
21
44
|
}
|
|
22
45
|
},
|
|
23
46
|
"electrical":{
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
47
|
+
"inverters":{
|
|
48
|
+
"ac":{
|
|
49
|
+
"current":{
|
|
50
|
+
"unit": "A",
|
|
51
|
+
"default":"electrical.inverters.{id}.ac.current"
|
|
52
|
+
},
|
|
53
|
+
"voltage":
|
|
54
|
+
{
|
|
55
|
+
"unit": "V",
|
|
56
|
+
"default":"electrical.inverters.{id}.ac.voltage"
|
|
57
|
+
},
|
|
58
|
+
"power":
|
|
59
|
+
{
|
|
60
|
+
"unit": "W",
|
|
61
|
+
"default":"electrical.inverters.{id}.ac.power"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
},
|
|
66
|
+
"dc":{
|
|
67
|
+
"current":{
|
|
68
|
+
"unit": "A",
|
|
69
|
+
"default":"electrical.inverters.{id}.dc.current"
|
|
70
|
+
},
|
|
71
|
+
"voltage":
|
|
72
|
+
{
|
|
73
|
+
"unit": "V",
|
|
74
|
+
"default":"electrical.inverters.{id}.dc.voltage"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
27
78
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
79
|
+
"batteries":{
|
|
80
|
+
|
|
81
|
+
"current":{
|
|
82
|
+
"unit": "A",
|
|
83
|
+
"default":"electrical.batteries.{batteryID}.current"
|
|
84
|
+
},
|
|
85
|
+
"voltage":
|
|
86
|
+
{
|
|
87
|
+
"unit": "V",
|
|
88
|
+
"default": "electrical.batteries.{batteryID}.voltage"
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
"temperature":{
|
|
92
|
+
"unit": "K",
|
|
93
|
+
"default": "electrical.batteries.{batteryID}.temperature"
|
|
94
|
+
},
|
|
95
|
+
"cycles":{
|
|
96
|
+
"unit": "",
|
|
97
|
+
"default": "electrical.batteries.{batteryID}.cycles"
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
"capacity":{
|
|
101
|
+
"remaining":{
|
|
102
|
+
"unit":"Ah",
|
|
103
|
+
"default": "electrical.batteries.{batteryID}.capacity.remaining"
|
|
104
|
+
},
|
|
105
|
+
"actual":{
|
|
106
|
+
"unit":"Ah",
|
|
107
|
+
"default": "electrical.batteries.{batteryID}.capacity.actual"
|
|
108
|
+
},
|
|
109
|
+
"stateOfCharge":{
|
|
110
|
+
"unit":"ratio",
|
|
111
|
+
"default": "electrical.batteries.{batteryID}.capacity.stateOfCharge"
|
|
112
|
+
},
|
|
113
|
+
"timeRemaining":{
|
|
114
|
+
"unit":"s",
|
|
115
|
+
"default": "electrical.batteries.{batteryID}.capacity.timeRemaining"
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
32
120
|
}
|
|
33
121
|
},
|
|
34
122
|
"sensors":{
|
package/sensor_classes/ATC.js
CHANGED
|
@@ -30,10 +30,9 @@ class ATC extends BTSensor{
|
|
|
30
30
|
if (!this.parser){
|
|
31
31
|
this.parser="ATC-LE"
|
|
32
32
|
}
|
|
33
|
-
this.initMetadata()
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
initSchema(){
|
|
35
|
+
super.initSchema()
|
|
37
36
|
this.addDefaultPath('batteryStrength','sensors.batteryStrength')
|
|
38
37
|
.read=(buff)=>{return ((buff.readUInt8(12))/100)}
|
|
39
38
|
|
|
@@ -13,25 +13,26 @@ class Aranet2 extends AranetSensor{
|
|
|
13
13
|
return null //not supported for now
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
async init() {
|
|
17
|
-
await super.init()
|
|
18
|
-
this.initMetadata()
|
|
19
|
-
}
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
initSchema(){
|
|
18
|
+
super.initSchema()
|
|
19
|
+
|
|
20
|
+
this.addMetadatum('co2', 'ppm', 'co2 concentration in zone',
|
|
23
21
|
(buff)=>{return ((buff.readUInt16LE(8)))})
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
.default="environment.{zone}.co2"
|
|
23
|
+
|
|
24
|
+
this.addDefaultPath('temp', 'environment.temperature')
|
|
25
|
+
.read=(buff)=>{return parseFloat((273.15+(buff.readInt16LBE(15))/1000).toFixed(2))}
|
|
26
26
|
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
this.addDefaultPath('pressure', 'environment.pressure')
|
|
28
|
+
.read= (buff)=>{return ((buff.readUInt16LE(13)))/10}
|
|
29
|
+
|
|
30
|
+
this.addDefaultPath('relativeHumidity','environment.relativeHumidity')
|
|
31
|
+
.read=(buff)=>{return ((buff.readUInt16LE(8))/10000)}
|
|
32
|
+
|
|
33
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
34
|
+
.read=(buff)=>{return ((buff.readUInt8(12))/100)}
|
|
31
35
|
|
|
32
|
-
this.addMetadatum('humidity','ratio', 'humidity',
|
|
33
|
-
(buff)=>{return ((buff.readUInt16LE(8))/10000)})
|
|
34
|
-
|
|
35
36
|
}
|
|
36
37
|
propertiesChanged(props){
|
|
37
38
|
super.propertiesChanged(props)
|
|
@@ -15,27 +15,33 @@ class Aranet4 extends AranetSensor{
|
|
|
15
15
|
return null
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async init() {
|
|
19
|
-
await super.init()
|
|
20
|
-
this.initMetadata()
|
|
21
|
-
}
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
this.addMetadatum('co2', 'ppm', 'co2 concentration',
|
|
25
|
-
(buff)=>{return ((buff.readUInt16LE(8)))})
|
|
26
|
-
this.addMetadatum('temp','K', 'temperature',
|
|
27
|
-
(buff)=>{return parseFloat((273.15+(buff.readInt16LE(10))/20).toFixed(2))})
|
|
19
|
+
initSchema(){
|
|
28
20
|
|
|
29
|
-
this.addMetadatum("pressure","hPa","atmospheric pressure",
|
|
30
|
-
(buff)=>{return ((buff.readUInt16LE(12)))/10})
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
super.initSchema()
|
|
23
|
+
this.addMetadatum('co2', 'ppm', 'co2 concentration in zone',
|
|
24
|
+
(buff)=>{return ((buff.readUInt16LE(8)))})
|
|
25
|
+
.default="environment.{zone}.co2"
|
|
26
|
+
|
|
27
|
+
this.addDefaultPath('temp','environment.temperature')
|
|
28
|
+
.read=
|
|
29
|
+
(buff)=>{return parseFloat((273.15+(buff.readInt16LE(10))/20).toFixed(2))}
|
|
38
30
|
|
|
31
|
+
this.addDefaultPath("pressure","environment.pressure")
|
|
32
|
+
.read=(buff)=>{return ((buff.readUInt16LE(12)))/10}
|
|
33
|
+
|
|
34
|
+
this.addDefaultPath('relativeHumidity','environment.relative')
|
|
35
|
+
.read=(buff)=>{return ((buff.readUInt8(14))/100)}
|
|
36
|
+
|
|
37
|
+
this.addMetadatum('color', '', 'Warning color (G Y R)',
|
|
38
|
+
(buff)=>{return this.COLOR[buff.readUInt8(16)]})
|
|
39
|
+
.default="environment.{zone}.warningColor"
|
|
40
|
+
|
|
41
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
42
|
+
.read=(buff)=>{return ((buff.readUInt8(15))/100)}
|
|
43
|
+
|
|
44
|
+
|
|
39
45
|
}
|
|
40
46
|
propertiesChanged(props){
|
|
41
47
|
super.propertiesChanged(props)
|
|
@@ -17,18 +17,16 @@ class GoveeH50xx extends BTSensor {
|
|
|
17
17
|
t
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
(buffer)=>{return
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
(buffer)=>{return buffer.
|
|
30
|
-
})
|
|
31
|
-
this.addMetadatum('battery','ratio', 'battery strength', (buffer)=>{return buffer.readUInt8(5)/100})
|
|
20
|
+
initSchema(){
|
|
21
|
+
super.initSchema()
|
|
22
|
+
this.addDefaultPath("temp","environment.temperature")
|
|
23
|
+
.read= (buffer)=>{return 273.15+(buffer.readUInt16LE(1)/100) }
|
|
24
|
+
|
|
25
|
+
this.addDefaultPath("humidity", "environment.humidity")
|
|
26
|
+
.read = (buffer)=>{return buffer.readUInt16LE(3)/10000}
|
|
27
|
+
|
|
28
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
29
|
+
.read = (buffer)=>{return buffer.readUInt8(5)/100}
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
getManufacturer(){
|
|
@@ -34,11 +34,8 @@ class GoveeH510x extends BTSensor{
|
|
|
34
34
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.initMetadata()
|
|
40
|
-
}
|
|
41
|
-
initMetadata(){
|
|
37
|
+
initSchema(){
|
|
38
|
+
super.initSchema()
|
|
42
39
|
this.addDefaultPath("temp","environment.temperature")
|
|
43
40
|
this.addDefaultPath("humidity", "environment.humidity")
|
|
44
41
|
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
@@ -13,13 +13,10 @@ class IBeacon extends BTSensor {
|
|
|
13
13
|
return null
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
initMetadata(){
|
|
22
|
-
this.addMetadatum('battery','ratio', 'Battery charge state', (buffer)=>{return buffer[6]})
|
|
16
|
+
initSchema(){
|
|
17
|
+
super.initSchema()
|
|
18
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
19
|
+
.read=(buffer)=>{return buffer[6]}
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
propertiesChanged(props){
|
|
@@ -13,8 +13,8 @@ class Inkbird extends BTSensor{
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
initSchema() {
|
|
17
|
+
super.initSchema()
|
|
18
18
|
this.addDefaultPath('temp','environment.temperature')
|
|
19
19
|
this.addDefaultPath('battery', 'sensors.batteryStrength')
|
|
20
20
|
if (this.getName() == 'sps'){
|
package/sensor_classes/JBDBMS.js
CHANGED
|
@@ -28,26 +28,35 @@ class JBDBMS extends BTSensor {
|
|
|
28
28
|
return await this.txChar.writeValueWithResponse(Buffer.from(this.jbdCommand(command)))
|
|
29
29
|
|
|
30
30
|
}
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
(buffer)=>{return buffer.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
(buffer)=>{return buffer.readUInt16BE(
|
|
31
|
+
async initSchema(){
|
|
32
|
+
super.initSchema()
|
|
33
|
+
this.addDefaultParam("batteryID")
|
|
34
|
+
|
|
35
|
+
this.addDefaultPath('voltage','electrical.batteries.voltage')
|
|
36
|
+
.read=(buffer)=>{return buffer.readUInt16BE(4) / 100}
|
|
37
|
+
|
|
38
|
+
this.addDefaultPath('voltage','electrical.batteries.current')
|
|
39
|
+
.read=(buffer)=>{return buffer.readInt16BE(6) / 100}
|
|
40
|
+
|
|
41
|
+
this.addDefaultPath('remainingCapacity','electrical.batteries.capacity.remaining')
|
|
42
|
+
.read=(buffer)=>{return buffer.readUInt16BE(8) / 100}
|
|
43
|
+
|
|
44
|
+
this.addDefaultPath('capacity','electrical.batteries.capacity.actual')
|
|
45
|
+
.read=(buffer)=>{return buffer.readUInt16BE(10) / 100}
|
|
46
|
+
|
|
47
|
+
this.addDefaultPath('cycles','electrical.batteries.cycles' )
|
|
48
|
+
.read=(buffer)=>{return buffer.readUInt16BE(12)}
|
|
49
|
+
|
|
43
50
|
this.addMetadatum('protectionStatus', '', 'Protection Status',
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
(buffer)=>{return buffer.readUInt16BE(20)} )
|
|
52
|
+
.default="electrical.batteries.{batteryID}.protectionStatus"
|
|
53
|
+
|
|
54
|
+
this.addDefaultPath('SOC','electrical.batteries.capacity.stateOfCharge')
|
|
55
|
+
.read=(buffer)=>{return buffer.readUInt8(23)/100}
|
|
48
56
|
|
|
49
57
|
this.addMetadatum('FET', '', 'FET Control',
|
|
50
58
|
(buffer)=>{return buffer.readUInt8(24)} )
|
|
59
|
+
.default="electrical.batteries.{batteryID}.FETControl"
|
|
51
60
|
|
|
52
61
|
await this.deviceConnect()
|
|
53
62
|
await this.initCharacteristics()
|
|
@@ -65,23 +74,22 @@ class JBDBMS extends BTSensor {
|
|
|
65
74
|
for (let i=0; i<this.numberOfCells; i++){
|
|
66
75
|
this.addMetadatum(`cell${i}Voltage`, 'V', `Cell ${i+1} voltage`,
|
|
67
76
|
(buffer)=>{return buffer.readUInt16BE((4+(i*2)))/1000} )
|
|
77
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.voltage`
|
|
68
78
|
this.addMetadatum(`cell${i}Balance`, 'V', `Cell ${i+1} balance` )
|
|
79
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.balance`
|
|
80
|
+
|
|
69
81
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
82
|
+
}
|
|
73
83
|
hasGATT(){
|
|
74
84
|
return true
|
|
75
85
|
}
|
|
76
|
-
initCharacteristics(){
|
|
77
|
-
return new Promise( async (resolve,reject )=>{
|
|
86
|
+
async initCharacteristics(){
|
|
78
87
|
const gattServer = await this.device.gatt()
|
|
79
88
|
const txRxService= await gattServer.getPrimaryService(this.constructor.TX_RX_SERVICE)
|
|
80
89
|
this.rxChar = await txRxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
|
|
81
90
|
this.txChar = await txRxService.getCharacteristic(this.constructor.WRITE_CHAR_UUID)
|
|
82
91
|
await this.rxChar.startNotifications()
|
|
83
|
-
|
|
84
|
-
.catch((e)=>{ reject(e.message) }) })
|
|
92
|
+
return this
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
async initGATTNotifications(){
|
|
@@ -60,35 +60,52 @@ class KilovaultHLXPlus extends BTSensor{
|
|
|
60
60
|
// Nothing to do here. HLX+ only reports via BLE notify, not BLE read
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
(buffer)=>{return buffer.readInt32LE(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
(buffer)=>{return buffer.readInt16LE(
|
|
63
|
+
async initSchema(){
|
|
64
|
+
super.initSchema()
|
|
65
|
+
this.addDefaultParam("batteryID")
|
|
66
|
+
|
|
67
|
+
this.addDefaultPath("voltage","electrical.batteries.voltage")
|
|
68
|
+
.read=(buffer)=>{return Number(buffer.readInt16LE(0)) / 1000}
|
|
69
|
+
|
|
70
|
+
this.addDefaultPath("current","electrical.batteries.current")
|
|
71
|
+
.read=(buffer)=>{return buffer.readInt32LE(4) / 1000}
|
|
72
|
+
|
|
73
|
+
this.addDefaultPath("energy", "electrical.batteries.capacity.remaining")
|
|
74
|
+
.read=(buffer)=>{return buffer.readInt32LE(8) / 1000}
|
|
75
|
+
|
|
76
|
+
this.addDefaultPath("cycles",'electrical.batteries.cycles')
|
|
77
|
+
.read=(buffer)=>{return buffer.readInt16LE(12)}
|
|
78
|
+
|
|
79
|
+
this.addDefaultPath("soc",'electrical.batteries.capacity,stateOfCharge')
|
|
80
|
+
.read=(buffer)=>{return buffer.readInt16LE(14)}
|
|
81
|
+
|
|
82
|
+
this.addDefaultPath("temperature",'electrical.batteries.temperature')
|
|
83
|
+
.read=(buffer)=>{return buffer.readInt16LE(16)/10 }
|
|
78
84
|
|
|
79
85
|
this.addMetadatum("status","","Battery Status",
|
|
80
86
|
(buffer)=>{return buffer.readInt16LE(18) })
|
|
87
|
+
.default="electrical.batteries.{batteryID}.status"
|
|
88
|
+
|
|
81
89
|
this.addMetadatum("AFEStatus","","Battery AFE Status",
|
|
82
90
|
(buffer)=>{return buffer.readInt16LE(20) })
|
|
91
|
+
.default="electrical.batteries.{batteryID}.AFEStatus"
|
|
83
92
|
|
|
84
93
|
this.addMetadatum("cell1_voltage","V","Cell 1 Voltage",
|
|
85
94
|
(buffer)=>{return buffer.readInt16LE(22) / 1000})
|
|
95
|
+
.default="electrical.batteries.{batteryID}.cell1.voltage"
|
|
96
|
+
|
|
86
97
|
this.addMetadatum("cell2_voltage","V","Cell 2 Voltage",
|
|
87
98
|
(buffer)=>{return buffer.readInt16LE(24) / 1000})
|
|
99
|
+
.default="electrical.batteries.{batteryID}.cell2.voltage"
|
|
100
|
+
|
|
88
101
|
this.addMetadatum("cell3_voltage","V","Cell 3 Voltage",
|
|
89
102
|
(buffer)=>{return buffer.readInt16LE(26) / 1000})
|
|
103
|
+
.default="electrical.batteries.{batteryID}.cell3.voltage"
|
|
104
|
+
|
|
90
105
|
this.addMetadatum("cell4_voltage","V","Cell 4 Voltage",
|
|
91
106
|
(buffer)=>{return buffer.readInt16LE(28) / 1000})
|
|
107
|
+
.default="electrical.batteries.{batteryID}.cell4.voltage"
|
|
108
|
+
|
|
92
109
|
}
|
|
93
110
|
|
|
94
111
|
// Concatentate chunks received by notification into a complete message.
|
|
@@ -14,9 +14,10 @@ class LancolVoltageMeter extends BTSensor{
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
17
|
+
initSchema(){
|
|
18
|
+
super.initSchema()
|
|
19
|
+
this.addDefaultParam("batteryID")
|
|
20
|
+
this.addDefaultPath('voltage',"electrical.batteries.voltage")
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
getManufacturer(){
|
|
@@ -22,25 +22,27 @@ class RenogyBattery extends RenogySensor {
|
|
|
22
22
|
initMetadata(){
|
|
23
23
|
|
|
24
24
|
this.addMetadatum('numberOfCells','', 'number of cells')
|
|
25
|
-
this.
|
|
26
|
-
|
|
25
|
+
this.addDefaultPath('current','electrical.batteries.current')
|
|
26
|
+
.read=(buffer)=>{return buffer.readInt16BE(3)/100}
|
|
27
27
|
|
|
28
|
-
this.
|
|
29
|
-
(buffer)=>{return buffer.readUInt16BE(5)/10}
|
|
28
|
+
this.addDefaultPath('voltage','electrical.batteries.voltage')
|
|
29
|
+
.read=(buffer)=>{return buffer.readUInt16BE(5)/10}
|
|
30
30
|
|
|
31
|
-
this.
|
|
32
|
-
(buffer)=>{return buffer.readUInt32BE(7)/1000}
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
(buffer)=>{return buffer.readUInt32BE(11)/1000}
|
|
31
|
+
this.addDefaultPath('remainingCharge', 'electrical.batteries.capacity.remaining')
|
|
32
|
+
.read=(buffer)=>{return buffer.readUInt32BE(7)/1000}
|
|
33
|
+
|
|
34
|
+
this.addDefaultPath('capacity', 'electrical.batteries.capacity.actual')
|
|
35
|
+
.read=(buffer)=>{return buffer.readUInt32BE(11)/1000}
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i++ ; i < this.numberOfCells) {
|
|
38
38
|
this.addMetadatum(`cellVoltage${i}`, 'V', `cell #${i} voltage`,
|
|
39
|
-
(buffer)=>{ return buffer.readUInt16(5+ i*2) }
|
|
40
|
-
|
|
39
|
+
(buffer)=>{ return buffer.readUInt16(5+ i*2) })
|
|
40
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.voltage`
|
|
41
|
+
|
|
41
42
|
this.addMetadatum(`cellTemp${i}`, 'K', `cell #${i} temperature`,
|
|
42
|
-
(buffer)=>{ return buffer.readUInt16(5+ i*2)+273.15 }
|
|
43
|
-
|
|
43
|
+
(buffer)=>{ return buffer.readUInt16(5+ i*2)+273.15 })
|
|
44
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.temperature`
|
|
45
|
+
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
async initGATTConnection() {
|