bt-sensors-plugin-sk 1.2.4-2 → 1.2.4-3

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/README.md CHANGED
@@ -1,4 +1,11 @@
1
1
  # Bluetooth Sensors for [Signal K](http://www.signalk.org)
2
+ ## WHAT'S NEW
3
+
4
+ # Version 1.2.4-3
5
+
6
+ - Mercury Smartcraft fixes (working now!)
7
+ - Govee 510x regression errors fixed
8
+
2
9
  # Version 1.2.4-2
3
10
 
4
11
  - RenogyRoverClient fix to Battery SOC calculation
@@ -6,9 +13,7 @@
6
13
  - SwitchBotTH and Meter Plus ::identify errors fixed
7
14
  - MercurySmartcraft::identify method fix
8
15
 
9
- ## WHAT'S NEW
10
-
11
- # 1.2.4-1
16
+ # Version 1.2.4-1
12
17
 
13
18
  - **NEW SENSOR** [Bank Manager](https://marinedcac.com/pages/bankmanager) (tested)
14
19
  - **NEW SENSOR** [Mercury Smartcraft](https://www.mercurymarine.com/us/en/gauges-and-controls/displays/smartcraft-connect) (untested)
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.2.4-2",
3
+ "version": "1.2.4-3",
4
4
  "description": "Bluetooth Sensors for Signalk - see https://www.npmjs.com/package/bt-sensors-plugin-sk#supported-sensors for a list of supported sensors",
5
5
  "main": "index.js",
6
- "dependencies": {
6
+ "dependencies": {
7
7
  "@rjsf/bootstrap-4": "^5.24.11",
8
8
  "@rjsf/core": "^5.24.11",
9
9
  "@rjsf/utils": "^5.24.11",
@@ -18,6 +18,7 @@ class GoveeSensor extends BTSensor {
18
18
 
19
19
  }
20
20
 
21
+ static DATA_ID=0xec88
21
22
  getManufacturer(){
22
23
  return "Govee"
23
24
  }
@@ -38,7 +39,7 @@ class GoveeSensor extends BTSensor {
38
39
  super.propertiesChanged(props)
39
40
  if (!props.hasOwnProperty("ManufacturerData")) return
40
41
 
41
- const buffer = this.getManufacturerData(0xec88)
42
+ const buffer = this.getManufacturerData(this.constructor.DATA_ID)
42
43
  if (buffer) {
43
44
  this.emitValuesFrom(buffer)
44
45
  }
@@ -1,6 +1,7 @@
1
1
  const GoveeSensor = require("./Govee/GoveeSensor");
2
2
 
3
3
  class GoveeH510x extends GoveeSensor{
4
+
4
5
  static getIDRegex(){
5
6
  return /^GVH510[0-9]_[a-f,A-F,0-9]{4}$/
6
7
  }
@@ -15,7 +16,7 @@ class GoveeH510x extends GoveeSensor{
15
16
  sensor.emitValuesFrom(Buffer.from([0x01,0x01,0x03,0x6d,0xcc,0x5c]))
16
17
 
17
18
  }
18
-
19
+ static DATA_ID = 0x0001
19
20
  initSchema(){
20
21
  super.initSchema()
21
22
  this.addDefaultParam("zone")
@@ -41,7 +41,7 @@ class JunctekBMS extends BTSensor{
41
41
  this.addDefaultPath("cycles",'electrical.batteries.cycles')
42
42
 
43
43
  this.addDefaultPath("soc",'electrical.batteries.capacity.stateOfCharge')
44
- this.addDefaultPath("remainingAh",'electrical.batteries.capacity.remaining')
44
+ this.addDefaultPath("remaining",'electrical.batteries.capacity.remaining')
45
45
  this.addDefaultPath("timeRemaining",'electrical.batteries.capacity.timeRemaining')
46
46
  this.addDefaultPath("discharge",'electrical.batteries.capacity.dischargeSinceFull')
47
47
  this.addDefaultPath("charge",'electrical.batteries.capacity.charge')
@@ -53,7 +53,7 @@ class JunctekBMS extends BTSensor{
53
53
 
54
54
  emitFrom(buffer){
55
55
  var value=[], chargeDirection = 1
56
-
56
+ this.debug(buffer)
57
57
  for (let byte of buffer){
58
58
  if (byte==0xBB) {
59
59
  value=[]
@@ -63,50 +63,53 @@ class JunctekBMS extends BTSensor{
63
63
  continue
64
64
  }
65
65
 
66
- value.push[byte]
67
-
68
- if (parseInt(byte.toString(16))==NaN){ //not a base-10 number. seriously. that's how Junctek does this.
66
+ if (isNaN(parseInt(byte.toString(16)))){ //not a base-10 number. seriously. that's how Junctek does this.
69
67
  const v = parseInt(bytesToBase10String(value))
68
+ value=[]
70
69
  switch (byte){
71
- case 0xC0:{
72
- emit("voltage",v/100)
73
- }
74
- case 0xC1:{
75
- emit("current",(v/100)*chargeDirection)
76
- }
77
-
78
- case 0xD1:{
70
+ case 0xC0:
71
+ this.emit("voltage",v/100)
72
+ break
73
+
74
+ case 0xC1:
75
+ this.emit("current",(v/100)*chargeDirection)
76
+ break
77
+
78
+ case 0xD1:
79
79
  if (byte==0)
80
80
  chargeDirection=-1
81
- }
82
-
83
- case 0xD2:{
84
- emit("remainingAh",v/1000)
85
- }
86
-
87
- case 0xD3:{
88
- emit("discharge",v/100000)
89
- }
90
- case 0xD4:{
91
- emit("charge",v/100000)
92
- }
93
- case 0xD6:{
94
- emit("timeRemaining",v*60)
95
- }
96
- case 0xD7:{
97
- emit("impedance",v/100)
98
- }
99
- case 0xD8:{
100
- emit("power",(v/100)*chargeDirection)
101
- }
102
- case 0xD9:{
103
- emit("temperature",v + 173.15) //assume C not F
104
- }
105
- case 0xB1:{
106
- emit("capacityActual",v /10 )
107
- }
81
+ break
82
+
83
+ case 0xD2:
84
+ this.emit("remaining",v*3.6)
85
+ break
86
+
87
+ case 0xD3:
88
+ this.emit("discharge",v/100000)
89
+ break
90
+ case 0xD4:
91
+ this.emit("charge",v/100000)
92
+ break
93
+ case 0xD6:
94
+ this.emit("timeRemaining",v*60)
95
+ break
96
+ case 0xD7:
97
+ this.emit("impedance",v/100)
98
+ break
99
+ case 0xD8:
100
+ this.emit("power",(v/100)*chargeDirection)
101
+ break
102
+ case 0xD9:
103
+ this.emit("temperature",v + 273.15) //assume C not F
104
+ break
105
+ case 0xB1:
106
+ this.emit("capacityActual",v /10 )
107
+ break
108
108
  }
109
109
  }
110
+ else{
111
+ value.push(byte)
112
+ }
110
113
  }
111
114
  }
112
115
  emitGATT(){
@@ -120,8 +123,9 @@ class JunctekBMS extends BTSensor{
120
123
  if (!this.gattServer) {
121
124
  this.gattServer = await this.device.gatt()
122
125
  this.battService = await this.gattServer.getPrimaryService("0000fff0-0000-1000-8000-00805f9b34fb")
123
- this.battCharacteristic = await this.battService.getCharacteristic("0000ffe1-0000-1000-8000-00805f9b34fb")
124
- }
126
+ this.battCharacteristic = await this.battService.getCharacteristic("0000fff1-0000-1000-8000-00805f9b34fb")
127
+
128
+ }
125
129
  resolve(this)
126
130
  }) .catch((e)=>{ reject(e.message) }) })
127
131
  }
@@ -38,7 +38,7 @@ class MercurySmartcraft extends BTSensor{
38
38
  emitGATT(){
39
39
  }
40
40
  initSchema(){
41
- const bo = 0
41
+ const bo = 2
42
42
 
43
43
  super.initSchema()
44
44
  this.addParameter(
@@ -48,7 +48,7 @@ class MercurySmartcraft extends BTSensor{
48
48
  "examples": ["port","starboard","p0","p1"]
49
49
  }
50
50
  )
51
- _schema.properties.params.required=["id"]
51
+ this._schema.properties.params.required=["id"]
52
52
 
53
53
  this.addMetadatum("rpm","Hz","engine revolutions per sec",
54
54
  (buffer)=>{return buffer.readUInt16LE(bo)/60}
@@ -67,15 +67,15 @@ class MercurySmartcraft extends BTSensor{
67
67
  ).default='propulsion.{id}.runTime'
68
68
 
69
69
  this.addMetadatum("rate","m3/s","Fuel rate of consumption (cubic meters per second)",
70
- (buffer)=>{return buffer.readUInt16LE(bo)/10000}
70
+ (buffer)=>{return buffer.readUInt16LE(bo)/100000/3600}
71
71
  ).default='propulsion.{id}.fuel.rate'
72
72
 
73
73
  this.addMetadatum("pressure","Pa","Fuel pressure",
74
- (buffer)=>{return buffer.readUInt16LE(bo)/100}
74
+ (buffer)=>{return buffer.readUInt16LE(bo)*10}
75
75
  ).default='propulsion.{id}.pressure'
76
76
 
77
77
  this.addMetadatum("level","ratio","Level of fluid in tank 0-100%",
78
- (buffer)=>{return buffer.readUInt16LE(bo)/100}
78
+ (buffer)=>{return buffer.readUInt16LE(bo)/10000}
79
79
  ).default='tanks.petrol.currentLevel'
80
80
  }
81
81
 
@@ -100,7 +100,7 @@ class MercurySmartcraft extends BTSensor{
100
100
  }) .catch((e)=>{ reject(e.message) }) })
101
101
  }
102
102
  async initGATTNotifications() {
103
- await this.sdpCharacteristic.writeDataWithoutResponse(Buffer.from([0x0D,0x01]))
103
+ await this.sdpCharacteristic.writeValue(Buffer.from([0x0D,0x01]))
104
104
  for (const c in this.dataCharacteristics){
105
105
  Promise.resolve(this.dataCharacteristics[c].startNotifications().then(()=>{
106
106
  this.dataCharacteristics[c].on('valuechanged', buffer => {
@@ -113,7 +113,7 @@ class MercurySmartcraft extends BTSensor{
113
113
  async stopListening(){
114
114
  super.stopListening()
115
115
  for (const c in this.dataCharacteristics){
116
- if (this.dataCharacteristics[c] && await this.dataCharacteristics[char].isNotifying()) {
116
+ if (this.dataCharacteristics[c] && await this.dataCharacteristics[c].isNotifying()) {
117
117
  await this.dataCharacteristics[c].stopNotifications()
118
118
  }
119
119
  }