bt-sensors-plugin-sk 1.1.0-beta.2.1.4.2 → 1.1.0-beta.2.1.4.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/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const fs = require('fs')
2
2
  const util = require('util')
3
3
  const path = require('path')
4
+ const packageInfo = require("./package.json")
5
+
4
6
  const {createBluetooth} = require('node-ble')
5
7
  const {bluetooth, destroy} = createBluetooth()
6
8
 
@@ -152,8 +154,8 @@ module.exports = function (app) {
152
154
  classMap = utilities_sk.loadClasses(path.join(__dirname, 'sensor_classes'))
153
155
  }
154
156
 
155
- app.debug('Loading plugin')
156
-
157
+ app.debug(`Loading plugin ${packageInfo.version}`)
158
+
157
159
  plugin.schema = {
158
160
  type: "object",
159
161
  description: "NOTE: \n 1) Plugin must be enabled to configure your sensors. \n"+
@@ -414,7 +416,7 @@ module.exports = function (app) {
414
416
  if (plugin.schema.properties.peripherals.items.dependencies)
415
417
  plugin.schema.properties.peripherals.items.dependencies.mac_address.oneOf=[]
416
418
  } else {
417
- app.debug('Plugin build Beta 2.4.1.2 started');
419
+ app.debug(`Loading plugin ${packageInfo.version} started` )
418
420
 
419
421
  }
420
422
  starts++
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.1.0-beta.2.1.4.2",
3
+ "version": "1.1.0-beta.2.1.4.5",
4
4
  "description": "Bluetooth Sensors for Signalk -- support for Victron devices, RuuviTag, Xiaomi, ATC and Inkbird, Ultrasonic, Mopeka tank reader and preliminary support for Govee GVH51xx temp sensors",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -36,6 +36,7 @@ class GoveeTH extends BTSensor{
36
36
 
37
37
  async init(){
38
38
  await super.init()
39
+ this.initMetadata()
39
40
  }
40
41
  initMetadata(){
41
42
  this.addMetadatum('temp','K', 'temperature')
@@ -63,4 +64,4 @@ class GoveeTH extends BTSensor{
63
64
  }
64
65
  }
65
66
  }
66
- module.exports=GoveeTH
67
+ module.exports=GoveeTH
@@ -1,11 +1,6 @@
1
1
  const BTSensor = require("../../BTSensor.js");
2
2
  const crypto = require('node:crypto');
3
- const int24 = require('int24')
4
- const util = require('util')
5
3
  const VC = require('./VictronConstants.js');
6
- const BLACKLISTED = require("../BlackListedDevice.js");
7
- const { resolve } = require("node:path");
8
- const { setMaxIdleHTTPParsers } = require("node:http");
9
4
  function sleep(x) {
10
5
  return new Promise((resolve) => {
11
6
  setTimeout(() => {
@@ -20,7 +15,6 @@ function sleep(x) {
20
15
  this.encryptionKey = config?.encryptionKey
21
16
  }
22
17
 
23
-
24
18
  static async identifyMode(device, mode){
25
19
 
26
20
  var md = await this.getDeviceProp(device,'ManufacturerData')
@@ -54,15 +48,10 @@ function sleep(x) {
54
48
  return null
55
49
  }
56
50
  }
57
-
58
-
59
51
 
60
52
  async init(){
61
53
  await super.init()
62
- var md = this.addMetadatum('encryptionKey','', "Encryption Key")
63
- md.isParam = true
64
- this.metadata = new Map(super.getMetadata())
65
- md = this.addMetadatum('encryptionKey','', "Encryption Key")
54
+ const md =this.addMetadatum('encryptionKey','', "Encryption Key")
66
55
  md.isParam = true
67
56
  this.model_id=this.getManufacturerData(0x2e1).readUInt16LE(2)
68
57
  }
@@ -35,7 +35,7 @@ class VictronACCharger extends VictronSensor{
35
35
  initMetadata(){
36
36
  this.addMetadatum('state','', 'device state',
37
37
  (buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
38
- this.addMetadatum('error','', 'error code',
38
+ this.addMetadatum('chargerError','', 'charger error code',
39
39
  (buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
40
40
 
41
41
  this.addMetadatum('batt1','V', 'battery 1 voltage')
@@ -67,7 +67,7 @@ class VictronACCharger extends VictronSensor{
67
67
  this.emit("batt3", this.NaNif(br.read_unsigned_int(13),0x1FFF)/100)
68
68
  this.emit("curr3", this.NaNif(br.read_unsigned_int(11),0x7FF)/10)
69
69
  this.emit("temp", this.NaNif(br.read_unsigned_int(7),0x7F)+233.15)
70
- this.emit("acCurr", this.NaNif(br.read_unsigned_int(9),0x1FF)/10)
70
+ this.emit("acCurr", this.NaNif(br.read_unsigned_int(9),0x1FF)/100)
71
71
  }
72
72
  }
73
- module.exports=VictronACCharger
73
+ module.exports=VictronACCharger
@@ -16,10 +16,19 @@ Start Bit Nr of Bits Meaning Units Range NA Value Remark
16
16
  152 7 Battery temperature 1°C -40..86 °C 0x7F VE_REG_BAT_TEMPERATURE Temperature = Record value - 40
17
17
  159 1 Unused
18
18
  VE_REG_BATTERY_CELL_VOLTAGE 0x00 ( 0) when cell voltage < 2.61V 0x01 ( 1) when cell voltage == 2.61V 0x7D (125) when cell voltage == 3.85V 0x7E (126) when cell voltage > 3.85 0x7F (127) when cell voltage is not available / unknown
19
- */const VictronSensor = require ("./Victron/VictronSensor")
19
+ */
20
+
21
+ const VictronSensor = require ("./Victron/VictronSensor")
20
22
  const VC = require("./Victron/VictronConstants")
21
23
  const BitReader = require("./_BitReader")
22
24
 
25
+ const BALANCERSTATUS = {
26
+ 0:"Unknown",
27
+ 1:"Balanced",
28
+ 2:"Balancing",
29
+ 3:"Cell imbalance",
30
+ 0xF:"Not applicable"
31
+ }
23
32
  function _toCellVoltage(val){
24
33
  return val==0x7F?NaN:2.6+(val/100)
25
34
  }
@@ -51,15 +60,15 @@ class VictronSmartLithium extends VictronSensor{
51
60
  this.addMetadatum('batteryVoltage','V', 'battery voltage',
52
61
  (buff)=>{return this.NaNif((buff.readUInt16LE(13)&0xFFF),0xFFF)/100})
53
62
  this.addMetadatum('balancerStatus','', 'balancer status', //TODO
54
- (buff)=>{return this.NaNif((buff.readUInt8(14)>>4),0xF)})
63
+ (buff)=>{return BALANCERSTATUS[this.NaNif((buff.readUInt8(14)>>4),0xF)]})
55
64
  this.addMetadatum('batteryTemp','K', 'battery temperature',
56
65
  (buff)=>{return this.NaNif((buff.readUInt8(15)&0x7F),0x7F)+233.15})
57
66
  }
58
67
  emitValuesFrom(buffer){
59
68
  super.emitValuesFrom(buffer)
60
69
  const br = new BitReader(buffer.subarray(6,13))
61
- for (let i = 1; i<8; i++)
70
+ for (let i = 0; i<8; i++)
62
71
  this.emit(`cell${i+1}Voltage`,_toCellVoltage(br.read_unsigned_int(7)))
63
72
  }
64
73
  }
65
- module.exports=VictronSmartLithium
74
+ module.exports=VictronSmartLithium