bt-sensors-plugin-sk 1.2.0-beta.0.0.4 → 1.2.0-beta.0.0.6

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.
Files changed (37) hide show
  1. package/BTSensor.js +7 -5
  2. package/index.js +8 -5
  3. package/package.json +1 -1
  4. package/plugin_defaults.json +98 -10
  5. package/sensor_classes/ATC.js +2 -3
  6. package/sensor_classes/Aranet/AranetSensor.js +4 -0
  7. package/sensor_classes/Aranet2.js +16 -15
  8. package/sensor_classes/Aranet4.js +23 -17
  9. package/sensor_classes/GoveeH50xx.js +10 -12
  10. package/sensor_classes/GoveeH510x.js +2 -5
  11. package/sensor_classes/IBeacon.js +4 -7
  12. package/sensor_classes/Inkbird.js +2 -2
  13. package/sensor_classes/JBDBMS.js +29 -19
  14. package/sensor_classes/KilovaultHLXPlus.js +32 -15
  15. package/sensor_classes/LancolVoltageMeter.js +4 -3
  16. package/sensor_classes/MopekaTankSensor.js +19 -10
  17. package/sensor_classes/RenogyBattery.js +15 -13
  18. package/sensor_classes/RenogyRoverClient.js +2 -3
  19. package/sensor_classes/RuuviTag.js +35 -27
  20. package/sensor_classes/ShellySBHT003C.js +17 -17
  21. package/sensor_classes/SwitchBotMeterPlus.js +8 -12
  22. package/sensor_classes/SwitchBotTH.js +11 -16
  23. package/sensor_classes/UltrasonicWindMeter.js +8 -4
  24. package/sensor_classes/VictronACCharger.js +19 -8
  25. package/sensor_classes/VictronBatteryMonitor.js +40 -23
  26. package/sensor_classes/VictronDCDCConverter.js +14 -5
  27. package/sensor_classes/VictronDCEnergyMeter.js +26 -7
  28. package/sensor_classes/VictronGXDevice.js +2 -5
  29. package/sensor_classes/VictronInverter.js +18 -14
  30. package/sensor_classes/VictronInverterRS.js +18 -7
  31. package/sensor_classes/VictronLynxSmartBMS.js +15 -13
  32. package/sensor_classes/VictronOrionXS.js +15 -3
  33. package/sensor_classes/VictronSmartBatteryProtect.js +4 -6
  34. package/sensor_classes/VictronSmartLithium.js +18 -18
  35. package/sensor_classes/VictronSolarCharger.js +31 -18
  36. package/sensor_classes/VictronVEBus.js +2 -5
  37. package/sensor_classes/XiaomiMiBeacon.js +17 -18
package/BTSensor.js CHANGED
@@ -101,6 +101,7 @@ function preparePath(obj, str) {
101
101
 
102
102
  class BTSensor extends EventEmitter {
103
103
  //static metadata=new Map()
104
+
104
105
  static DEFAULTS = require('./plugin_defaults.json');
105
106
 
106
107
  /**
@@ -314,11 +315,6 @@ class BTSensor extends EventEmitter {
314
315
  }
315
316
  }
316
317
 
317
- }
318
- async init(){
319
- this.currentProperties = await this.constructor.getDeviceProps(this.device)
320
- this.initSchema()
321
-
322
318
 
323
319
  //create the 'name' parameter
324
320
  this.addDefaultParam("name")
@@ -331,6 +327,12 @@ class BTSensor extends EventEmitter {
331
327
  this.addDefaultPath("RSSI","sensors.RSSI")
332
328
  this.getPath("RSSI").read=()=>{return this.getRSSI()}
333
329
  this.getPath("RSSI").read.bind(this)
330
+
331
+ }
332
+ async init(){
333
+ this.currentProperties = await this.constructor.getDeviceProps(this.device)
334
+ this.initSchema()
335
+
334
336
  this.initListen()
335
337
  }
336
338
 
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 (_transport) {
348
- app.debug(`Setting Bluetooth transport option to ${_transport}`)
351
+ if (transport) {
352
+ app.debug(`Setting Bluetooth transport option to ${transport}`)
349
353
  await adapter.helper.callMethod('SetDiscoveryFilter', {
350
- Transport: new Variant('s', _transport)
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.4",
3
+ "version": "1.2.0-beta.0.0.6",
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": {
@@ -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.{location}.temperature"
26
+ "default": "environment.{zone}.temperature"
16
27
  },
17
28
  "humidity":
18
29
  {
19
30
  "unit":"ratio",
20
- "default":"environment.{location}.humidity"
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
- "current":{
25
- "unit": "A",
26
- "default":"electrical.batteries.0.current"
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
- "voltage":
29
- {
30
- "unit": "V",
31
- "default": "electrical.batteries.0.voltage"
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":{
@@ -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
- initMetadata(){
36
-
34
+ initSchema(){
35
+ super.initSchema()
37
36
  this.addDefaultPath('batteryStrength','sensors.batteryStrength')
38
37
  .read=(buff)=>{return ((buff.readUInt8(12))/100)}
39
38
 
@@ -19,6 +19,10 @@ class AranetSensor extends BTSensor{
19
19
 
20
20
  return null
21
21
  }
22
+ initSchema(){
23
+ super.initSchema()
24
+ this.addDefaultParam("zone")
25
+ }
22
26
 
23
27
  }
24
28
  module.exports=AranetSensor
@@ -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
- initMetadata(){
22
- this.addMetadatum('c02', '', 'c02 concentration',
17
+ initSchema(){
18
+ super.initSchema()
19
+
20
+ this.addMetadatum('co2', 'ppm', 'co2 concentration in zone',
23
21
  (buff)=>{return ((buff.readUInt16LE(8)))})
24
- this.addMetadatum('temp','K', 'temperature',
25
- (buff)=>{return parseFloat((273.15+(buff.readInt16LBE(15))/1000).toFixed(2))})
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.addMetadatum("pressure","","atmospheric pressure",
28
- (buff)=>{return ((buff.readUInt16LE(13)))/10})
29
- this.addMetadatum('batteryStrength', 'ratio', 'sensor battery strength',
30
- (buff)=>{return ((buff.readUInt8(12))/100)})
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
- initMetadata(){
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
- this.addMetadatum('humidity','ratio', 'humidity',
33
- (buff)=>{return ((buff.readUInt8(14))/100)})
34
- this.addMetadatum('batteryStrength', 'ratio', 'sensor battery strength',
35
- (buff)=>{return ((buff.readUInt8(15))/100)})
36
- this.addMetadatum('color', '', 'Warning color (G Y R)',
37
- (buff)=>{return this.COLOR[buff.readUInt8(16)]})
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
- async init(){
21
- await super.init()
22
- this.initMetadata()
23
- }
24
- initMetadata(){
25
- this.addMetadatum('temp','K', 'temperature',
26
- (buffer)=>{return 273.15+(buffer.readUInt16LE(1)/100)
27
- })
28
- this.addMetadatum('humidity','ratio', 'humidity',
29
- (buffer)=>{return buffer.readUInt16LE(3)/10000
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
- async init(){
38
- await super.init()
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
- async init() {
17
- await super.init();
18
- this.initMetadata();
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
- async init(){
17
- await super.init()
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'){
@@ -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 init(){
32
- await super.init()
33
- this.addMetadatum('voltage', 'V', 'Total battery voltage',
34
- (buffer)=>{return buffer.readUInt16BE(4) / 100})
35
- this.addMetadatum('current', 'A', 'Current flow',
36
- (buffer)=>{return buffer.readInt16BE(6) / 100} )
37
- this.addMetadatum('remainingCapacity', 'Ah', 'Remaining battery capacity',
38
- (buffer)=>{return buffer.readUInt16BE(8) / 100} )
39
- this.addMetadatum('capacity', 'Ah', 'Battery capacity',
40
- (buffer)=>{return buffer.readUInt16BE(10) / 100} )
41
- this.addMetadatum('cycles', '', 'cycles',
42
- (buffer)=>{return buffer.readUInt16BE(12)} )
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
- (buffer)=>{return buffer.readUInt16BE(20)} )
45
-
46
- this.addMetadatum('SOC', 'ratio', 'State of Charge',
47
- (buffer)=>{return buffer.readUInt8(23)/100} )
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,11 +74,12 @@ 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
  }
@@ -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 init(){
64
- await super.init()
65
-
66
- this.addMetadatum("voltage","V","Battery Voltage",
67
- (buffer)=>{return Number(buffer.readInt16LE(0)) / 1000})
68
- this.addMetadatum("current","A","Battery Current",
69
- (buffer)=>{return buffer.readInt32LE(4) / 1000})
70
- this.addMetadatum("energy","AHr","Battery Capacity",
71
- (buffer)=>{return buffer.readInt32LE(8) / 1000})
72
- this.addMetadatum("cycles","","Number of Charge Cycles",
73
- (buffer)=>{return buffer.readInt16LE(12)})
74
- this.addMetadatum("soc","ratio","Battery State of Charge",
75
- (buffer)=>{return buffer.readInt16LE(14)})
76
- this.addMetadatum("temperature","K","Battery Temperature",
77
- (buffer)=>{return buffer.readInt16LE(16)/10 })
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
- async init(){
18
- await super.init()
19
- this.addMetadatum('voltage','V', 'battery voltage')
17
+ initSchema(){
18
+ super.initSchema()
19
+ this.addDefaultParam("batteryID")
20
+ this.addDefaultPath('voltage',"electrical.batteries.voltage")
20
21
  }
21
22
 
22
23
  getManufacturer(){
@@ -276,7 +276,7 @@ class MopekaTankSensor extends BTSensor{
276
276
  this.addParameter("medium",
277
277
  {
278
278
  title:"type of liquid in tank",
279
- enum: Object.keys(Media)
279
+ enum: Object.keys(Media)
280
280
  }
281
281
  )
282
282
  this.addParameter("tankHeight",
@@ -286,34 +286,43 @@ class MopekaTankSensor extends BTSensor{
286
286
  unit:"mm"
287
287
  }
288
288
  )
289
+ this.addDefaultParam("id")
289
290
 
290
- this.addMetadatum("battVolt","V","sensor battery in volts",
291
- ((buffer)=>{
291
+ this.addDefaultPath("battVolt","sensors.batteryVoltage")
292
+ .read=((buffer)=>{
292
293
  this.battVolt = (buffer.readUInt8(1)/32)
293
294
  return this.battVolt
294
295
  }).bind(this)
295
- )
296
- this.addMetadatum("battStrength","ratio","sensor battery strength",
297
- (buffer)=>{ return Math.max(0, Math.min(1, (((this.battVolt) - 2.2) / 0.65))) }
298
- )
296
+
297
+ this.addDefaultPath("battStrength", "sensors.batteryStrength")
298
+ .read=(buffer)=>{ return Math.max(0, Math.min(1, (((this.battVolt) - 2.2) / 0.65))) }
299
+
299
300
  this.addMetadatum("temp","K","temperature",
300
301
  ((buffer)=>{
301
302
  this.temp = parseFloat(((buffer.readUInt8(2)&0x7F)+233.15).toFixed(2))
302
303
  return this.temp
303
- }).bind(this)
304
+ })
304
305
  )
306
+ .default="tanks.{id}.temperature"
305
307
  this.addMetadatum("tankLevel","ratio","tank level",
306
308
  (buffer)=>{ return (this._tankLevel(((buffer.readUInt16LE(3))&0x3FFF)))/this.getTankHeight()}
307
309
  )
310
+ .default="tanks.{id}.currentLevel"
311
+
308
312
  this.addMetadatum("readingQuality","","quality of read",
309
313
  (buffer)=>{ return buffer.readUInt8(4)>>6}
310
314
  )
315
+ .default="sensors.{macAndName}.readingQuality"
316
+
311
317
  this.addMetadatum("accX","Mg","acceleration on X-axis",
312
318
  (buffer)=>{ return buffer.readUInt8(8)}
313
319
  )
320
+ .default="sensors.{macAndName}.accelerationXAxis"
321
+
314
322
  this.addMetadatum("accY","Mg","acceleration on Y-axis",
315
323
  (buffer)=>{ return buffer.readUInt8(9)}
316
324
  )
325
+ .default="sensors.{macAndName}.accelerationYAxis"
317
326
  }
318
327
 
319
328
  propertiesChanged(props){
@@ -326,8 +335,8 @@ class MopekaTankSensor extends BTSensor{
326
335
  if (this.name)
327
336
  return this.name
328
337
 
329
- const _name = MopekaDevices.get(this?.modelID??0x0).name
330
- return _name?_name:MopekaDevices.get(0x0).name
338
+ const _name = MopekaDevice.get(this?.modelID??0x0).name
339
+ return _name?_name:MopekaDevice.get(0x0).name
331
340
 
332
341
  }
333
342
  }