bt-sensors-plugin-sk 1.1.1 → 1.2.0-beta.0.0.10
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 +304 -108
- package/Queue.js +48 -0
- package/README.md +36 -22
- package/classLoader.js +38 -0
- package/definitions.json +941 -0
- package/index.js +425 -375
- package/package.json +52 -6
- package/plugin_defaults.json +146 -0
- package/public/893.js +1 -1
- package/public/main.js +1 -100
- package/public/remoteEntry.js +1 -129
- package/sensor_classes/ATC.js +34 -22
- package/sensor_classes/Aranet/AranetSensor.js +4 -0
- package/sensor_classes/Aranet2.js +16 -15
- package/sensor_classes/Aranet4.js +23 -17
- package/sensor_classes/BlackListedDevice.js +4 -0
- package/sensor_classes/DEVELOPMENT.md +1 -6
- package/sensor_classes/GoveeH50xx.js +12 -12
- package/sensor_classes/GoveeH510x.js +7 -8
- package/sensor_classes/IBeacon.js +6 -10
- package/sensor_classes/Inkbird.js +8 -6
- package/sensor_classes/JBDBMS.js +33 -25
- package/sensor_classes/KilovaultHLXPlus.js +33 -16
- package/sensor_classes/LancolVoltageMeter.js +4 -3
- package/sensor_classes/MopekaTankSensor.js +31 -15
- package/sensor_classes/Renogy/RenogySensor.js +15 -6
- package/sensor_classes/RenogyBattery.js +15 -13
- package/sensor_classes/RenogyRoverClient.js +2 -3
- package/sensor_classes/RuuviTag.js +36 -27
- package/sensor_classes/ShellySBHT003C.js +19 -22
- package/sensor_classes/SwitchBotMeterPlus.js +10 -12
- package/sensor_classes/SwitchBotTH.js +13 -16
- package/sensor_classes/UNKNOWN.js +8 -4
- package/sensor_classes/UltrasonicWindMeter.js +13 -5
- package/sensor_classes/Victron/VictronSensor.js +6 -2
- package/sensor_classes/VictronACCharger.js +19 -8
- package/sensor_classes/VictronBatteryMonitor.js +49 -37
- package/sensor_classes/VictronDCDCConverter.js +14 -5
- package/sensor_classes/VictronDCEnergyMeter.js +27 -15
- package/sensor_classes/VictronGXDevice.js +2 -5
- package/sensor_classes/VictronInverter.js +19 -15
- package/sensor_classes/VictronInverterRS.js +19 -8
- package/sensor_classes/VictronLynxSmartBMS.js +15 -13
- package/sensor_classes/VictronOrionXS.js +16 -3
- package/sensor_classes/VictronSmartBatteryProtect.js +5 -6
- package/sensor_classes/VictronSmartLithium.js +18 -18
- package/sensor_classes/VictronSolarCharger.js +31 -18
- package/sensor_classes/VictronVEBus.js +2 -5
- package/sensor_classes/XiaomiMiBeacon.js +31 -21
- package/spec/electrical.json +688 -0
- package/spec/environment.json +401 -0
- package/spec/sensors.json +39 -0
- package/spec/tanks.json +115 -0
- package/src/components/PluginConfigurationPanel.js +393 -0
- package/src/index.js +0 -0
- package/webpack.config.js +71 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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.relativeHumidity')
|
|
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)
|
|
@@ -15,6 +15,10 @@ class BLACKLISTED extends BTSensor {
|
|
|
15
15
|
await super.init();
|
|
16
16
|
this.currentProperties.Name = `Unsupported device from ${this.getManufacturer()}`;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
initListen(){
|
|
20
|
+
//do nothing
|
|
21
|
+
}
|
|
18
22
|
reasonForBlacklisting() {
|
|
19
23
|
switch (this.getManufacturerID()) {
|
|
20
24
|
case 0x004c:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# BLUETOOTH SENSOR CLASS DEVELOPMENT (OUT OF DATE AS OF 1.1.0 release
|
|
1
|
+
# BLUETOOTH SENSOR CLASS DEVELOPMENT (OUT OF DATE AS OF 1.1.0 Beta release NEW VERSION COMING SOON)
|
|
2
2
|
|
|
3
3
|
The goal of this project is to support as many mariner-useful sensors as possible. If there's anything we can do to make sensor class development easier, please let us know.<br><br>
|
|
4
4
|
|
|
@@ -146,11 +146,6 @@ module.exports=ATC</pre>
|
|
|
146
146
|
|
|
147
147
|
The big difference here is in the connect() method. All it does is wait on propertiesChanged and when that event occurs, the device object parses the buffer and emits the data. NOTE: Both classes have the same metadata, so the ATC class "borrows" the metadata from the LYWSD03MMC class.<br>
|
|
148
148
|
|
|
149
|
-
## DEVICE MODULES
|
|
150
|
-
|
|
151
|
-
To learn more about runtime loading of device modules, see (https://github.com/naugehyde/bt-sensors-plugin-sk/discussions/26)
|
|
152
|
-
|
|
153
|
-
|
|
154
149
|
## LET US KNOW
|
|
155
150
|
|
|
156
151
|
When you're done working on your class and satisified that it's functioning properly, commit and request a merge (more git talk).<br>
|
|
@@ -17,18 +17,18 @@ class GoveeH50xx extends BTSensor {
|
|
|
17
17
|
t
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
initSchema(){
|
|
21
|
+
super.initSchema()
|
|
22
|
+
this.addDefaultParam("zone")
|
|
23
|
+
|
|
24
|
+
this.addDefaultPath("temp","environment.temperature")
|
|
25
|
+
.read= (buffer)=>{return 273.15+(buffer.readUInt16LE(1)/100) }
|
|
26
|
+
|
|
27
|
+
this.addDefaultPath("humidity", "environment.humidity")
|
|
28
|
+
.read = (buffer)=>{return buffer.readUInt16LE(3)/10000}
|
|
29
|
+
|
|
30
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
31
|
+
.read = (buffer)=>{return buffer.readUInt8(5)/100}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
getManufacturer(){
|
|
@@ -34,14 +34,13 @@ class GoveeH510x extends BTSensor{
|
|
|
34
34
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.addMetadatum('humidity','ratio', 'humidity')
|
|
37
|
+
initSchema(){
|
|
38
|
+
super.initSchema()
|
|
39
|
+
this.addDefaultParam("zone")
|
|
40
|
+
|
|
41
|
+
this.addDefaultPath("temp","environment.temperature")
|
|
42
|
+
this.addDefaultPath("humidity", "environment.humidity")
|
|
43
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
emitValuesFrom(buffer){
|
|
@@ -20,21 +20,17 @@ class IBeacon extends BTSensor {
|
|
|
20
20
|
return null
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
initMetadata(){
|
|
29
|
-
this.addMetadatum('battery','ratio', 'Battery charge state', (buffer)=>{return buffer[6]})
|
|
23
|
+
initSchema(){
|
|
24
|
+
super.initSchema()
|
|
25
|
+
this.addDefaultPath("battery","sensors.batteryStrength")
|
|
26
|
+
.read=(buffer)=>{return buffer[6]}
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
propertiesChanged(props){
|
|
33
30
|
super.propertiesChanged(props);
|
|
34
31
|
const buff = this.getServiceData("0000356e-0000-1000-8000-00805f9b34fb");
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
this.emitData("battery", buff);
|
|
32
|
+
if (buff)
|
|
33
|
+
this.emitData("battery", buff);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
getManufacturer(){
|
|
@@ -13,12 +13,14 @@ class Inkbird extends BTSensor{
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
16
|
+
initSchema() {
|
|
17
|
+
super.initSchema()
|
|
18
|
+
this.addDefaultParam("zone")
|
|
19
|
+
|
|
20
|
+
this.addDefaultPath('temp','environment.temperature')
|
|
21
|
+
this.addDefaultPath('battery', 'sensors.batteryStrength')
|
|
20
22
|
if (this.getName() == 'sps'){
|
|
21
|
-
this.
|
|
23
|
+
this.addDefaultPath('humidity','environment.humidity')
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -37,7 +39,7 @@ class Inkbird extends BTSensor{
|
|
|
37
39
|
throw new Error("Unable to get manufacturer data for "+this.getDisplayName())
|
|
38
40
|
this.emit("temp", parseFloat((273.15+(key_i & 0x8000 ? key_i - 0x10000 : key_i)/100).toFixed(2))) ;
|
|
39
41
|
this.emit('battery', data[5]/100)
|
|
40
|
-
if (this.
|
|
42
|
+
if (this.getPath('humidity')) {
|
|
41
43
|
this.emit("humidity", data.readUInt16LE(0)/100);
|
|
42
44
|
}
|
|
43
45
|
}
|
package/sensor_classes/JBDBMS.js
CHANGED
|
@@ -28,28 +28,37 @@ class JBDBMS extends BTSensor {
|
|
|
28
28
|
return await this.txChar.writeValueWithResponse(Buffer.from(this.jbdCommand(command)))
|
|
29
29
|
|
|
30
30
|
}
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
(buffer)=>{return buffer.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
(buffer)=>{return buffer.readUInt16BE(
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
await this.
|
|
61
|
+
await this.deviceConnect()
|
|
53
62
|
await this.initCharacteristics()
|
|
54
63
|
const cellsAndTemps = await this.getNumberOfCellsAndTemps()
|
|
55
64
|
this.numberOfCells=cellsAndTemps.cells
|
|
@@ -65,23 +74,22 @@ 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
|
}
|
|
76
|
-
initCharacteristics(){
|
|
77
|
-
return new Promise((resolve,reject )=>{ this.device.connect().then(async ()=>{
|
|
86
|
+
async initCharacteristics(){
|
|
78
87
|
const gattServer = await this.device.gatt()
|
|
79
88
|
const txRxService= await gattServer.getPrimaryService(this.constructor.TX_RX_SERVICE)
|
|
80
89
|
this.rxChar = await txRxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
|
|
81
90
|
this.txChar = await txRxService.getCharacteristic(this.constructor.WRITE_CHAR_UUID)
|
|
82
91
|
await this.rxChar.startNotifications()
|
|
83
|
-
|
|
84
|
-
}) .catch((e)=>{ reject(e.message) }) })
|
|
92
|
+
return this
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
async initGATTNotifications(){
|
|
@@ -92,7 +100,7 @@ class JBDBMS extends BTSensor {
|
|
|
92
100
|
|
|
93
101
|
emitGATT(){
|
|
94
102
|
this.getAndEmitBatteryInfo()
|
|
95
|
-
setTimeout(()=>{this.getAndEmitCellVoltages()},
|
|
103
|
+
setTimeout(()=>{this.getAndEmitCellVoltages()}, 10000)
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
async getNumberOfCellsAndTemps(){
|
|
@@ -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
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
(buffer)=>{return buffer.readInt32LE(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
(buffer)=>{return buffer.readInt16LE(
|
|
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.
|
|
@@ -175,7 +192,7 @@ class KilovaultHLXPlus extends BTSensor{
|
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
initGATTConnection(){
|
|
178
|
-
return new Promise((resolve,reject )=>{ this.
|
|
195
|
+
return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
|
|
179
196
|
if (!this.gattServer) {
|
|
180
197
|
this.gattServer = await this.device.gatt()
|
|
181
198
|
this.battService = await this.gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
|
|
@@ -14,9 +14,10 @@ class LancolVoltageMeter extends BTSensor{
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
17
|
+
initSchema(){
|
|
18
|
+
super.initSchema()
|
|
19
|
+
this.addDefaultParam("batteryID")
|
|
20
|
+
this.addDefaultPath('voltage',"electrical.batteries.voltage")
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
getManufacturer(){
|
|
@@ -257,7 +257,6 @@ class MopekaTankSensor extends BTSensor{
|
|
|
257
257
|
await super.init()
|
|
258
258
|
const md = this.valueIfVariant(this.getManufacturerData(this.constructor.manufacturerID))
|
|
259
259
|
this.modelID = md[0]
|
|
260
|
-
this.initMetadata()
|
|
261
260
|
}
|
|
262
261
|
|
|
263
262
|
getMedium(){
|
|
@@ -272,41 +271,58 @@ class MopekaTankSensor extends BTSensor{
|
|
|
272
271
|
return rawLevel * (coefs[0] + (coefs[1] * (this.temp-233.15)) + (coefs[2] * ((this.temp-233.15)^2)))
|
|
273
272
|
}
|
|
274
273
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
initSchema(){
|
|
275
|
+
super.initSchema()
|
|
276
|
+
this.addParameter("medium",
|
|
277
|
+
{
|
|
278
|
+
title:"type of liquid in tank",
|
|
279
|
+
enum: Object.keys(Media)
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
this.addParameter("tankHeight",
|
|
283
|
+
{
|
|
284
|
+
title:"height of tank (in mm)",
|
|
285
|
+
type:"number",
|
|
286
|
+
unit:"mm"
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
this.addDefaultParam("id")
|
|
279
290
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
this.addMetadatum("battVolt","V","sensor battery in volts",
|
|
284
|
-
((buffer)=>{
|
|
291
|
+
this.addDefaultPath("battVolt","sensors.batteryVoltage")
|
|
292
|
+
.read=((buffer)=>{
|
|
285
293
|
this.battVolt = (buffer.readUInt8(1)/32)
|
|
286
294
|
return this.battVolt
|
|
287
295
|
}).bind(this)
|
|
288
|
-
|
|
289
|
-
this.
|
|
290
|
-
(buffer)=>{ return Math.max(0, Math.min(1, (((this.battVolt) - 2.2) / 0.65))) }
|
|
291
|
-
|
|
296
|
+
|
|
297
|
+
this.addDefaultPath("battStrength", "sensors.batteryStrength")
|
|
298
|
+
.read=(buffer)=>{ return Math.max(0, Math.min(1, (((this.battVolt) - 2.2) / 0.65))) }
|
|
299
|
+
|
|
292
300
|
this.addMetadatum("temp","K","temperature",
|
|
293
301
|
((buffer)=>{
|
|
294
302
|
this.temp = parseFloat(((buffer.readUInt8(2)&0x7F)+233.15).toFixed(2))
|
|
295
303
|
return this.temp
|
|
296
|
-
})
|
|
304
|
+
})
|
|
297
305
|
)
|
|
306
|
+
.default="tanks.{id}.temperature"
|
|
298
307
|
this.addMetadatum("tankLevel","ratio","tank level",
|
|
299
308
|
(buffer)=>{ return (this._tankLevel(((buffer.readUInt16LE(3))&0x3FFF)))/this.getTankHeight()}
|
|
300
309
|
)
|
|
310
|
+
.default="tanks.{id}.currentLevel"
|
|
311
|
+
|
|
301
312
|
this.addMetadatum("readingQuality","","quality of read",
|
|
302
313
|
(buffer)=>{ return buffer.readUInt8(4)>>6}
|
|
303
314
|
)
|
|
315
|
+
.default="sensors.{macAndName}.readingQuality"
|
|
316
|
+
|
|
304
317
|
this.addMetadatum("accX","Mg","acceleration on X-axis",
|
|
305
318
|
(buffer)=>{ return buffer.readUInt8(8)}
|
|
306
319
|
)
|
|
320
|
+
.default="sensors.{macAndName}.accelerationXAxis"
|
|
321
|
+
|
|
307
322
|
this.addMetadatum("accY","Mg","acceleration on Y-axis",
|
|
308
323
|
(buffer)=>{ return buffer.readUInt8(9)}
|
|
309
324
|
)
|
|
325
|
+
.default="sensors.{macAndName}.accelerationYAxis"
|
|
310
326
|
}
|
|
311
327
|
|
|
312
328
|
propertiesChanged(props){
|
|
@@ -42,13 +42,22 @@ class RenogySensor extends BTSensor{
|
|
|
42
42
|
|
|
43
43
|
async init(){
|
|
44
44
|
await super.init()
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
this.addParameter(
|
|
46
|
+
"refreshInterval",
|
|
47
|
+
{
|
|
48
|
+
title: 'refresh interval',
|
|
49
|
+
type: 'number'
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
this.addParameter(
|
|
53
|
+
"deviceID",
|
|
54
|
+
{
|
|
55
|
+
title: 'ID of device'
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
|
|
50
59
|
|
|
51
|
-
await this.
|
|
60
|
+
await this.deviceConnect()
|
|
52
61
|
const rw = await this.constructor.getReadWriteCharacteristics(this.device)
|
|
53
62
|
|
|
54
63
|
this.readChar = rw.read
|
|
@@ -22,25 +22,27 @@ class RenogyBattery extends RenogySensor {
|
|
|
22
22
|
initMetadata(){
|
|
23
23
|
|
|
24
24
|
this.addMetadatum('numberOfCells','', 'number of cells')
|
|
25
|
-
this.
|
|
26
|
-
|
|
25
|
+
this.addDefaultPath('current','electrical.batteries.current')
|
|
26
|
+
.read=(buffer)=>{return buffer.readInt16BE(3)/100}
|
|
27
27
|
|
|
28
|
-
this.
|
|
29
|
-
(buffer)=>{return buffer.readUInt16BE(5)/10}
|
|
28
|
+
this.addDefaultPath('voltage','electrical.batteries.voltage')
|
|
29
|
+
.read=(buffer)=>{return buffer.readUInt16BE(5)/10}
|
|
30
30
|
|
|
31
|
-
this.
|
|
32
|
-
(buffer)=>{return buffer.readUInt32BE(7)/1000}
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
(buffer)=>{return buffer.readUInt32BE(11)/1000}
|
|
31
|
+
this.addDefaultPath('remainingCharge', 'electrical.batteries.capacity.remaining')
|
|
32
|
+
.read=(buffer)=>{return buffer.readUInt32BE(7)/1000}
|
|
33
|
+
|
|
34
|
+
this.addDefaultPath('capacity', 'electrical.batteries.capacity.actual')
|
|
35
|
+
.read=(buffer)=>{return buffer.readUInt32BE(11)/1000}
|
|
36
36
|
|
|
37
37
|
for (let i = 0; i++ ; i < this.numberOfCells) {
|
|
38
38
|
this.addMetadatum(`cellVoltage${i}`, 'V', `cell #${i} voltage`,
|
|
39
|
-
(buffer)=>{ return buffer.readUInt16(5+ i*2) }
|
|
40
|
-
|
|
39
|
+
(buffer)=>{ return buffer.readUInt16(5+ i*2) })
|
|
40
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.voltage`
|
|
41
|
+
|
|
41
42
|
this.addMetadatum(`cellTemp${i}`, 'K', `cell #${i} temperature`,
|
|
42
|
-
(buffer)=>{ return buffer.readUInt16(5+ i*2)+273.15 }
|
|
43
|
-
|
|
43
|
+
(buffer)=>{ return buffer.readUInt16(5+ i*2)+273.15 })
|
|
44
|
+
.default=`electrical.batteries.{batteryID}.cell${i}.temperature`
|
|
45
|
+
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
async initGATTConnection() {
|
|
@@ -10,13 +10,12 @@ class RenogyRoverClient extends RenogySensor {
|
|
|
10
10
|
|
|
11
11
|
async init(){
|
|
12
12
|
await super.init()
|
|
13
|
-
this.initMetadata()
|
|
14
13
|
this.modelID=await this.retrieveModelID()
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
initSchema(){
|
|
18
17
|
//Buffer(73) [1, 3, 68, 32, 32, 82, 78, 71, 45, 67, 84, 82, 76, 45, 87, 78, 68, 51, 48, 7, 140, 0, 132, 0, 126, 0, 120, 0, 111, 0, 106, 100, 50, 0, 5, 0, 120, 0, 120, 0, 28, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 5, 0, 5, 2, 148, 0, 5, 206, 143, 34, 228, buffer: ArrayBuffer(8192), byteLength: 73, byteOffset: 6144, length: 73, Symbol(Symbol.toStringTag): 'Uint8Array']
|
|
19
|
-
|
|
18
|
+
super.initSchema()
|
|
20
19
|
this.addMetadatum('batteryType', '', "battery type")
|
|
21
20
|
this.addMetadatum('batteryPercentage', 'ratio', "battery percentage",
|
|
22
21
|
(buffer)=>{return buffer.readUInt16BE(3) })
|