bt-sensors-plugin-sk 1.2.0-beta.0.1.2.b → 1.2.0-beta.0.1.4

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/testqueue.js ADDED
@@ -0,0 +1,64 @@
1
+
2
+
3
+ import {createBluetooth} from 'node-ble'
4
+
5
+ import {AutoQueue} from "./Queue.js"
6
+ import {Variant} from 'dbus-next'
7
+
8
+ const {bluetooth, destroy} = createBluetooth()
9
+ const connectQueue = new AutoQueue()
10
+ const adapter = await bluetooth.getAdapter("hci0")
11
+ await adapter.startDiscovery()
12
+
13
+ function deviceConnect(mac) {
14
+
15
+ /* CAUTION: HACK AHEAD
16
+
17
+ Bluez for some cockamamie reason (It's 2025 for chrissake.
18
+ BLUETOOTH ISN'T JUST FOR DESKTOPS ANYMORE, BLUEZ DEVS!)
19
+ SUSPENDS scanning while connected to a device.
20
+
21
+ The next line of code gives the scanner a kick in the arse,
22
+ starting it up again so, I dunno, another device might be able
23
+ to connect and sensor classes could maybe get beacon updates.
24
+
25
+ You know, the little things.
26
+ */
27
+ adapter.waitDevice(mac,(30000)).then((device) =>{
28
+
29
+ return connectQueue.enqueue( async ()=>{
30
+ console.log("Connecting to "+mac)
31
+ try {await device.connect()} catch {(e)=>console.log(e)}
32
+ try {
33
+ console.log("Connected to "+mac)
34
+ console.log("Stopping discovery for "+mac)
35
+
36
+ await adapter.helper.callMethod('StopDiscovery')
37
+ console.log("Discovery stopped for "+mac)
38
+ await adapter.helper.callMethod('SetDiscoveryFilter', {
39
+ Transport: new Variant('s', "le")
40
+ })
41
+ console.log("Starting discovery for "+mac)
42
+ await adapter.helper.callMethod('StartDiscovery')
43
+ console.log("Discovery started for "+mac)
44
+
45
+ } catch (e){
46
+ //probably ignorable error. probably.
47
+ console.log(e)
48
+ }
49
+ })
50
+ })
51
+ /* END HACK*/
52
+ }
53
+ setInterval( ()=>{
54
+ deviceConnect("D1:06:00:C6:16:4A")
55
+ }, 5000)
56
+ setInterval( ()=>{
57
+
58
+ for (const mac of (["D1:06:01:46:49:39","A4:C1:38:3E:7E:94"])){
59
+ try { deviceConnect(mac) } catch { (e)=>console.log(e) }
60
+ }
61
+ }, 10000)
62
+
63
+
64
+
@@ -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
- }