bt-sensors-plugin-sk 1.2.4-3 → 1.2.5-1
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 +34 -7
- package/README.md +22 -0
- package/bt-sensors-plugin-sk copy.json +170 -0
- package/diff.txt +2860 -0
- package/index.js +31 -15
- package/package.json +1 -1
- package/public/847.js +1 -1
- package/public/index.html +23 -0
- package/sensor_classes/BTHome/AbstractBTHomeSensor.js +26 -1
- package/sensor_classes/Junctek.js +41 -16
- package/sensor_classes/MercurySmartcraft.js +2 -2
- package/sensor_classes/MopekaTankSensor.js +10 -8
- package/sensor_classes/RuuviTag.js +5 -5
- package/sensor_classes/ShellySBDW002C.js +51 -0
- package/sensor_classes/ShellySBMO003Z.js +1 -2
- package/sensor_classes/ShenzhenLiOnBMS.js +1 -0
- package/sensor_classes/Victron/VictronSensor.js +29 -8
- package/sensor_classes/XiaomiMiBeacon.js +2 -1
- package/src/components/PluginConfigurationPanel.js +86 -155
package/BTSensor.js
CHANGED
|
@@ -74,7 +74,7 @@ function preparePath(obj, str) {
|
|
|
74
74
|
evalResult= evalResult.call(obj)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
resultString += evalResult !== undefined ? evalResult : `${keyToAccess}_value_undefined`;
|
|
77
|
+
resultString += evalResult !== undefined ? evalResult.replace(/\s+/g,'_') : `${keyToAccess}_value_undefined`;
|
|
78
78
|
} catch (error) {
|
|
79
79
|
console.error(`Error accessing key '${keyToAccess}':`, error);
|
|
80
80
|
resultString += fullMatch; // Keep the original curly braces on error
|
|
@@ -405,6 +405,12 @@ class BTSensor extends EventEmitter {
|
|
|
405
405
|
if (!param.type)
|
|
406
406
|
param.type="string"
|
|
407
407
|
|
|
408
|
+
if (param.isRequired) {
|
|
409
|
+
if (!Object.hasOwn(this._schema.properties.params, "required"))
|
|
410
|
+
this._schema.properties.params.required=[tag]
|
|
411
|
+
else
|
|
412
|
+
this._schema.properties.params.required.push(tag)
|
|
413
|
+
}
|
|
408
414
|
this._schema.properties.params.properties[tag]=param
|
|
409
415
|
return this._schema.properties.params.properties[tag]
|
|
410
416
|
}
|
|
@@ -413,6 +419,13 @@ class BTSensor extends EventEmitter {
|
|
|
413
419
|
if (!path.type)
|
|
414
420
|
path.type="string"
|
|
415
421
|
|
|
422
|
+
if (path.isRequired) {
|
|
423
|
+
if (!Object.hasOwn(this._schema.properties.paths, "required"))
|
|
424
|
+
this._schema.properties.paths.required=[tag]
|
|
425
|
+
else
|
|
426
|
+
this._schema.properties.paths.required.push(tag)
|
|
427
|
+
}
|
|
428
|
+
|
|
416
429
|
if (!path.pattern)
|
|
417
430
|
path.pattern=//"^(?:[^{}\\s]*\\{[a-zA-Z0-9]+\\}[^{}\\s]*|[^{}\\s]*)$"
|
|
418
431
|
"^((\\{[a-zA-Z0-9]+\\}|[a-zA-Z0-9]+))(\\.(\\{[a-zA-Z0-9]+\\}|[a-zA-Z0-9]+))*$"
|
|
@@ -424,7 +437,13 @@ class BTSensor extends EventEmitter {
|
|
|
424
437
|
|
|
425
438
|
if (!param.type)
|
|
426
439
|
param.type="string"
|
|
427
|
-
|
|
440
|
+
|
|
441
|
+
if (param.isRequired) {
|
|
442
|
+
if (!Object.hasOwn(this._schema.properties.gattParams, "required"))
|
|
443
|
+
this._schema.properties.gattParams.required=[tag]
|
|
444
|
+
else
|
|
445
|
+
this._schema.properties.gattParams.required.push(tag)
|
|
446
|
+
}
|
|
428
447
|
return this._schema.properties.gattParams.properties[tag]=param
|
|
429
448
|
}
|
|
430
449
|
|
|
@@ -433,8 +452,10 @@ class BTSensor extends EventEmitter {
|
|
|
433
452
|
return this.addPath(tag,Object.assign({}, path))
|
|
434
453
|
}
|
|
435
454
|
|
|
436
|
-
addDefaultParam(tag){
|
|
437
|
-
|
|
455
|
+
addDefaultParam(tag,required=false){
|
|
456
|
+
const param = Object.assign({}, BTSensor.DEFAULTS.params[tag])
|
|
457
|
+
param.isRequired=required
|
|
458
|
+
return this.addParameter(tag,param)
|
|
438
459
|
}
|
|
439
460
|
|
|
440
461
|
getJSONSchema(){
|
|
@@ -866,12 +887,14 @@ class BTSensor extends EventEmitter {
|
|
|
866
887
|
Object.keys(this.getPaths()).forEach((tag)=>{
|
|
867
888
|
const pathMeta=this.getPath(tag)
|
|
868
889
|
const path = config.paths[tag]
|
|
869
|
-
if (!(path===undefined))
|
|
890
|
+
if (!(path===undefined)) {
|
|
891
|
+
const preparedPath =
|
|
870
892
|
this.app.handleMessage(id,
|
|
871
893
|
{
|
|
872
894
|
updates:
|
|
873
|
-
[{ meta: [{path:
|
|
895
|
+
[{ meta: [{path: preparePath(this, path), value: { units: pathMeta?.unit }}]}]
|
|
874
896
|
})
|
|
897
|
+
}
|
|
875
898
|
})
|
|
876
899
|
}
|
|
877
900
|
|
|
@@ -881,11 +904,12 @@ class BTSensor extends EventEmitter {
|
|
|
881
904
|
const pathMeta=this.getPath(tag)
|
|
882
905
|
const path = deviceConfig.paths[tag];
|
|
883
906
|
if (!(path === undefined)) {
|
|
907
|
+
let preparedPath = preparePath(this, path)
|
|
884
908
|
this.on(tag, (val)=>{
|
|
885
909
|
if (pathMeta.notify){
|
|
886
910
|
this.app.notify(tag, val, id )
|
|
887
911
|
} else {
|
|
888
|
-
this.updatePath(
|
|
912
|
+
this.updatePath(preparedPath,val, id, source)
|
|
889
913
|
}
|
|
890
914
|
})
|
|
891
915
|
}
|
|
@@ -898,6 +922,9 @@ class BTSensor extends EventEmitter {
|
|
|
898
922
|
return (Date.now()-this?._lastContact??Date.now())/1000
|
|
899
923
|
}
|
|
900
924
|
|
|
925
|
+
prepareConfig(config){
|
|
926
|
+
config.params.sensorClass=this.constructor.name
|
|
927
|
+
}
|
|
901
928
|
|
|
902
929
|
}
|
|
903
930
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# Bluetooth Sensors for [Signal K](http://www.signalk.org)
|
|
2
|
+
|
|
2
3
|
## WHAT'S NEW
|
|
3
4
|
|
|
5
|
+
# Version 1.2.5-1
|
|
6
|
+
|
|
7
|
+
- Reverted change from 1.2.5 to path's source field
|
|
8
|
+
- Victron Sensor model ID and name improvements to constistency for VE Smart Networking enabled devices
|
|
9
|
+
- Improved initial startup responsiveness
|
|
10
|
+
|
|
11
|
+
# Version 1.2.5
|
|
12
|
+
|
|
13
|
+
- On initial startup, plugin saves default configuration. Fixing the "missing" configured devices after restart.
|
|
14
|
+
- Mopeka Tank Sensor configuration fix
|
|
15
|
+
- Added number of found devices in a domain in the configuration screen's domain tab
|
|
16
|
+
|
|
17
|
+
# Version 1.2.4-4
|
|
18
|
+
|
|
19
|
+
Junctek support (tested)
|
|
20
|
+
|
|
4
21
|
# Version 1.2.4-3
|
|
5
22
|
|
|
6
23
|
- Mercury Smartcraft fixes (working now!)
|
|
@@ -185,6 +202,11 @@ Poorly shielded USB 3.0 and HDMI (5ghz) can interfere with BT transmission (2.4g
|
|
|
185
202
|
- There's no way that I know of to remove a SK Path without restarting the server. So if any active paths are changed by the plugin, you'll still see them hanging around in the data browser growing stale until you restart the server.
|
|
186
203
|
- RPi 3/4/5/CM400s when running an Access Point on the on board Wifi can cause a problem connecting to devices through the onboard BT. The only known fix is to disable the onboard Bluetooth and use a USB BT adapter. Alternatively, you can use a USB WiFi adapter. NOTE: This only applies to _connected_ devices like Renogy devices, LiTime batteries etc.
|
|
187
204
|
|
|
205
|
+
### Problems saving the configuration after installing plugin for first time (fixed as of Version 1.2.5)
|
|
206
|
+
|
|
207
|
+
Device config after being saved will appear to be "missing" after restarting. The config is in fact saved in the plugin config directory. All you have to do is Submit the main configuration then enable and optionally disable Debug. This, believe it or not, ensures that the config is marked as enabled. You should see your data now and upon restart.
|
|
208
|
+
|
|
209
|
+
|
|
188
210
|
## CONFIGURATION
|
|
189
211
|
|
|
190
212
|
After installing and restarting Signalk you should see a "BT Sensors Plugin" option in the Signalk->Server->Plugin Config page.<br><br>
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
{
|
|
2
|
+
"configuration": {
|
|
3
|
+
"discoveryInterval": 10,
|
|
4
|
+
"peripherals": [
|
|
5
|
+
{
|
|
6
|
+
"active": true,
|
|
7
|
+
"discoveryTimeout": 30,
|
|
8
|
+
"params": {
|
|
9
|
+
"name": "ATC_9FF77E",
|
|
10
|
+
"zone": "inside.cabin",
|
|
11
|
+
"parser": "ATC-LE",
|
|
12
|
+
"sensorClass": "ATC"
|
|
13
|
+
},
|
|
14
|
+
"paths": {
|
|
15
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
16
|
+
"batteryStrength": "sensors.{macAndName}.battery.strength",
|
|
17
|
+
"voltage": "sensors.{macAndName}.battery.voltage",
|
|
18
|
+
"temp": "environment.{zone}.temperature",
|
|
19
|
+
"humidity": "environment.{zone}.humidity"
|
|
20
|
+
},
|
|
21
|
+
"mac_address": "A4:C1:38:9F:F7:7E"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"active": true,
|
|
25
|
+
"discoveryTimeout": 30,
|
|
26
|
+
"params": {
|
|
27
|
+
"name": "tps",
|
|
28
|
+
"zone": "inside.refrigerator",
|
|
29
|
+
"sensorClass": "Inkbird"
|
|
30
|
+
},
|
|
31
|
+
"paths": {
|
|
32
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
33
|
+
"temp": "environment.{zone}.temperature",
|
|
34
|
+
"battery": "sensors.{macAndName}.battery.strength"
|
|
35
|
+
},
|
|
36
|
+
"mac_address": "49:22:05:17:2B:AE"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"active": true,
|
|
40
|
+
"discoveryTimeout": 30,
|
|
41
|
+
"params": {
|
|
42
|
+
"name": "Ruuvi BC7E",
|
|
43
|
+
"zone": "inside.navdesk",
|
|
44
|
+
"sensorClass": "RuuviTag"
|
|
45
|
+
},
|
|
46
|
+
"paths": {
|
|
47
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
48
|
+
"temp": "environment.{zone}.temperature",
|
|
49
|
+
"humidity": "environment.{zone}.humidity",
|
|
50
|
+
"pressure": "environment.{zone}.pressure",
|
|
51
|
+
"accX": "sensors.{macAndName}.accX",
|
|
52
|
+
"accY": "sensors.{macAndName}.accY",
|
|
53
|
+
"accZ": "sensors.{macAndName}.accZ",
|
|
54
|
+
"battV": "sensors.{macAndName}.battery.voltage",
|
|
55
|
+
"mc": "sensors.{macAndName}.movementCounter",
|
|
56
|
+
"msc": "sensors.{macAndName}.measurementSequenceCounter"
|
|
57
|
+
},
|
|
58
|
+
"mac_address": "F9:B0:6E:63:BC:7E"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"active": true,
|
|
62
|
+
"discoveryTimeout": 30,
|
|
63
|
+
"params": {
|
|
64
|
+
"name": "SBMO-003Z-db1b",
|
|
65
|
+
"zone": "inside",
|
|
66
|
+
"sensorClass": "ShellySBMO003Z"
|
|
67
|
+
},
|
|
68
|
+
"paths": {
|
|
69
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
70
|
+
"motion": "environment.{zone}.motion",
|
|
71
|
+
"illuminance": "environment.{zone}.illuminance",
|
|
72
|
+
"battery": "sensors.{macAndName}.battery.strength",
|
|
73
|
+
"button": "sensors.{macAndName}.button"
|
|
74
|
+
},
|
|
75
|
+
"mac_address": "E8:E0:7E:97:DB:1B"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"active": true,
|
|
79
|
+
"discoveryTimeout": 30,
|
|
80
|
+
"params": {
|
|
81
|
+
"name": "LYWSD03MMC",
|
|
82
|
+
"zone": "inside.vberth",
|
|
83
|
+
"encryptionKey": "3985f4ebc032f276cc316f1f6ecea085",
|
|
84
|
+
"sensorClass": "XiaomiMiBeacon"
|
|
85
|
+
},
|
|
86
|
+
"paths": {
|
|
87
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
88
|
+
"temp": "environment.{zone}.temperature",
|
|
89
|
+
"humidity": "environment.{zone}.humidity",
|
|
90
|
+
"batteryStrength": "sensors.{macAndName}.battery.strength",
|
|
91
|
+
"voltage": "sensors.{macAndName}.battery.voltage"
|
|
92
|
+
},
|
|
93
|
+
"gattParams": {
|
|
94
|
+
"useGATT": false
|
|
95
|
+
},
|
|
96
|
+
"mac_address": "A4:C1:38:3E:7E:94"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"active": true,
|
|
100
|
+
"discoveryTimeout": 30,
|
|
101
|
+
"params": {
|
|
102
|
+
"name": "SmartShunt HQ2204C2GHD",
|
|
103
|
+
"batteryID": "house",
|
|
104
|
+
"encryptionKey": "8cce8529307cf9dd0c85611c4fef42d9",
|
|
105
|
+
"sensorClass": "VictronBatteryMonitor"
|
|
106
|
+
},
|
|
107
|
+
"paths": {
|
|
108
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
109
|
+
"current": "electrical.batteries.{batteryID}.current",
|
|
110
|
+
"power": "electrical.batteries.{batteryID}.power",
|
|
111
|
+
"voltage": "electrical.batteries.{batteryID}.voltage",
|
|
112
|
+
"alarm": "electrical.batteries.{batteryID}.alarm",
|
|
113
|
+
"consumed": "electrical.batteries.{batteryID}.capacity.ampHoursConsumed",
|
|
114
|
+
"soc": "electrical.batteries.{batteryID}.capacity.stateOfCharge",
|
|
115
|
+
"ttg": "electrical.batteries.{batteryID}.capacity.timeRemaining",
|
|
116
|
+
"starterVoltage": "electrical.batteries.secondary.voltage"
|
|
117
|
+
},
|
|
118
|
+
"gattParams": {
|
|
119
|
+
"useGATT": false
|
|
120
|
+
},
|
|
121
|
+
"mac_address": "D4:50:46:39:38:C5"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"active": true,
|
|
125
|
+
"discoveryTimeout": 90,
|
|
126
|
+
"params": {
|
|
127
|
+
"name": "aft propane tank",
|
|
128
|
+
"medium": "PROPANE",
|
|
129
|
+
"tankHeight": "325",
|
|
130
|
+
"id": "propane",
|
|
131
|
+
"sensorClass": "MopekaTankSensor"
|
|
132
|
+
},
|
|
133
|
+
"paths": {
|
|
134
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
135
|
+
"battVolt": "sensors.{macAndName}.battery.voltage",
|
|
136
|
+
"battStrength": "sensors.{macAndName}.battery.strength",
|
|
137
|
+
"temp": "tanks.{id}.temperature",
|
|
138
|
+
"tankLevel": "tanks.{id}.currentLevel",
|
|
139
|
+
"readingQuality": "sensors.{macAndName}.readingQuality",
|
|
140
|
+
"accX": "sensors.{macAndName}.accelerationXAxis",
|
|
141
|
+
"accY": "sensors.{macAndName}.accelerationYAxis"
|
|
142
|
+
},
|
|
143
|
+
"mac_address": "D4:40:59:BE:2A:8C"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"active": true,
|
|
147
|
+
"discoveryTimeout": 30,
|
|
148
|
+
"params": {
|
|
149
|
+
"name": "SBHT-003C",
|
|
150
|
+
"zone": "outside.deck",
|
|
151
|
+
"sensorClass": "ShellySBHT003C"
|
|
152
|
+
},
|
|
153
|
+
"paths": {
|
|
154
|
+
"RSSI": "sensors.{macAndName}.RSSI",
|
|
155
|
+
"battery": "sensors.{macAndName}.battery.strength",
|
|
156
|
+
"temp": "environment.{zone}.temperature",
|
|
157
|
+
"humidity": "environment.{zone}.humidity",
|
|
158
|
+
"button": "sensors.{macAndName}.button"
|
|
159
|
+
},
|
|
160
|
+
"mac_address": "7C:C6:B6:AF:49:5F"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"adapter": "hci0",
|
|
164
|
+
"transport": "le",
|
|
165
|
+
"duplicateData": false,
|
|
166
|
+
"discoveryTimeout": 30
|
|
167
|
+
},
|
|
168
|
+
"enabled": true,
|
|
169
|
+
"enableDebug": false
|
|
170
|
+
}
|