bt-sensors-plugin-sk 1.2.5 → 1.2.6-beta-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/.vscode/settings.json +2 -0
- package/BTSensor.js +77 -38
- package/DistanceManager.js +249 -0
- package/Mixin.js +19 -0
- package/OutOfRangeDevice.js +46 -0
- package/README.md +26 -6
- package/classLoader.js +13 -8
- package/connectUUID.exp +26 -0
- package/development/FakeBTDevice.js +57 -0
- package/development/package.json +5 -0
- package/diff.txt +2860 -0
- package/index.js +58 -12
- package/package.json +8 -6
- package/public/698.js +14 -0
- package/public/847.js +1 -1
- package/public/images/ATC.jpeg +0 -0
- package/public/images/Aranet4.webp +0 -0
- package/public/images/BP108B.webp +0 -0
- package/public/images/GoveeH5074.jpg +0 -0
- package/public/images/GoveeH5075.webp +0 -0
- package/public/images/GoveeH510x.jpg +0 -0
- package/public/images/InkbirdTH3.webp +0 -0
- package/public/images/JBDBMS.webp +0 -0
- package/public/images/Junctek.webp +0 -0
- package/public/images/KilovaultHLXPlus.jpg +0 -0
- package/public/images/LancolVoltageMeter.webp +0 -0
- package/public/images/LiTimeLiFePo4Battery.avif +0 -0
- package/public/images/MercurySmartcraft.jpg +0 -0
- package/public/images/MopekaTankSensor.jpg +0 -0
- package/public/images/RemoranWave3.jpeg +0 -0
- package/public/images/RenogyInverter.jpg +0 -0
- package/public/images/RenogyRoverClient.jpg +0 -0
- package/public/images/RenogySmartLiFePo4Battery.webp +0 -0
- package/public/images/RuuviTag.jpg +0 -0
- package/public/images/ShellyBLUHT.webp +0 -0
- package/public/images/ShellyBLUMotion.webp +0 -0
- package/public/images/ShellyBluDoorWindow.webp +0 -0
- package/public/images/Skanbatt.jpg +0 -0
- package/public/images/SmartBatteryProtect.webp +0 -0
- package/public/images/SmartBatterySense.webp +0 -0
- package/public/images/SwitchBotMeterPlus.webp +0 -0
- package/public/images/SwitchBotTH.webp +0 -0
- package/public/images/TopbandBattery.webp +0 -0
- package/public/images/Ultrasonic.jpg +0 -0
- package/public/images/VictronBlueSmartACCharger.jpg +0 -0
- package/public/images/VictronBlueSolarMPPT.jpeg +0 -0
- package/public/images/VictronCerboGX.webp +0 -0
- package/public/images/VictronInverterRS.webp +0 -0
- package/public/images/VictronLynxSmartBMS.webp +0 -0
- package/public/images/VictronMultiPlus-II.webp +0 -0
- package/public/images/VictronOrionTrIsolated.webp +0 -0
- package/public/images/VictronOrionTrNonIsolated.webp +0 -0
- package/public/images/VictronPhoenixInverter.webp +0 -0
- package/public/images/VictronPhoenixSmart1600.webp +0 -0
- package/public/images/VictronSmartBatteryProtect.jpg +0 -0
- package/public/images/VictronSmartIP43.webp +0 -0
- package/public/images/VictronSmartLithiumBattery.jpg +0 -0
- package/public/images/VictronSmartSolarMPPT.webp +0 -0
- package/public/images/VictronVEBus.webp +0 -0
- package/public/images/eco-worthy.webp +0 -0
- package/public/images/iBeacon.jpg +0 -0
- package/public/remoteEntry.js +1 -1
- package/readUUID.exp +23 -0
- package/sensor_classes/ATC.js +3 -2
- package/sensor_classes/Aranet2.js +3 -1
- package/sensor_classes/Aranet4.js +1 -2
- package/sensor_classes/BankManager.js +1 -1
- package/sensor_classes/Beacon/AbstractBeaconMixin.js +85 -0
- package/sensor_classes/Beacon/Eddystone.js +77 -0
- package/sensor_classes/Beacon/iBeacon.js +58 -0
- package/sensor_classes/EcoWorthy.js +160 -0
- package/sensor_classes/EctiveBMS.js +269 -0
- package/sensor_classes/FeasyComBeacon.js +68 -0
- package/sensor_classes/GobiusCTankMeter.js +4 -3
- package/sensor_classes/GoveeH5074.js +2 -0
- package/sensor_classes/GoveeH5075.js +2 -0
- package/sensor_classes/GoveeH510x.js +1 -0
- package/sensor_classes/Inkbird.js +1 -0
- package/sensor_classes/JBDBMS.js +1 -0
- package/sensor_classes/Junctek.js +14 -6
- package/sensor_classes/KilovaultHLXPlus.js +1 -0
- package/sensor_classes/LancolVoltageMeter.js +2 -0
- package/sensor_classes/MercurySmartcraft.js +1 -0
- package/sensor_classes/MopekaTankSensor.js +7 -204
- package/sensor_classes/RemoranWave3.js +2 -0
- package/sensor_classes/Renogy/RenogySensor.js +1 -0
- package/sensor_classes/RenogyBattery.js +3 -4
- package/sensor_classes/RenogyInverter.js +3 -6
- package/sensor_classes/RenogyRoverClient.js +3 -0
- package/sensor_classes/RuuviTag.js +11 -8
- package/sensor_classes/ShellySBDW002C.js +3 -1
- package/sensor_classes/ShellySBHT003C.js +7 -0
- package/sensor_classes/ShellySBMO003Z.js +3 -2
- package/sensor_classes/ShenzhenLiOnBMS.js +4 -0
- package/sensor_classes/SwitchBotMeterPlus.js +1 -1
- package/sensor_classes/SwitchBotTH.js +2 -1
- package/sensor_classes/UNKNOWN.js +2 -1
- package/sensor_classes/UltrasonicWindMeter.js +3 -0
- package/sensor_classes/Victron/VictronConstants.js +2 -0
- package/sensor_classes/Victron/VictronIdentifier.js +24 -0
- package/sensor_classes/Victron/VictronSensor.js +59 -49
- package/sensor_classes/VictronACCharger.js +1 -6
- package/sensor_classes/VictronBatteryMonitor.js +39 -28
- package/sensor_classes/VictronDCDCConverter.js +1 -4
- package/sensor_classes/VictronDCEnergyMeter.js +1 -4
- package/sensor_classes/VictronGXDevice.js +1 -4
- package/sensor_classes/VictronInverter.js +2 -3
- package/sensor_classes/VictronInverterRS.js +2 -4
- package/sensor_classes/VictronLynxSmartBMS.js +1 -4
- package/sensor_classes/VictronOrionXS.js +1 -3
- package/sensor_classes/VictronSmartBatteryProtect.js +1 -4
- package/sensor_classes/VictronSmartLithium.js +1 -4
- package/sensor_classes/VictronSolarCharger.js +1 -3
- package/sensor_classes/VictronVEBus.js +1 -4
- package/sensor_classes/XiaomiMiBeacon.js +5 -2
- package/sensor_classes/iBeaconSensor.js +40 -0
- package/src/components/PluginConfigurationPanel.js +179 -184
- package/test.txt +805 -0
- package/public/681.js +0 -14
- package/sensor_classes/IBeacon.js +0 -45
- /package/public/{681.js.LICENSE.txt → 698.js.LICENSE.txt} +0 -0
- /package/public/images/{Aranet2_HOME_F_900x900_90OVA5J.original.webp → Aranet2.webp} +0 -0
- /package/public/images/{Bank Manager All-in-onewc.webp → BankManager.webp} +0 -0
- /package/public/images/{Gobius_C.png → GobiusCTankMeter.png} +0 -0
- /package/public/images/{Victron-SmartShunt.jpg → VictronSmartShunt.jpg} +0 -0
- /package/public/images/{smartsolarMPPT7515.png → VictronSmartSolarMPPT7515.png} +0 -0
package/index.js
CHANGED
|
@@ -7,10 +7,10 @@ const {bluetooth, destroy} = createBluetooth()
|
|
|
7
7
|
|
|
8
8
|
const BTSensor = require('./BTSensor.js')
|
|
9
9
|
const BLACKLISTED = require('./sensor_classes/BlackListedDevice.js')
|
|
10
|
+
const OutOfRangeDevice = require("./OutOfRangeDevice.js")
|
|
10
11
|
const { createChannel, createSession } = require("better-sse");
|
|
11
12
|
const { clearTimeout } = require('timers')
|
|
12
13
|
const loadClassMap = require('./classLoader.js')
|
|
13
|
-
|
|
14
14
|
class MissingSensor {
|
|
15
15
|
|
|
16
16
|
constructor(config){
|
|
@@ -20,6 +20,7 @@ class MissingSensor {
|
|
|
20
20
|
this.addDefaultPath=BTSensor.prototype.addDefaultPath.bind(this)
|
|
21
21
|
this.addDefaultParam=BTSensor.prototype.addDefaultParam.bind(this)
|
|
22
22
|
this.getPath=BTSensor.prototype.getPath.bind(this)
|
|
23
|
+
this.getImageSrc=BTSensor.prototype.getImageSrc.bind(this)
|
|
23
24
|
|
|
24
25
|
this.getJSONSchema = BTSensor.prototype.getJSONSchema.bind(this)
|
|
25
26
|
this.initSchema = BTSensor.prototype.initSchema.bind(this)
|
|
@@ -131,10 +132,11 @@ module.exports = function (app) {
|
|
|
131
132
|
var adapter
|
|
132
133
|
const channel = createChannel()
|
|
133
134
|
|
|
134
|
-
const classMap = loadClassMap(app)
|
|
135
135
|
const sensorMap=new Map()
|
|
136
136
|
|
|
137
137
|
plugin.start = async function (options, restartPlugin) {
|
|
138
|
+
const classMap = loadClassMap(app)
|
|
139
|
+
|
|
138
140
|
plugin.started=true
|
|
139
141
|
var adapterID=options.adapter
|
|
140
142
|
var foundConfiguredDevices=0
|
|
@@ -155,9 +157,37 @@ module.exports = function (app) {
|
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
plugin.registerWithRouter = function(router) {
|
|
160
|
+
router.get('/getSensorInfo', async (req, res) => {
|
|
161
|
+
const _sensor = sensorMap.get(req.query?.mac_address)
|
|
162
|
+
const _class = classMap.get(req.query?.class)
|
|
163
|
+
let _tempSensor = null
|
|
164
|
+
if (_sensor &&_class && _sensor instanceof classMap.get("UNKNOWN")){
|
|
165
|
+
try {
|
|
166
|
+
|
|
167
|
+
_tempSensor = new _class ( _sensor.device )
|
|
168
|
+
_tempSensor.currentProperties=_sensor.currentProperties
|
|
169
|
+
_tempSensor.debug = app.debug
|
|
170
|
+
_tempSensor._adapter=adapter
|
|
171
|
+
await _tempSensor.init()
|
|
172
|
+
const _json = sensorToJSON(_tempSensor)
|
|
173
|
+
res.status(200).json(_json)
|
|
174
|
+
} catch (e){
|
|
175
|
+
res.status(400).send(`Invalid request: ${e.message}`)
|
|
176
|
+
}
|
|
177
|
+
finally{
|
|
178
|
+
if (_tempSensor)
|
|
179
|
+
_tempSensor.stopListening()
|
|
180
|
+
}
|
|
181
|
+
} else{
|
|
182
|
+
res.status(404).json({message: `Invalid request`})
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
})
|
|
158
186
|
|
|
159
187
|
router.post('/updateSensorData', async (req, res) => {
|
|
160
188
|
app.debug(req.body)
|
|
189
|
+
const sensor = sensorMap.get(req.body.mac_address)
|
|
190
|
+
sensor.prepareConfig(req.body)
|
|
161
191
|
const i = deviceConfigs.findIndex((p)=>p.mac_address==req.body.mac_address)
|
|
162
192
|
if (i<0){
|
|
163
193
|
if (!options.peripherals){
|
|
@@ -175,7 +205,6 @@ module.exports = function (app) {
|
|
|
175
205
|
options, async () => {
|
|
176
206
|
app.debug('Plugin options saved')
|
|
177
207
|
res.status(200).json({message: "Sensor updated"})
|
|
178
|
-
const sensor = sensorMap.get(req.body.mac_address)
|
|
179
208
|
if (sensor) {
|
|
180
209
|
removeSensorFromList(sensor)
|
|
181
210
|
if (sensor.isActive())
|
|
@@ -226,12 +255,6 @@ module.exports = function (app) {
|
|
|
226
255
|
}
|
|
227
256
|
)
|
|
228
257
|
});
|
|
229
|
-
router.get('/getDomains', (req, res) => {
|
|
230
|
-
|
|
231
|
-
res.status(200).json(
|
|
232
|
-
BTSensor.SensorDomains
|
|
233
|
-
);
|
|
234
|
-
})
|
|
235
258
|
|
|
236
259
|
router.get('/getBaseData', (req, res) => {
|
|
237
260
|
|
|
@@ -248,6 +271,8 @@ module.exports = function (app) {
|
|
|
248
271
|
}
|
|
249
272
|
);
|
|
250
273
|
})
|
|
274
|
+
|
|
275
|
+
|
|
251
276
|
router.get('/getSensors', (req, res) => {
|
|
252
277
|
app.debug("Sending sensors")
|
|
253
278
|
const t = sensorsToJSON()
|
|
@@ -293,6 +318,7 @@ module.exports = function (app) {
|
|
|
293
318
|
|
|
294
319
|
return { mac: sensor.getMacAddress(),
|
|
295
320
|
name: sensor.getName(),
|
|
321
|
+
class: sensor.constructor.name,
|
|
296
322
|
domain: sensor.getDomain().name,
|
|
297
323
|
RSSI: sensor.getRSSI(),
|
|
298
324
|
signalStrength: sensor.getSignalStrength(),
|
|
@@ -304,10 +330,12 @@ module.exports = function (app) {
|
|
|
304
330
|
const config = getDeviceConfig(sensor.getMacAddress())
|
|
305
331
|
const schema = sensor.getJSONSchema()
|
|
306
332
|
schema.htmlDescription = sensor.getDescription()
|
|
333
|
+
|
|
307
334
|
return {
|
|
308
335
|
info: getSensorInfo(sensor),
|
|
309
336
|
schema: schema,
|
|
310
|
-
config: config?config:{}
|
|
337
|
+
config: config?config:{},
|
|
338
|
+
configCopy: JSON.parse(JSON.stringify(config?config:{}))
|
|
311
339
|
}
|
|
312
340
|
}
|
|
313
341
|
|
|
@@ -388,9 +416,25 @@ module.exports = function (app) {
|
|
|
388
416
|
resolve(s)
|
|
389
417
|
}
|
|
390
418
|
})
|
|
391
|
-
.catch((e)=>{
|
|
419
|
+
.catch(async (e)=>{
|
|
392
420
|
if (s)
|
|
393
421
|
s.stopListening()
|
|
422
|
+
else{
|
|
423
|
+
const device = new OutOfRangeDevice(adapter, config)
|
|
424
|
+
const c = await getClassFor(device,config)
|
|
425
|
+
if (c.domain==BTSensor.SensorDomains.beacons || c.IsRoaming){
|
|
426
|
+
s = await instantiateSensor(device,config)
|
|
427
|
+
device.once("deviceFound",async (device)=>{
|
|
428
|
+
s.device=device
|
|
429
|
+
s.listen()
|
|
430
|
+
s.activate(config, plugin)
|
|
431
|
+
removeSensorFromList(s)
|
|
432
|
+
addSensorToList(s)
|
|
433
|
+
})
|
|
434
|
+
addSensorToList(s)
|
|
435
|
+
resolve(s)
|
|
436
|
+
}
|
|
437
|
+
}
|
|
394
438
|
if (startNumber == starts ) {
|
|
395
439
|
app.debug(`Unable to communicate with device ${deviceNameAndAddress(config)} Reason: ${e?.message??e}`)
|
|
396
440
|
app.debug(e)
|
|
@@ -428,9 +472,11 @@ module.exports = function (app) {
|
|
|
428
472
|
c.debug=app.debug
|
|
429
473
|
|
|
430
474
|
const sensor = new c(device, config?.params, config?.gattParams)
|
|
475
|
+
sensor._paths=config.paths //this might be a good candidate for refactoring
|
|
431
476
|
sensor.debug=app.debug
|
|
432
477
|
sensor.setPluginError=app.setPluginError
|
|
433
478
|
sensor.app=app
|
|
479
|
+
if (!adapter) debugger
|
|
434
480
|
sensor._adapter=adapter //HACK!
|
|
435
481
|
await sensor.init()
|
|
436
482
|
return sensor
|
|
@@ -455,7 +501,7 @@ module.exports = function (app) {
|
|
|
455
501
|
if (startNumber != starts ) {
|
|
456
502
|
return
|
|
457
503
|
}
|
|
458
|
-
if (deviceConfig.active) {
|
|
504
|
+
if (deviceConfig.active && !(sensor.device instanceof OutOfRangeDevice) ) {
|
|
459
505
|
app.setPluginStatus(`Listening to ${++foundConfiguredDevices} sensors.`);
|
|
460
506
|
sensor.activate(deviceConfig, plugin)
|
|
461
507
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bt-sensors-plugin-sk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6-beta-1",
|
|
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": {
|
|
7
|
-
"@rjsf/bootstrap-4": "^5.24.
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@rjsf/bootstrap-4": "^5.24.12",
|
|
8
8
|
"@rjsf/core": "^5.24.11",
|
|
9
9
|
"@rjsf/utils": "^5.24.11",
|
|
10
10
|
"@rjsf/validator-ajv8": "^5.24.11",
|
|
11
11
|
"better-sse": "^0.14.1",
|
|
12
|
+
"buffer": "^6.0.3",
|
|
12
13
|
"dbus-next": "^0.10.2",
|
|
13
14
|
"int24": "^0.0.1",
|
|
14
|
-
"kaitai-struct": "^0.10.0",
|
|
15
|
+
"kaitai-struct": "^0.10.0",
|
|
15
16
|
"node-ble": "^1.13.0",
|
|
16
|
-
"semver": "^7.7.1"
|
|
17
|
+
"semver": "^7.7.1",
|
|
18
|
+
"lru-cache": "^11.1.0"
|
|
17
19
|
},
|
|
18
20
|
"devDependencies": {
|
|
19
21
|
"@babel/core": "^7.11.6",
|
|
@@ -33,9 +35,9 @@
|
|
|
33
35
|
"mocha": "^8.0.1",
|
|
34
36
|
"prettier-standard": "^6.0.0",
|
|
35
37
|
"react": "^16.13.1",
|
|
36
|
-
"react-html-parser":"^2.0.2",
|
|
37
38
|
"react-bootstrap": "^1.6.5",
|
|
38
39
|
"react-dom": "^16.13.1",
|
|
40
|
+
"react-html-parser": "^2.0.2",
|
|
39
41
|
"react-markdown": "^4.3.1",
|
|
40
42
|
"react-redux": "^5.1.2",
|
|
41
43
|
"react-select": "^3.1.0",
|