bt-sensors-plugin-sk 1.3.6-beta4 → 1.3.6-beta5

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.
@@ -0,0 +1,45 @@
1
+
2
+ function test() {
3
+ const crypto = require("crypto");
4
+ var mac = Buffer.from("A4:C1:38:BA:24:B2".replaceAll(":", ""), "hex");
5
+ var data = Buffer.from(
6
+ "48 59 32 28 2d 81 d0 40 5f 2a 97 38 08 00 00 c9 bd c9 8b".replaceAll(
7
+ " ",
8
+ ""
9
+ ),
10
+ "hex"
11
+ );
12
+ var encryptionKey = Buffer.from("1828296d746bb1abefbf31de8c86fc1e", "hex");
13
+ i = 5;
14
+ const frameControl = data.readUInt16LE(0);
15
+ const isEncrypted = (frameControl >> 3) & 1;
16
+ const encryptionVersion = frameControl >> 12;
17
+ const mesh = (frameControl >> 7) & 1; // mesh device
18
+ const authMode = (frameControl >> 10) & 3;
19
+ const solicited = (frameControl >> 9) & 1;
20
+ const registered = (frameControl >> 8) & 1;
21
+ const objectInclude = (frameControl >> 6) & 1; // object/payload data present
22
+ const capabilityInclude = (frameControl >> 5) & 1; // capability byte present
23
+ const macInclude = (frameControl >> 4) & 1; // MAC address included in payload
24
+ const requestTiming = frameControl & 1;
25
+
26
+ if (capabilityInclude) i++;
27
+ debugger
28
+ const encryptedPayload = data.subarray(i, -7);
29
+ const nonce = Buffer.concat([
30
+ mac.reverse(),
31
+ data.subarray(2, 5),
32
+ data.subarray(-7, -4),
33
+ ]);
34
+ const cipher = crypto.createDecipheriv(
35
+ "aes-128-ccm",
36
+ Buffer.from(encryptionKey, "hex"),
37
+ nonce,
38
+ { authTagLength: 4 }
39
+ );
40
+ cipher.setAAD(Buffer.from("11", "hex"), {
41
+ plaintextLength: encryptedPayload.length,
42
+ });
43
+ cipher.setAuthTag(data.subarray(-4));
44
+ return cipher.update(encryptedPayload);
45
+ }
package/temp.html ADDED
File without changes
package/testxiaomi.js ADDED
@@ -0,0 +1,27 @@
1
+
2
+ const crypto = require("crypto");
3
+
4
+ var mac = Buffer.from("A4:C1:38:BA:24:B2".replaceAll(" ",""), "hex")
5
+ var data=Buffer.from("48 59 32 28 a5 d9 cb 57 68 00 e9 5e 0a 00 00 9b 06 e9 7f".replaceAll(" ", ""),"hex")
6
+ var encryptionKey = Buffer.from("1828296d746bb1abefbf31de8c86fc1e","hex")
7
+ i = 5
8
+ const frameControl = data.readUInt16LE(0)
9
+ const isEncrypted = (frameControl >> 3) & 1
10
+ const encryptionVersion = frameControl >> 12
11
+ const mesh = (frameControl >> 7) & 1; // mesh device
12
+ const authMode = (frameControl >> 10) & 3;
13
+ const solicited = (frameControl >> 9) & 1;
14
+ const registered = (frameControl >> 8) & 1;
15
+ const objectInclude = (frameControl >> 6) & 1; // object/payload data present
16
+ const capabilityInclude = (frameControl >> 5) & 1; // capability byte present
17
+ const macInclude = (frameControl >> 4) & 1; // MAC address included in payload
18
+ const requestTiming = frameControl & 1;
19
+
20
+ if (capabilityInclude) i++
21
+
22
+ const encryptedPayload = data.subarray(i,-7);
23
+ const nonce = Buffer.concat([mac.reverse(), data.subarray(2, 5), data.subarray(-7,-4)]);
24
+ const cipher = crypto.createDecipheriv('aes-128-ccm', Buffer.from(encryptionKey,"hex"), nonce, { authTagLength: 4});
25
+ cipher.setAAD(Buffer.from('11', 'hex'), { plaintextLength: encryptedPayload.length });
26
+ cipher.setAuthTag(data.subarray(-4))
27
+ return cipher.update(encryptedPayload)
@@ -1,2 +0,0 @@
1
- {
2
- }
@@ -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
- }
@@ -1,121 +0,0 @@
1
- {
2
- "configuration": {
3
- "discoveryTimeout": 30,
4
- "discoveryInterval": 0,
5
- "peripherals": [
6
- {
7
- "active": true,
8
- "mac_address": "D4:50:46:39:38:C5",
9
- "discoveryTimeout": 30,
10
- "params": {
11
- "name": "Victron Smart Shunt",
12
- "encryptionKey": "8cce8529307cf9dd0c85611c4fef42d9"
13
- },
14
- "paths": {
15
- "RSSI": "sensors.smartshunt.rssi",
16
- "current": "electrical.battery.house.current",
17
- "power": "electrical.battery.house.power",
18
- "voltage": "electrical.battery.house.voltage",
19
- "alarm": "electrical.battery.house.alarm",
20
- "consumed": "electrical.battery.house.consumedAh",
21
- "soc": "electrical.battery.house.soc",
22
- "ttg": "electrical.battery.house.ttg",
23
- "starterVoltage": "electrical.battery.starter.voltage",
24
- "__state__": "sensors.smartshunt.state"
25
- },
26
- "gattParams": {
27
- "useGATT": false
28
- }
29
- },
30
- {
31
- "active": true,
32
- "mac_address": "F9:B0:6E:63:BC:7E",
33
- "discoveryTimeout": 30,
34
- "params": {
35
- "name": "Ruuvi sensor for cabin"
36
- },
37
- "paths": {
38
- "RSSI": "sensors.ruuviBC7E.rssi",
39
- "temp": "environment.cabin.temperature",
40
- "humidity": "environment.cabin.humidity",
41
- "pressure": "environment.cabin.pressure",
42
- "battV": "sensors.ruuviBC7E.voltage",
43
- "mc": "sensors.ruuviBC7E.movementCounter",
44
- "battery": "sensors.temperature.reefer.batterystrength",
45
- "__state__": "sensors.ruuviBC7E.state"
46
- }
47
- },
48
- {
49
- "active": true,
50
- "mac_address": "49:22:05:17:2B:AE",
51
- "discoveryTimeout": 120,
52
- "params": {
53
- "name": "Inkbird temperature sensor"
54
- },
55
- "paths": {
56
- "RSSI": "sensors.inkbird-th2.rssi",
57
- "temp": "environment.refrigerator.temperature",
58
- "battery": "sensors.inkbird-th2.battery",
59
- "__state__": "sensors.inkbird-th2.state"
60
- }
61
- },
62
- {
63
- "active": true,
64
- "mac_address": "A4:C1:38:9F:F7:7E",
65
- "discoveryTimeout": 300,
66
- "params": {
67
- "name": "ATC Temp/Humidity sensor for Deck",
68
- "parser": "ATC-LE"
69
- },
70
- "paths": {
71
- "RSSI": "sensors.ATC_9FF77E.rssi",
72
- "temp": "environment.deck.temperature",
73
- "humidity": "environment.deck.humidity",
74
- "voltage": "sensors.ATC_9FF77E.voltage",
75
- "batteryStrength": "sensors.ATC_9FF77E.batteryStrength",
76
- "__state__": "sensors.ATC_9FF77E.state"
77
- }
78
- },
79
- {
80
- "active": true,
81
- "mac_address": "D4:40:59:BE:2A:8C",
82
- "discoveryTimeout": 30,
83
- "params": {
84
- "medium": "PROPANE",
85
- "tankHeight": "304.8",
86
- "name": "Galley propane level"
87
- },
88
- "paths": {
89
- "RSSI": "sensors.mopeka-59be8c.rssi",
90
- "battVolt": "sensors.mopeka-59be8c.battery.voltage",
91
- "battStrength": "sensors.mopeka-59be8c.battery.strength",
92
- "temp": "sensors.mopeka-59be8c.temperature",
93
- "tankLevel": "sensors.mopeka-59be8c.tankLevel",
94
- "readingQuality": "sensors.mopeka-59be8c.quality",
95
- "__state__": "sensors.mopeka-59be8c.state"
96
- }
97
- },
98
- {
99
- "active": true,
100
- "mac_address": "A4:C1:38:3E:7E:94",
101
- "discoveryTimeout": 30,
102
- "params": {
103
- "encryptionKey": "3985f4ebc032f276cc316f1f6ecea085",
104
- "__state__": "sensors.xiaomi.state"
105
- },
106
- "paths": {
107
- "RSSI": "sensors.xiaomi.rssi",
108
- "temp": "sensors.xiaomi.temp",
109
- "humidity": "sensors.xiaomi.humidity",
110
- "voltage": "sensors.xiaomi.voltage",
111
- "__state__": "sensors.xiaomi.state"
112
- },
113
- "gattParams": {
114
- "useGATT": false
115
- }
116
- }
117
- ]
118
- },
119
- "enabled": true,
120
- "enableDebug": true
121
- }
@@ -1,14 +0,0 @@
1
- {
2
- "delay":100,
3
- "data":
4
- {
5
- "0x96": [
6
- "55 aa eb 90 10 e0 ac d0 00 00 28 a0 00 00 5a a0 00 00 42 e0 00 00 78 d0 00 00 50 00 00 00 79 d0 00 00 50 a0 00 00 7a d0 00 00 16 d0 00 00 ba 90 00 00 20 bf 20 00 30 00 00 00 3c 00 00 00 20 bf 20 00 2c 10 00 00 3c 00 00 00 1e 00 00 00 d0 70 00 00 bc 20 00 00 58 20 00 00 bc 20 00 00 58 20 00 00 9c ff ff ff 00 00 00 00 20 30 00 00 bc 20 00 00 40 00 00 00 10 00 00 00 10 00 00 00 10 00 00 00 f0 ba 40 00 50 ","00 00 00 5c d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 20 a1 70 00 90 18 f6 00 18 fe ff ff ff 1f a9 6f e0 00 dd e2 00 7b" ],
7
- "0x97":[
8
- "55 aa eb 90 00 3 c4 4a 4b 5f 42 32 41 38 53 32 30 50 00 0 00 0 00 00 00 31 31 2e 58 57 00 00 00 31 31 2e 32 36 31 00 00 68 96 c1 03 18 00 00 00 48 42 31 5f 42 34 00 00 00 00 00 00 00 00 00 00 31 32 33 34 00 00 00 00 00 00 00 00 00 00 00 00 32 33 30 38 31 34 00 00 33 30 32 32 38 34 34 32 36 37 00 30 30 30 30 00 49 6e 70 75 74 20 55 73 65 72 64 61 74 61 00 00 31 32 33 33 32 31 00 00 00 00",
9
- "00 00 00 00 00 00 49 6e 70 75 74 20 55 73 65 72 64 61 74 61 00 00",
10
- "7c f8 ff ff 1f 0d 00 00 00 00 00 00 90 0f 00 00 00 00 c0 d8 03 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
11
- "00 00 00 00 00 00 00 00 00 fe 2f 00 00 00 00 00 00 00 00 00 00 bf"
12
- ]
13
- }
14
- }