bt-sensors-plugin-sk 1.2.5-1 → 1.2.6-beta
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 +74 -38
- package/DistanceManager.js +249 -0
- package/Mixin.js +19 -0
- package/OutOfRangeDevice.js +46 -0
- package/README.md +14 -0
- package/classLoader.js +7 -2
- package/connectUUID.exp +26 -0
- package/index.js +49 -3
- package/package.json +8 -6
- package/public/159.js +1 -1
- package/public/540.js +1 -1
- package/public/681.js +3 -9
- package/public/681.js.LICENSE.txt +2 -0
- package/public/764.js +1 -0
- 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/iBeacon.jpg +0 -0
- package/public/main.js +1 -1
- 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/EctiveBMS.js +270 -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 +3 -200
- 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 +6 -3
- 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 +43 -54
- package/sensor_classes/VictronACCharger.js +1 -6
- package/sensor_classes/VictronBatteryMonitor.js +37 -26
- 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 +53 -17
- package/Screenshot 2025-06-12 at 9.33.57/342/200/257AM.png +0 -0
- package/bt-sensors-plugin-sk copy.json +0 -170
- package/bt-sensors-plugin-sk.json.bak +0 -121
- package/diff.txt +0 -2860
- package/public/847.js +0 -1
- package/sensor_classes/IBeacon.js +0 -45
- package/vsl_patch_17_06_25.patch +0 -13
- /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
|
@@ -7,18 +7,18 @@ const VC=require("./Victron/VictronConstants.js")
|
|
|
7
7
|
const int24 = require('int24')
|
|
8
8
|
class VictronBatteryMonitor extends VictronSensor{
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
static _test(data, key){
|
|
11
|
+
var b
|
|
12
|
+
if (data instanceof String)
|
|
13
|
+
b = Buffer.from(data.replaceAll(" ",""),"hex")
|
|
14
|
+
else
|
|
15
|
+
b = data
|
|
16
16
|
const d = new this()
|
|
17
17
|
|
|
18
18
|
if (key) {
|
|
19
|
-
d.encryptionKey = key
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
d.encryptionKey = key
|
|
20
|
+
} else
|
|
21
|
+
d.auxMode=b.readInt8(8)&0x3
|
|
22
22
|
d.currentProperties = {}
|
|
23
23
|
d.currentProperties.ManufacturerData={}
|
|
24
24
|
d.currentProperties.ManufacturerData[0x02e1]=b
|
|
@@ -28,18 +28,21 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
28
28
|
Object.keys(d.getPaths()).forEach((tag)=>{
|
|
29
29
|
d.on(tag,(v)=>console.log(`${tag}=${v}`))
|
|
30
30
|
})
|
|
31
|
-
|
|
31
|
+
if (key)
|
|
32
|
+
b = d.decrypt(b)
|
|
33
|
+
else
|
|
34
|
+
|
|
32
35
|
console.log(b)
|
|
33
36
|
d.emitValuesFrom(b)
|
|
34
37
|
d.removeAllListeners()
|
|
35
38
|
|
|
36
39
|
}
|
|
40
|
+
static ImageFile = "VictronSmartShunt.jpg"
|
|
37
41
|
|
|
38
42
|
characteristics=[]
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
super.initSchema()
|
|
44
|
+
async initSchema(){
|
|
45
|
+
await super.initSchema()
|
|
43
46
|
this.addDefaultParam("batteryID").default="house"
|
|
44
47
|
//"default": "electrical.batteries.{batteryID}.voltage"
|
|
45
48
|
|
|
@@ -73,26 +76,31 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
73
76
|
|
|
74
77
|
this.addDefaultPath( 'ttg',"electrical.batteries.capacity.timeRemaining")
|
|
75
78
|
.read=(buff,offset=0)=>{return this.NaNif(buff.readUInt16LE(offset),0xFFFF)*60}
|
|
76
|
-
this.getPath("ttg").gatt='65970ffe-4bda-4c1e-af4b-551c4cf74769'
|
|
79
|
+
this.getPath("ttg").gatt='65970ffe-4bda-4c1e-af4b-551c4cf74769';
|
|
80
|
+
|
|
77
81
|
this.auxMode=VC.AuxMode.STARTER_VOLTAGE
|
|
78
|
-
try {
|
|
79
|
-
if (this.encryptionKey){
|
|
80
|
-
const decData = this.decrypt(this.getManufacturerData(0x02e1))
|
|
81
|
-
if (decData)
|
|
82
|
-
this.auxMode=decData.readInt8(8)&0x3
|
|
83
|
-
}
|
|
84
|
-
} catch(e){
|
|
85
|
-
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
86
|
-
this.debug(e)
|
|
87
|
-
this.auxMode=VC.AuxMode.DISABLED
|
|
88
|
-
}
|
|
89
82
|
|
|
83
|
+
if (!this.auxMode){
|
|
84
|
+
const md=await this.constructor.getDataPacket(this.device, this.getManufacturerData(this.constructor.ManufacturerID))
|
|
85
|
+
try {
|
|
86
|
+
if (this.encryptionKey){
|
|
87
|
+
const decData = this.decrypt(md)
|
|
88
|
+
if (decData)
|
|
89
|
+
this.auxMode=decData.readInt8(8)&0x3
|
|
90
|
+
}
|
|
91
|
+
} catch(e){
|
|
92
|
+
this.debug(`Unable to determine device AuxMode. ${e.message}`)
|
|
93
|
+
this.debug(e)
|
|
94
|
+
this.auxMode=VC.AuxMode.DISABLED
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
switch(this.auxMode){
|
|
91
99
|
case VC.AuxMode.STARTER_VOLTAGE:
|
|
92
100
|
this.addMetadatum('starterVoltage','V', 'starter battery voltage',
|
|
93
101
|
(buff,offset=0)=>{return buff.readInt16LE(offset)/100},
|
|
94
102
|
'6597ed7d-4bda-4c1e-af4b-551c4cf74769')
|
|
95
|
-
.default="electrical.batteries.
|
|
103
|
+
.default="electrical.batteries.starter.voltage"
|
|
96
104
|
break;
|
|
97
105
|
case VC.AuxMode.MIDPOINT_VOLTAGE:
|
|
98
106
|
this.addMetadatum('midpointVoltage','V', 'midpoint battery voltage',
|
|
@@ -110,9 +118,11 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
110
118
|
default:
|
|
111
119
|
break
|
|
112
120
|
}
|
|
121
|
+
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
emitValuesFrom(decData){
|
|
125
|
+
|
|
116
126
|
this.emitData("ttg",decData,0)
|
|
117
127
|
this.emitData("voltage",decData,2);
|
|
118
128
|
const alarm = this.getPath("alarm").read(decData,4)
|
|
@@ -211,5 +221,6 @@ class VictronBatteryMonitor extends VictronSensor{
|
|
|
211
221
|
this.debug(`Disconnected from ${ this.getName()}`)
|
|
212
222
|
}
|
|
213
223
|
}
|
|
224
|
+
|
|
214
225
|
}
|
|
215
226
|
module.exports=VictronBatteryMonitor
|
|
@@ -3,10 +3,7 @@ const VC=require("./Victron/VictronConstants.js")
|
|
|
3
3
|
|
|
4
4
|
class VictronDCDCConverter extends VictronSensor{
|
|
5
5
|
|
|
6
|
-
static
|
|
7
|
-
return await this.identifyMode(device,0x04)
|
|
8
|
-
}
|
|
9
|
-
|
|
6
|
+
static ImageFile="VictronOrionTrIsolated.webp"
|
|
10
7
|
|
|
11
8
|
initSchema(){
|
|
12
9
|
super.initSchema()
|
|
@@ -5,10 +5,7 @@ const int24 = require("int24");
|
|
|
5
5
|
const _BitReader = require("./_BitReader.js");
|
|
6
6
|
class VictronDCEnergyMeter extends VictronSensor{
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
return await this.identifyMode(device, 0x0D)
|
|
10
|
-
}
|
|
11
|
-
async init(){
|
|
8
|
+
async init(){
|
|
12
9
|
await super.init()
|
|
13
10
|
try {
|
|
14
11
|
if (this.encryptionKey){
|
|
@@ -22,10 +22,7 @@ Alarms
|
|
|
22
22
|
TBD
|
|
23
23
|
117 43 Unuse
|
|
24
24
|
*/
|
|
25
|
-
static
|
|
26
|
-
return await this.identifyMode(device, 0x07)
|
|
27
|
-
}
|
|
28
|
-
|
|
25
|
+
static ImageFile = "VictronCerboGX.webp"
|
|
29
26
|
initSchema(){
|
|
30
27
|
super.initSchema()
|
|
31
28
|
this.addMetadatum('voltage','V', 'channel #1 voltage',
|
|
@@ -3,9 +3,8 @@ const VC=require("./Victron/VictronConstants.js")
|
|
|
3
3
|
const BitReader = require('./_BitReader')
|
|
4
4
|
|
|
5
5
|
class VictronInverter extends VictronSensor{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
|
|
7
|
+
static ImageFile="VictronPhoenixSmart1600.webp"
|
|
9
8
|
|
|
10
9
|
initSchema(){
|
|
11
10
|
super.initSchema()
|
|
@@ -5,10 +5,8 @@ function toBinaryString(buff){
|
|
|
5
5
|
return [...buff].map((b) => b.toString(2).padStart(8, "0")).join("");
|
|
6
6
|
}
|
|
7
7
|
class VictronInverterRS extends VictronSensor{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
static ImageFile = "VictronInverterRS.webp"
|
|
12
10
|
|
|
13
11
|
initSchema() {
|
|
14
12
|
super.initSchema()
|
|
@@ -18,10 +18,7 @@ const VC = require("./Victron/VictronConstants.js")
|
|
|
18
18
|
const BitReader = require("./_BitReader")
|
|
19
19
|
class VictronLynxSmartBMS extends VictronSensor{
|
|
20
20
|
|
|
21
|
-
static
|
|
22
|
-
return await this.identifyMode(device, 0x0A)
|
|
23
|
-
}
|
|
24
|
-
|
|
21
|
+
static ImageFile="VictronLynxSmartBMS"
|
|
25
22
|
initSchema(){
|
|
26
23
|
super.initSchema()
|
|
27
24
|
this.addDefaultParam("batteryID")
|
|
@@ -5,9 +5,7 @@ const VictronSensor = require ("./Victron/VictronSensor.js")
|
|
|
5
5
|
const VC = require("./Victron/VictronConstants.js")
|
|
6
6
|
class VictronOrionXS extends VictronSensor{
|
|
7
7
|
|
|
8
|
-
static
|
|
9
|
-
return await this.identifyMode(device, 0x0F)
|
|
10
|
-
}
|
|
8
|
+
static ImageFile="VictronOrionTrIsolated.webp"
|
|
11
9
|
initSchema() {
|
|
12
10
|
super.initSchema()
|
|
13
11
|
this.addDefaultParam("id")
|
|
@@ -19,10 +19,7 @@ const VictronSensor = require ("./Victron/VictronSensor.js")
|
|
|
19
19
|
const VC = require("./Victron/VictronConstants.js")
|
|
20
20
|
class VictronSmartBatteryProtect extends VictronSensor{
|
|
21
21
|
|
|
22
|
-
static
|
|
23
|
-
return await this.identifyMode(device, 0x09)
|
|
24
|
-
}
|
|
25
|
-
|
|
22
|
+
static ImageFile="VictronSmartBatteryProte.jpg"
|
|
26
23
|
|
|
27
24
|
initSchema(){
|
|
28
25
|
super.initSchema()
|
|
@@ -34,10 +34,7 @@ function _toCellVoltage(val){
|
|
|
34
34
|
}
|
|
35
35
|
class VictronSmartLithium extends VictronSensor{
|
|
36
36
|
|
|
37
|
-
static
|
|
38
|
-
return await this.identifyMode(device, 0x05)
|
|
39
|
-
}
|
|
40
|
-
|
|
37
|
+
static ImageFile="VictronSmartLithiumBattery.jpg"
|
|
41
38
|
initSchema(){
|
|
42
39
|
super.initSchema()
|
|
43
40
|
this.addDefaultParam("batteryID")
|
|
@@ -2,9 +2,7 @@ const VictronSensor = require ("./Victron/VictronSensor.js")
|
|
|
2
2
|
const VC = require("./Victron/VictronConstants.js")
|
|
3
3
|
class VictronSolarCharger extends VictronSensor{
|
|
4
4
|
|
|
5
|
-
static
|
|
6
|
-
return await this.identifyMode(device, 0x01)
|
|
7
|
-
}
|
|
5
|
+
static ImageFile="VictronSmartSolarMPPT.webp"
|
|
8
6
|
|
|
9
7
|
initSchema() {
|
|
10
8
|
super.initSchema()
|
|
@@ -5,10 +5,7 @@ AC_IN_STATE=["AC in 1","AC in 2","NOT CONNECTED", "NA"]
|
|
|
5
5
|
ALARM_STATE=["None","warning", "alarm","NA"]
|
|
6
6
|
class VictronVEBus extends VictronSensor{
|
|
7
7
|
|
|
8
|
-
static
|
|
9
|
-
return await this.identifyMode(device, 0x0C)
|
|
10
|
-
}
|
|
11
|
-
|
|
8
|
+
static ImageFile="VictronVEBus.webp"
|
|
12
9
|
initSchema(){
|
|
13
10
|
super.initSchema()
|
|
14
11
|
this.addMetadatum('chargeState','', 'charge state',
|
|
@@ -72,7 +72,7 @@ const DEVICE_TYPES = new Map([
|
|
|
72
72
|
|
|
73
73
|
class XiaomiMiBeacon extends BTSensor{
|
|
74
74
|
static Domain = BTSensor.SensorDomains.environmental
|
|
75
|
-
|
|
75
|
+
static ImageFile = "LYWSD03MMC-Device.jpg"
|
|
76
76
|
constructor(device, config, gattConfig){
|
|
77
77
|
super(device, config, gattConfig)
|
|
78
78
|
this.encryptionKey = config?.encryptionKey
|
|
@@ -91,7 +91,8 @@ class XiaomiMiBeacon extends BTSensor{
|
|
|
91
91
|
return null
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
static ImageFile="LYWSD03MMC-Device.jpg"
|
|
95
|
+
|
|
95
96
|
emitValues(buffer){
|
|
96
97
|
this.emitData("temp", buffer, 0)
|
|
97
98
|
this.emit("humidity", buffer.readUInt8(2)/100)
|
|
@@ -206,6 +207,8 @@ class XiaomiMiBeacon extends BTSensor{
|
|
|
206
207
|
|
|
207
208
|
await super.init()
|
|
208
209
|
const data = this.getServiceData(this.constructor.SERVICE_MIBEACON)
|
|
210
|
+
if (!data || data.length<4)
|
|
211
|
+
throw new Error(`Service Data ${this.constructor.SERVICE_MIBEACON} not available for ${this.getName()}`)
|
|
209
212
|
const frameControl = data[0] + (data[1] << 8)
|
|
210
213
|
this.deviceID = data[2] + (data[3] << 8)
|
|
211
214
|
this.isEncrypted = (frameControl >> 3) & 1
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
const BTSensor = require("../BTSensor");
|
|
3
|
+
const iBeacon = require("./Beacon/iBeacon")
|
|
4
|
+
|
|
5
|
+
class iBeaconSensor extends BTSensor {
|
|
6
|
+
|
|
7
|
+
static async identify (device){
|
|
8
|
+
return null
|
|
9
|
+
}
|
|
10
|
+
static IsRoaming = true;
|
|
11
|
+
static Domain = BTSensor.SensorDomains.beacons
|
|
12
|
+
static ImageFile = "iBeacon.jpg"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
beacon=new iBeacon(this)
|
|
16
|
+
|
|
17
|
+
initSchema(){
|
|
18
|
+
super.initSchema()
|
|
19
|
+
this.beacon.initSchema()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
initListen(){
|
|
23
|
+
super.initListen()
|
|
24
|
+
this.beacon.initListen()
|
|
25
|
+
}
|
|
26
|
+
elapsedTimeSinceLastContact(){
|
|
27
|
+
return this.beacon.elapsedTimeSinceLastContact(super.elapsedTimeSinceLastContact())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
propertiesChanged(props){
|
|
31
|
+
super.propertiesChanged(props);
|
|
32
|
+
this.beacon.propertiesChanged(props)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getTextDescription(){
|
|
36
|
+
return `${this.getName()} iBeacon device`
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = iBeaconSensor;
|
|
@@ -23,7 +23,10 @@ export function BTConfig (props) {
|
|
|
23
23
|
|
|
24
24
|
const _uiSchema= {
|
|
25
25
|
"ui:options": {label: false},
|
|
26
|
-
|
|
26
|
+
"paths":{
|
|
27
|
+
enableMarkdownInDescription:true
|
|
28
|
+
},
|
|
29
|
+
'title': { 'ui:widget': 'hidden' },
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
const baseUISchema =
|
|
@@ -94,23 +97,25 @@ const useStyles = makeStyles((theme) => ({
|
|
|
94
97
|
headers:headers
|
|
95
98
|
})
|
|
96
99
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
async function fetchJSONData(path, data = {}) {
|
|
101
|
+
let result;
|
|
102
|
+
try {
|
|
103
|
+
// Convert data object to query string
|
|
104
|
+
const query = Object.keys(data).length
|
|
105
|
+
? '?' + new URLSearchParams(data).toString()
|
|
106
|
+
: '';
|
|
107
|
+
result = await fetch(`/plugins/bt-sensors-plugin-sk/${path}${query}`, {
|
|
108
|
+
credentials: 'include',
|
|
109
|
+
method: 'GET'
|
|
110
|
+
});
|
|
111
|
+
} catch (e) {
|
|
112
|
+
result = {
|
|
113
|
+
status: 500,
|
|
114
|
+
statusText: e.toString()
|
|
115
|
+
};
|
|
112
116
|
}
|
|
113
|
-
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
114
119
|
async function getSensors(){
|
|
115
120
|
const response = await fetchJSONData("getSensors")
|
|
116
121
|
if (response.status!=200){
|
|
@@ -122,6 +127,16 @@ const useStyles = makeStyles((theme) => ({
|
|
|
122
127
|
|
|
123
128
|
}
|
|
124
129
|
|
|
130
|
+
|
|
131
|
+
async function getSensorInfo(mac, sensorClass){
|
|
132
|
+
const response = await fetchJSONData("getSensorInfo",{mac_address: mac, class: sensorClass})
|
|
133
|
+
if (response.status!=200){
|
|
134
|
+
throw new Error(`Unable get sensor info: ${response.statusText} (${response.status}) `)
|
|
135
|
+
}
|
|
136
|
+
const json = await response.json()
|
|
137
|
+
return json
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
async function getBaseData(){
|
|
126
141
|
const response = await fetchJSONData("getBaseData")
|
|
127
142
|
if (response.status!=200){
|
|
@@ -262,6 +277,27 @@ const useStyles = makeStyles((theme) => ({
|
|
|
262
277
|
|
|
263
278
|
},[])
|
|
264
279
|
|
|
280
|
+
|
|
281
|
+
useEffect(()=>{
|
|
282
|
+
|
|
283
|
+
if (!(sensorData && sensorMap) ) return
|
|
284
|
+
|
|
285
|
+
const _sensor = sensorMap.get(sensorData.mac_address)
|
|
286
|
+
if (_sensor && schema && sensorData &&
|
|
287
|
+
Object.hasOwn(sensorData,"params" )){
|
|
288
|
+
|
|
289
|
+
if (_sensor.info.class == "UNKNOWN" && sensorData.params.sensorClass && sensorData.params.sensorClass != "UNKNOWN") {
|
|
290
|
+
getSensorInfo(sensorData.mac_address, sensorData.params.sensorClass).then((json)=>{
|
|
291
|
+
debugger
|
|
292
|
+
setSchema(json.schema)
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
},[sensorData])
|
|
299
|
+
|
|
300
|
+
|
|
265
301
|
useEffect(()=>{
|
|
266
302
|
if (pluginState=="started") {
|
|
267
303
|
getBaseData().then((json) => {
|
|
Binary file
|
|
@@ -1,170 +0,0 @@
|
|
|
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
|
-
}
|