bt-sensors-plugin-sk 1.2.5 → 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.
Files changed (126) hide show
  1. package/BTSensor.js +77 -38
  2. package/DistanceManager.js +249 -0
  3. package/Mixin.js +19 -0
  4. package/OutOfRangeDevice.js +46 -0
  5. package/README.md +20 -6
  6. package/classLoader.js +7 -2
  7. package/connectUUID.exp +26 -0
  8. package/index.js +54 -11
  9. package/package.json +8 -6
  10. package/public/159.js +1 -1
  11. package/public/540.js +1 -1
  12. package/public/681.js +3 -9
  13. package/public/681.js.LICENSE.txt +2 -0
  14. package/public/764.js +1 -0
  15. package/public/images/ATC.jpeg +0 -0
  16. package/public/images/Aranet4.webp +0 -0
  17. package/public/images/BP108B.webp +0 -0
  18. package/public/images/GoveeH5074.jpg +0 -0
  19. package/public/images/GoveeH5075.webp +0 -0
  20. package/public/images/GoveeH510x.jpg +0 -0
  21. package/public/images/InkbirdTH3.webp +0 -0
  22. package/public/images/JBDBMS.webp +0 -0
  23. package/public/images/Junctek.webp +0 -0
  24. package/public/images/KilovaultHLXPlus.jpg +0 -0
  25. package/public/images/LancolVoltageMeter.webp +0 -0
  26. package/public/images/LiTimeLiFePo4Battery.avif +0 -0
  27. package/public/images/MercurySmartcraft.jpg +0 -0
  28. package/public/images/MopekaTankSensor.jpg +0 -0
  29. package/public/images/RemoranWave3.jpeg +0 -0
  30. package/public/images/RenogyInverter.jpg +0 -0
  31. package/public/images/RenogyRoverClient.jpg +0 -0
  32. package/public/images/RenogySmartLiFePo4Battery.webp +0 -0
  33. package/public/images/RuuviTag.jpg +0 -0
  34. package/public/images/ShellyBLUHT.webp +0 -0
  35. package/public/images/ShellyBLUMotion.webp +0 -0
  36. package/public/images/ShellyBluDoorWindow.webp +0 -0
  37. package/public/images/Skanbatt.jpg +0 -0
  38. package/public/images/SmartBatteryProtect.webp +0 -0
  39. package/public/images/SmartBatterySense.webp +0 -0
  40. package/public/images/SwitchBotMeterPlus.webp +0 -0
  41. package/public/images/SwitchBotTH.webp +0 -0
  42. package/public/images/TopbandBattery.webp +0 -0
  43. package/public/images/Ultrasonic.jpg +0 -0
  44. package/public/images/VictronBlueSmartACCharger.jpg +0 -0
  45. package/public/images/VictronBlueSolarMPPT.jpeg +0 -0
  46. package/public/images/VictronCerboGX.webp +0 -0
  47. package/public/images/VictronInverterRS.webp +0 -0
  48. package/public/images/VictronLynxSmartBMS.webp +0 -0
  49. package/public/images/VictronMultiPlus-II.webp +0 -0
  50. package/public/images/VictronOrionTrIsolated.webp +0 -0
  51. package/public/images/VictronOrionTrNonIsolated.webp +0 -0
  52. package/public/images/VictronPhoenixInverter.webp +0 -0
  53. package/public/images/VictronPhoenixSmart1600.webp +0 -0
  54. package/public/images/VictronSmartBatteryProtect.jpg +0 -0
  55. package/public/images/VictronSmartIP43.webp +0 -0
  56. package/public/images/VictronSmartLithiumBattery.jpg +0 -0
  57. package/public/images/VictronSmartSolarMPPT.webp +0 -0
  58. package/public/images/VictronVEBus.webp +0 -0
  59. package/public/images/iBeacon.jpg +0 -0
  60. package/public/main.js +1 -1
  61. package/public/remoteEntry.js +1 -1
  62. package/readUUID.exp +23 -0
  63. package/sensor_classes/ATC.js +3 -2
  64. package/sensor_classes/Aranet2.js +3 -1
  65. package/sensor_classes/Aranet4.js +1 -2
  66. package/sensor_classes/BankManager.js +1 -1
  67. package/sensor_classes/Beacon/AbstractBeaconMixin.js +85 -0
  68. package/sensor_classes/Beacon/Eddystone.js +77 -0
  69. package/sensor_classes/Beacon/iBeacon.js +58 -0
  70. package/sensor_classes/EctiveBMS.js +270 -0
  71. package/sensor_classes/FeasyComBeacon.js +68 -0
  72. package/sensor_classes/GobiusCTankMeter.js +4 -3
  73. package/sensor_classes/GoveeH5074.js +2 -0
  74. package/sensor_classes/GoveeH5075.js +2 -0
  75. package/sensor_classes/GoveeH510x.js +1 -0
  76. package/sensor_classes/Inkbird.js +1 -0
  77. package/sensor_classes/JBDBMS.js +1 -0
  78. package/sensor_classes/Junctek.js +14 -6
  79. package/sensor_classes/KilovaultHLXPlus.js +1 -0
  80. package/sensor_classes/LancolVoltageMeter.js +2 -0
  81. package/sensor_classes/MercurySmartcraft.js +1 -0
  82. package/sensor_classes/MopekaTankSensor.js +7 -204
  83. package/sensor_classes/RemoranWave3.js +2 -0
  84. package/sensor_classes/Renogy/RenogySensor.js +1 -0
  85. package/sensor_classes/RenogyBattery.js +3 -4
  86. package/sensor_classes/RenogyInverter.js +3 -6
  87. package/sensor_classes/RenogyRoverClient.js +3 -0
  88. package/sensor_classes/RuuviTag.js +11 -8
  89. package/sensor_classes/ShellySBDW002C.js +3 -1
  90. package/sensor_classes/ShellySBHT003C.js +7 -0
  91. package/sensor_classes/ShellySBMO003Z.js +3 -2
  92. package/sensor_classes/ShenzhenLiOnBMS.js +4 -0
  93. package/sensor_classes/SwitchBotMeterPlus.js +1 -1
  94. package/sensor_classes/SwitchBotTH.js +2 -1
  95. package/sensor_classes/UNKNOWN.js +2 -1
  96. package/sensor_classes/UltrasonicWindMeter.js +3 -0
  97. package/sensor_classes/Victron/VictronConstants.js +2 -0
  98. package/sensor_classes/Victron/VictronIdentifier.js +24 -0
  99. package/sensor_classes/Victron/VictronSensor.js +59 -49
  100. package/sensor_classes/VictronACCharger.js +1 -6
  101. package/sensor_classes/VictronBatteryMonitor.js +37 -26
  102. package/sensor_classes/VictronDCDCConverter.js +1 -4
  103. package/sensor_classes/VictronDCEnergyMeter.js +1 -4
  104. package/sensor_classes/VictronGXDevice.js +1 -4
  105. package/sensor_classes/VictronInverter.js +2 -3
  106. package/sensor_classes/VictronInverterRS.js +2 -4
  107. package/sensor_classes/VictronLynxSmartBMS.js +1 -4
  108. package/sensor_classes/VictronOrionXS.js +1 -3
  109. package/sensor_classes/VictronSmartBatteryProtect.js +1 -4
  110. package/sensor_classes/VictronSmartLithium.js +1 -4
  111. package/sensor_classes/VictronSolarCharger.js +1 -3
  112. package/sensor_classes/VictronVEBus.js +1 -4
  113. package/sensor_classes/XiaomiMiBeacon.js +5 -2
  114. package/sensor_classes/iBeaconSensor.js +40 -0
  115. package/src/components/PluginConfigurationPanel.js +134 -173
  116. package/Screenshot 2025-06-12 at 9.33.57/342/200/257AM.png +0 -0
  117. package/bt-sensors-plugin-sk copy.json +0 -170
  118. package/bt-sensors-plugin-sk.json.bak +0 -121
  119. package/public/847.js +0 -1
  120. package/sensor_classes/IBeacon.js +0 -45
  121. package/vsl_patch_17_06_25.patch +0 -13
  122. /package/public/images/{Aranet2_HOME_F_900x900_90OVA5J.original.webp → Aranet2.webp} +0 -0
  123. /package/public/images/{Bank Manager All-in-onewc.webp → BankManager.webp} +0 -0
  124. /package/public/images/{Gobius_C.png → GobiusCTankMeter.png} +0 -0
  125. /package/public/images/{Victron-SmartShunt.jpg → VictronSmartShunt.jpg} +0 -0
  126. /package/public/images/{smartsolarMPPT7515.png → VictronSmartSolarMPPT7515.png} +0 -0
@@ -3,71 +3,71 @@ const Images = require('./VictronImages.js')
3
3
 
4
4
  const BTSensor = require("../../BTSensor.js");
5
5
  const crypto = require('node:crypto');
6
- function sleep(x) {
7
- return new Promise((resolve) => {
8
- setTimeout(() => {
9
- resolve(x);
10
- }, x);
11
- });
12
- }
6
+ const VictronIdentifier = require('./VictronIdentifier.js');
7
+
13
8
  class VictronSensor extends BTSensor{
14
9
  static Domain = BTSensor.SensorDomains.electrical
15
-
10
+ static ManufacturerID = 0x2e1
16
11
  constructor(device,config,gattConfig){
17
12
  super(device,config,gattConfig)
18
- this.encryptionKey = config?.encryptionKey
13
+
14
+ if (device.modelID)
15
+ this.modelID=device.modelID
19
16
  }
17
+
20
18
 
21
- static async identifyMode(device, mode){
22
-
23
- var md = await this.getDeviceProp(device,'ManufacturerData')
24
- if (md==undefined || !Object.hasOwn(md,0x2e1))
25
- return null
26
- else {
27
-
28
- if (md[0x2e1].value[0]==0x10) {
29
- if (md[0x2e1].value[4]==mode)
30
- return this
31
- else
32
- return null
33
- }
19
+ static async getDataPacket(device, md){
20
+ if (md && md[this.ManufacturerID]?.value[0]==0x10)
21
+ return md[this.ManufacturerID].value
22
+
23
+ device.helper._prepare()
34
24
 
35
- var hasDataPacket=false
36
- device.helper._prepare()
25
+ return new Promise((resolve, reject) => {
37
26
  device.helper.on("PropertiesChanged",
38
- (props)=> {
39
- if (Object.hasOwn(props,'ManufacturerData')){
40
- md = props['ManufacturerData'].value
41
- hasDataPacket=md[0x2e1].value[0]==0x10
27
+ (props)=> {
28
+ if (Object.hasOwn(props,'ManufacturerData')){
29
+ const md = props['ManufacturerData'].value
30
+ if(md[this.ManufacturerID].value[0]==0x10) {
31
+ device.helper.removeListeners()
32
+ resolve(md[this.ManufacturerID].value)
42
33
  }
34
+ }
43
35
  })
44
- while (!hasDataPacket) {
45
- await sleep(500)
46
- }
47
- device.helper.removeListeners()
48
- if (md[0x2e1].value[4]==mode)
49
- return this
50
- else
51
- return null
52
- }
36
+ })
37
+ }
38
+
39
+ static getModelID(md) {
40
+ return md[this.ManufacturerID]?.value.readUInt16LE(2)??-1
53
41
  }
54
42
 
55
- async init(){
43
+ static async identify(device){
44
+
45
+ var md = await this.getDeviceProp(device,'ManufacturerData')
46
+ if (md==undefined || !Object.hasOwn(md,this.ManufacturerID))
47
+ return null
48
+ const data=await this.getDataPacket(device,md)
49
+ if (data) {
50
+ device.modelID=this.getModelID(md)
51
+ return VictronIdentifier.identify(data)
52
+ }
53
+ return null
54
+ }
55
+ async init(){
56
56
  await super.init()
57
57
  this.addParameter(
58
58
  "encryptionKey",
59
59
  {
60
- title:"Encryption Key"
60
+ title:"Encryption Key",
61
+ isRequired: true
61
62
  }
62
63
  )
63
- this.model_id=this.getManufacturerData(0x2e1)?.readUInt16LE(2)??"Unknown"
64
- this._schema.title = this.getName()
65
64
  }
66
65
  alarmReason(alarmValue){
67
66
  return this.constructor.AlarmReason[alarmValue]
68
67
  }
69
68
  getModelName(){
70
- const m = VC.MODEL_ID_MAP[this.model_id]
69
+ const mID = this.getModelID()
70
+ const m = VC.MODEL_ID_MAP[mID]
71
71
  if(m) {
72
72
  if(typeof m == 'string' || m instanceof String ) {
73
73
  return m
@@ -75,7 +75,7 @@ function sleep(x) {
75
75
  return m.name
76
76
  }
77
77
  }
78
- return this.constructor.name+" (Model ID:"+this.model_id+")"
78
+ return this.constructor.name+` (Model ID: ${mID==-1?"Unknown":mID})`
79
79
  }
80
80
 
81
81
  decrypt(data){
@@ -98,6 +98,13 @@ function sleep(x) {
98
98
  return Buffer.from(decData)
99
99
 
100
100
  }
101
+ getModelID(){
102
+ if (!this.modelID ||this.modelID==-1)
103
+ this.modelID=this.getManufacturerData(this.constructor.ManufacturerID)?.readUInt16LE(2)??-1
104
+
105
+ return this.modelID
106
+ }
107
+
101
108
  getName(){
102
109
  return `Victron ${this.getModelName()}`
103
110
  }
@@ -106,7 +113,7 @@ function sleep(x) {
106
113
  if (this.usingGATT()) return
107
114
  if (!props.hasOwnProperty("ManufacturerData")) return
108
115
  try{
109
- const md = this.getManufacturerData(0x2e1)
116
+ const md = this.getManufacturerData(this.constructor.ManufacturerID)
110
117
  if (md && md.length && md[0]==0x10){
111
118
  const decData=this.decrypt(md)
112
119
  this.emitValuesFrom(decData)
@@ -122,21 +129,24 @@ function sleep(x) {
122
129
  }
123
130
 
124
131
  getImage(){
125
- const m = VC.MODEL_ID_MAP[this.model_id]
132
+ const m = VC.MODEL_ID_MAP[this.getModelID()]
126
133
  if (m && m.image)
127
134
  return m.image
128
135
  else
129
136
  return Images.generic
130
137
  }
131
138
 
132
- getDescription(){
139
+ getTextDescription(){
133
140
  //return `<img src="https://www.victronenergy.com/_next/image?url=https%3A%2F%2Fwww.victronenergy.com%2Fupload%2Fproducts%2FSmartShunt%2520500_nw.png&w=1080&q=70"" height="150" align=”top” ></img>`
134
141
 
135
142
 
136
- return `<img src="../bt-sensors-plugin-sk/images/${this.getImage()}" width="200" style="float: left;
137
- margin: 20px;" ></img>
138
- To get the encryption key for your device, follow the instructions <a href=https://communityarchive.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html target="_victron_encrypt">here</a>`
143
+ return `To get the encryption key for your device, follow the instructions <a href=https://communityarchive.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html target="_victron_encrypt">here</a>`
139
144
  }
140
145
 
146
+ prepareConfig(config){
147
+ super.prepareConfig(config)
148
+ config.params.modelID=this.getModelID()
149
+ }
150
+
141
151
  }
142
152
  module.exports=VictronSensor
@@ -23,12 +23,7 @@ const VC = require("./Victron/VictronConstants.js")
23
23
  const BitReader = require("./_BitReader")
24
24
 
25
25
  class VictronACCharger extends VictronSensor{
26
-
27
- static async identify(device){
28
- return await this.identifyMode(device, 0x08)
29
- }
30
-
31
-
26
+ static ImageFile = "VictronBlueSmartACCharger.jpg"
32
27
  initSchema(){
33
28
  super.initSchema()
34
29
  this.addDefaultParam("id")
@@ -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
- static async identify(device){
12
- return await this.identifyMode(device, 0x02)
13
- }
14
- static _test(data, key){
15
- var b = Buffer.from(data.replaceAll(" ",""),"hex")
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
- b = d.decrypt(b)
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
- initSchema(){
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.secondary.voltage"
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 async identify(device){
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
- static async identify(device){
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 async identify(device){
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
- static async identify(device){
7
- return await this.identifyMode(device, 0x03)
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
- static async identify(device){
9
- return await this.identifyMode(device, 0x06)
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 async identify(device){
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 async identify(device){
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 async identify(device){
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 async identify(device){
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 async identify(device){
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 async identify(device){
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;