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
|
@@ -26,11 +26,8 @@ TBD
|
|
|
26
26
|
return await this.identifyMode(device, 0x07)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.initMetadata()
|
|
32
|
-
}
|
|
33
|
-
initMetadata(){
|
|
29
|
+
initSchema(){
|
|
30
|
+
super.initSchema()
|
|
34
31
|
this.addMetadatum('voltage','V', 'channel #1 voltage',
|
|
35
32
|
(buff)=>{return this.NaNif(buff.readInt16LE(0),0xFFFF)/100})
|
|
36
33
|
this.addMetadatum('pvPower','W','DC input power in watts',
|
|
@@ -7,23 +7,27 @@ class VictronInverter extends VictronSensor{
|
|
|
7
7
|
return await this.identifyMode(device, 0x03)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
initMetadata(){
|
|
10
|
+
initSchema(){
|
|
11
|
+
super.initSchema()
|
|
12
|
+
this.addDefaultParam("id")
|
|
13
|
+
|
|
15
14
|
this.addMetadatum('deviceState','', 'inverter device state',
|
|
16
15
|
(buff)=>{return VC.OperationMode.get(buff.readIntU8(0))})
|
|
16
|
+
.default="electrical.inverters.{id}.state"
|
|
17
|
+
|
|
17
18
|
const md = this.addMetadatum('alarmReason','', 'reason for alarm',
|
|
18
19
|
(buff)=>{return buff.readIntU16LE(1)})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
.default="electrical.inverters.{id}.alarm"
|
|
21
|
+
|
|
22
|
+
this.addDefaultPath('dcVoltage','electrical.inverters.dc.voltage')
|
|
23
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
24
|
+
|
|
25
|
+
this.addDefaultPath('acPower','electrical.inverters.ac.power')
|
|
26
|
+
.read=(buff)=>{return this.NaNif( buff.readUInt16LE(5), 0xFFFF )*this.powerFactor}
|
|
27
|
+
|
|
28
|
+
this.addDefaultPath('acVoltage','electrical.inverters.ac.voltage')
|
|
29
|
+
|
|
30
|
+
this.addDefaultPath('acCurrent','electrical.inverters.ac.current')
|
|
27
31
|
|
|
28
32
|
}
|
|
29
33
|
powerFactor = .8 //parameterize anon
|
|
@@ -33,9 +37,9 @@ class VictronInverter extends VictronSensor{
|
|
|
33
37
|
const br = new BitReader(decData.subarray(5))
|
|
34
38
|
this.emit('acVoltage',
|
|
35
39
|
this.NaNif(br.read_unsigned_int(15),0x7FFF)/100)
|
|
36
|
-
this.
|
|
40
|
+
this.emit('acCurrent',
|
|
37
41
|
this.NaNif(br.read_unsigned_int(11),0x7FF)/10)
|
|
38
|
-
const alarm = this.
|
|
42
|
+
const alarm = this.getPath("alarmReason").read(decData)
|
|
39
43
|
if (alarm>0){
|
|
40
44
|
this.emit(
|
|
41
45
|
`ALARM #${alarm} from ${this.getDisplayName()})`,
|
|
@@ -10,28 +10,39 @@ class VictronInverterRS extends VictronSensor{
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
initSchema() {
|
|
14
|
+
super.initSchema()
|
|
15
|
+
this.addDefaultParam("id")
|
|
16
16
|
this.addMetadatum('deviceState','', 'inverter device state',
|
|
17
|
-
|
|
17
|
+
(buff)=>{return VC.OperationMode.get(buff.readIntU8(0))})
|
|
18
|
+
.default='electrical.inverters.{id}.state'
|
|
19
|
+
|
|
18
20
|
const md = this.addMetadatum('chargerError','', 'charger error',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
(buff)=>{return VC.ChargerError(buff.readIntU8(1))})
|
|
22
|
+
md.default='electrical.inverters.{id}.error'
|
|
23
|
+
md.notify=true
|
|
21
24
|
|
|
22
25
|
this.addMetadatum('batteryVoltage','V', 'battery voltage',
|
|
23
26
|
(buff)=>{return this.NaNif(buff.readInt16LE(2),0x7FFF)/100})
|
|
27
|
+
.default='electrical.inverters.{id}.battery.voltage'
|
|
28
|
+
.
|
|
24
29
|
this.addMetadatum('pvPower','W', 'PV power',
|
|
25
30
|
(buff)=>{return this.NaNif(buff.readUInt16LE(4), 0xffff)})
|
|
31
|
+
.default='electrical.inverters.{id}.power'
|
|
32
|
+
|
|
26
33
|
this.addMetadatum('yieldToday','W', 'yield yoday in watts',
|
|
27
34
|
(buff)=>{return this.NaNif(buff.readUInt16LE(6), 0xffff)*10})
|
|
35
|
+
.default='electrical.inverters.{id}.yieldToday'
|
|
36
|
+
|
|
28
37
|
this.addMetadatum('acOutPower','W', 'AC out power in watts',
|
|
29
|
-
(buff)=>{this.NaNif(buff.readInt16LE(8), 0x7fff)})
|
|
38
|
+
(buff)=>{this.NaNif(buff.readInt16LE(8), 0x7fff)})
|
|
39
|
+
.default='electrical.inverters.{id}.ac.power'
|
|
40
|
+
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
emitValuesFrom(decData){
|
|
33
44
|
super.emitValuesFrom(decData)
|
|
34
|
-
const error = this.
|
|
45
|
+
const error = this.getPath("chargerError").read(decData)
|
|
35
46
|
if (error>0){
|
|
36
47
|
this.emit(
|
|
37
48
|
`Charger Error #${error} from ${this.getDisplayName()})`,
|
|
@@ -22,26 +22,28 @@ class VictronLynxSmartBMS extends VictronSensor{
|
|
|
22
22
|
return await this.identifyMode(device, 0x0A)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.initMetadata()
|
|
28
|
-
}
|
|
29
|
-
initMetadata(){
|
|
25
|
+
initSchema(){
|
|
26
|
+
super.initSchema()
|
|
30
27
|
this.addMetadatum('error','', 'error code',
|
|
31
28
|
(buff)=>{return buff.readUInt8(0)})
|
|
32
29
|
|
|
33
|
-
this.
|
|
34
|
-
(buff)=>{return this.NaNif(buff.readUInt16LE(1),0xFFFF)*60}
|
|
35
|
-
this.
|
|
36
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
37
|
-
this.
|
|
38
|
-
(buff)=>{return this.NaNif(buff.readInt16LE(5),0x7FFF)/10}
|
|
30
|
+
this.addDefaultPath('ttg','electrical.batteries.capacity.timeRemaining')
|
|
31
|
+
.read=(buff)=>{return this.NaNif(buff.readUInt16LE(1),0xFFFF)*60}
|
|
32
|
+
this.addDefaultPath('voltage','electrical.batteries.voltage')
|
|
33
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(3),0x7FFF)/100}
|
|
34
|
+
this.addDefaultPath('current','electrical.batteries.current')
|
|
35
|
+
.read=(buff)=>{return this.NaNif(buff.readInt16LE(5),0x7FFF)/10}
|
|
36
|
+
|
|
39
37
|
this.addMetadatum('ioStatus','','IO Status', //TODO
|
|
40
38
|
(buff)=>{return buff.readUInt16LE(7)})
|
|
39
|
+
|
|
41
40
|
this.addMetadatum('warningsAndAlarms','','warnings and alarms')
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
this.addDefaultPath('soc','electrical.batteries.capacity.stateOfCharge')
|
|
43
43
|
this.addMetadatum('consumedAh','Ah','amp-hours consumed')
|
|
44
|
-
|
|
44
|
+
.default="electrical.batteries.{batteryID}.capacity.ampHoursConsumed"
|
|
45
|
+
|
|
46
|
+
this.addDefaultPath('temp', 'electrical.batteries.temperature')
|
|
45
47
|
}
|
|
46
48
|
emitValuesFrom(buffer){
|
|
47
49
|
super.emitValuesFrom(buffer)
|
|
@@ -8,22 +8,35 @@ class VictronOrionXS extends VictronSensor{
|
|
|
8
8
|
static async identify(device){
|
|
9
9
|
return await this.identifyMode(device, 0x0F)
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
initSchema() {
|
|
12
|
+
super.initSchema()
|
|
13
|
+
this.addDefaultParam("id")
|
|
13
14
|
this.addMetadatum('deviceState','', 'device state',
|
|
14
15
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
16
|
+
.default="electrical.chargers.{id}.state"
|
|
17
|
+
|
|
15
18
|
this.addMetadatum('chargerError','', 'charger error',
|
|
16
19
|
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
20
|
+
.default="electrical.chargers.{id}.error"
|
|
21
|
+
|
|
17
22
|
this.addMetadatum('outputVoltage','V', 'output voltage',
|
|
18
23
|
(buff)=>{return this.NaNif(buff.readInt16LE(2),0x7FF)/100})
|
|
24
|
+
.default="electrical.chargers.{id}.output.voltage"
|
|
25
|
+
|
|
26
|
+
|
|
19
27
|
this.addMetadatum('current','A','output current',
|
|
20
28
|
(buff)=>{return this.NaNif(buff.readUInt16LE(4),0xFFFF)/10})
|
|
29
|
+
.default="electrical.chargers.{id}.output.current"
|
|
21
30
|
this.addMetadatum('inputVoltage','V', 'input voltage',
|
|
22
31
|
(buff)=>{return this.NaNif(buff.readInt16LE(6),0x07FF)/100})
|
|
32
|
+
.default="electrical.chargers.{id}.input.voltage"
|
|
23
33
|
this.addMetadatum('inputCurrent','A','input current',
|
|
24
34
|
(buff)=>{return this.NaNif(buff.readUInt16LE(8),0xFFFF)/10})
|
|
35
|
+
.default="electrical.chargers.{id}.input.current"
|
|
25
36
|
this.addMetadatum('deviceOffReason','', 'device off reason',
|
|
26
|
-
(buff)=>{return VC.OffReasons(buff.readUInt32BE(10))})
|
|
37
|
+
(buff)=>{return VC.OffReasons(buff.readUInt32BE(10))})
|
|
38
|
+
.default="electrical.chargers.{id}.offReason"
|
|
39
|
+
}
|
|
27
40
|
|
|
28
41
|
}
|
|
29
42
|
module.exports=VictronOrionXS
|
|
@@ -23,13 +23,12 @@ class VictronSmartBatteryProtect extends VictronSensor{
|
|
|
23
23
|
return await this.identifyMode(device, 0x09)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
initMetadata(){
|
|
26
|
+
|
|
27
|
+
initSchema(){
|
|
28
|
+
super.initSchema()
|
|
29
|
+
this.addDefaultParam("id")
|
|
31
30
|
this.addMetadatum('deviceState','', 'device state',
|
|
32
|
-
|
|
31
|
+
(buff)=>{return VC.OperationMode.get(buff.readUInt8(1))})
|
|
33
32
|
this.addMetadatum('outputStatus','', 'output status', //TODO
|
|
34
33
|
(buff)=>{return (buff.readUInt8(2))})
|
|
35
34
|
|
|
@@ -38,31 +38,31 @@ class VictronSmartLithium extends VictronSensor{
|
|
|
38
38
|
return await this.identifyMode(device, 0x05)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
}
|
|
45
|
-
initMetadata(){
|
|
41
|
+
initSchema(){
|
|
42
|
+
super.initSchema()
|
|
43
|
+
this.addDefaultParam("batteryID")
|
|
46
44
|
|
|
47
45
|
this.addMetadatum('bmsFlags','', 'BMS Flags',
|
|
48
46
|
(buff)=>{return buff.readUInt32LE(0)})
|
|
47
|
+
.default="electrical.batteries.{batteryID}.flags"
|
|
49
48
|
|
|
50
49
|
this.addMetadatum('smartLithiumErrors','', 'Smart Lithium Errors Flags',
|
|
51
50
|
(buff)=>{return buff.readUInt16LE(4)})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.addMetadatum('balancerStatus','', 'balancer status', //TODO
|
|
51
|
+
.default="electrical.batteries.{batteryID}.errors"
|
|
52
|
+
|
|
53
|
+
for (let i=0;i++;i<8){
|
|
54
|
+
this.addMetadatum(`cell${i+1}Voltage`,'V', `cell ${i+1} voltage`)
|
|
55
|
+
.default=`electrical.batteries.{batteryID}.cell${i+1}.voltage`
|
|
56
|
+
}
|
|
57
|
+
this.addDefaultPath('batteryVoltage','electrical.batteries.voltage')
|
|
58
|
+
.read=(buff)=>{return this.NaNif((buff.readUInt16LE(13)&0xFFF),0xFFF)/100}
|
|
59
|
+
|
|
60
|
+
this.addMetadatum('balancerStatus','', 'balancer status',
|
|
63
61
|
(buff)=>{return BALANCERSTATUS[this.NaNif((buff.readUInt8(14)>>4),0xF)]})
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
.default=`electrical.batteries.{batteryID}.balancerStatus`
|
|
63
|
+
|
|
64
|
+
this.addDefaultPath('batteryTemp','electrical.batteries.temperature')
|
|
65
|
+
.read=(buff)=>{return this.NaNif((buff.readUInt8(15)&0x7F),0x7F)+233.15}
|
|
66
66
|
}
|
|
67
67
|
emitValuesFrom(buffer){
|
|
68
68
|
super.emitValuesFrom(buffer)
|
|
@@ -6,25 +6,38 @@ class VictronSolarCharger extends VictronSensor{
|
|
|
6
6
|
return await this.identifyMode(device, 0x01)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.addMetadatum('chargeState','', 'charge state',
|
|
9
|
+
initSchema() {
|
|
10
|
+
super.initSchema()
|
|
11
|
+
this.addDefaultParam("id")
|
|
12
|
+
|
|
13
|
+
this.addMetadatum('chargeState','', 'charge state',
|
|
15
14
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
.default="electrical.solar.{id}.state"
|
|
16
|
+
|
|
17
|
+
this.addMetadatum('chargerError','', 'charger error',
|
|
18
|
+
(buff)=>{return VC.ChargerError.get(buff.readUInt8(1))})
|
|
19
|
+
.default="electrical.solar.{id}.error"
|
|
20
|
+
|
|
21
|
+
this.addMetadatum('voltage','V', 'charger battery voltage',
|
|
22
|
+
(buff)=>{return this.NaNif(buff.readInt16LE(2),0x7FFF)/100})
|
|
23
|
+
.default="electrical.solar.{id}.dc.voltage"
|
|
24
|
+
|
|
25
|
+
this.addMetadatum('current','A','charger battery current',
|
|
26
|
+
(buff)=>{return this.NaNif(buff.readInt16LE(4),0x7FFF)/10})
|
|
27
|
+
.default="electrical.solar.{id}.dc.current"
|
|
28
|
+
|
|
29
|
+
this.addMetadatum('yield','Wh', 'yield today in Watt-hours',
|
|
30
|
+
(buff)=>{return this.NaNif(buff.readUInt16LE(6),0xFFFF)*10})
|
|
31
|
+
.default="electrical.solar.{id}.yieldToday"
|
|
32
|
+
|
|
33
|
+
this.addMetadatum('solarPower','W', 'solar power',
|
|
34
|
+
(buff)=>{return this.NaNif(buff.readUInt16LE(8),0xFFFF)})
|
|
35
|
+
.default="electrical.solar.{id}.panelPower"
|
|
36
|
+
|
|
37
|
+
this.addMetadatum('externalDeviceLoad','A', 'external device load',
|
|
38
|
+
(buff)=>{return this.NaNif(buff.readUInt16LE(10)&0x1FF,0x1FF)/10})
|
|
39
|
+
.default="electrical.solar.{id}.loadCurrent"
|
|
40
|
+
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
43
|
module.exports=VictronSolarCharger
|
|
@@ -9,11 +9,8 @@ class VictronVEBus extends VictronSensor{
|
|
|
9
9
|
return await this.identifyMode(device, 0x0C)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.initMetadata()
|
|
15
|
-
}
|
|
16
|
-
initMetadata(){
|
|
12
|
+
initSchema(){
|
|
13
|
+
super.initSchema()
|
|
17
14
|
this.addMetadatum('chargeState','', 'charge state',
|
|
18
15
|
(buff)=>{return VC.OperationMode.get(buff.readUInt8(0))})
|
|
19
16
|
|
|
@@ -90,8 +90,6 @@ class XiaomiMiBeacon extends BTSensor{
|
|
|
90
90
|
return null
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
GATTwarning = "WARNING: Xiaomi GATT connections are known to be unreliable on Debian distributions with Bluez 5.55 and up (earlier BlueZ versions are untested). Using GATT on the Xiaomi may put the system Bluetooth stack into an inconsistent state disrupting and disabling other plugin Bluetooth connections. If by some chance you're successful using GATT with the Xiaomi, let the plugin developer know your configuration. Refer to the plugin documentation for getting the Xiamoi bindKey for non-GATT connections and more information on Xiaomi GATT issues."
|
|
95
93
|
|
|
96
94
|
emitValues(buffer){
|
|
97
95
|
this.emitData("temp", buffer, 0)
|
|
@@ -102,15 +100,12 @@ class XiaomiMiBeacon extends BTSensor{
|
|
|
102
100
|
return "Xiaomi Inc."
|
|
103
101
|
}
|
|
104
102
|
getGATTDescription() {
|
|
105
|
-
return
|
|
103
|
+
return ""
|
|
106
104
|
}
|
|
105
|
+
|
|
107
106
|
initGATTConnection(){
|
|
108
|
-
if (!this?.gattWarningDelivered) {
|
|
109
|
-
this.debug(this.GATTwarning.toUpperCase())
|
|
110
|
-
this.gattWarningDelivered=true
|
|
111
|
-
}
|
|
112
107
|
return new Promise((resolve,reject )=>{
|
|
113
|
-
this.
|
|
108
|
+
this.deviceConnect().then(async ()=>{
|
|
114
109
|
if (!this.gattServer) {
|
|
115
110
|
this.gattServer = await this.device.gatt()
|
|
116
111
|
this.gattService = await this.gattServer.getPrimaryService("ebe0ccb0-7a0a-4b0c-8a1a-6ff2997da3a6")
|
|
@@ -202,29 +197,44 @@ class XiaomiMiBeacon extends BTSensor{
|
|
|
202
197
|
}
|
|
203
198
|
|
|
204
199
|
async init(){
|
|
205
|
-
await super.init()
|
|
206
|
-
const md = this.addMetadatum("encryptionKey", "", "encryptionKey (AKA bindKey) for decryption")
|
|
207
|
-
md.isParam=true
|
|
208
|
-
this.addMetadatum('temp','K', 'temperature',
|
|
209
|
-
(buff,offset)=>{return ((buff.readInt16LE(offset))/10) + 273.15})
|
|
210
|
-
this.addMetadatum('humidity','ratio', 'humidity',
|
|
211
|
-
(buff,offset)=>{return buff.readInt16LE(offset)/1000})
|
|
212
|
-
|
|
213
|
-
this.addMetadatum('batteryStrength', 'ratio', 'sensor battery strength',
|
|
214
|
-
(buff,offset)=>{return ((buff.readUInt8(offset))/100)})
|
|
215
|
-
this.addMetadatum('voltage', 'V', 'sensor battery voltage',
|
|
216
|
-
(buff,offset)=>{return ((buff.readUInt16LE(offset))/1000)})
|
|
217
200
|
|
|
201
|
+
await super.init()
|
|
218
202
|
const data = this.getServiceData(this.constructor.SERVICE_MIBEACON)
|
|
219
203
|
const frameControl = data[0] + (data[1] << 8)
|
|
220
204
|
this.deviceID = data[2] + (data[3] << 8)
|
|
221
205
|
this.isEncrypted = (frameControl >> 3) & 1
|
|
222
206
|
this.encryptionVersion = frameControl >> 12
|
|
223
207
|
}
|
|
208
|
+
initSchema(){
|
|
209
|
+
super.initSchema()
|
|
210
|
+
this.addDefaultParam("zone")
|
|
211
|
+
|
|
212
|
+
this.addParameter(
|
|
213
|
+
"encryptionKey",
|
|
214
|
+
{
|
|
215
|
+
title: "encryptionKey (AKA bindKey) for decryption"
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
this.addDefaultPath('temp','environment.temperature')
|
|
219
|
+
.read=(buff,offset)=>{return ((buff.readInt16LE(offset))/10) + 273.15}
|
|
220
|
+
|
|
221
|
+
this.addDefaultPath('humidity','environment.humidity')
|
|
222
|
+
.read=(buff,offset)=>{return buff.readInt16LE(offset)/1000}
|
|
223
|
+
|
|
224
|
+
this.addDefaultPath("batteryStrength", "sensors.batteryStrength")
|
|
225
|
+
.read= (buff,offset)=>{return ((buff.readUInt8(offset))/100)}
|
|
226
|
+
|
|
227
|
+
this.addDefaultPath("voltage", "sensors.batteryVoltage")
|
|
228
|
+
.read=(buff,offset)=>{return ((buff.readUInt16LE(offset))/1000)}
|
|
229
|
+
}
|
|
224
230
|
|
|
225
231
|
getName(){
|
|
226
232
|
const dt = DEVICE_TYPES.get(this.deviceID)
|
|
227
|
-
|
|
233
|
+
if (!dt)
|
|
234
|
+
return super.getName()
|
|
235
|
+
else
|
|
236
|
+
return this?.name??`${dt.name} ${dt.model}`
|
|
237
|
+
|
|
228
238
|
}
|
|
229
239
|
|
|
230
240
|
async disconnectGATTCharacteristic(){
|