@mschaeffler/node-red-bthome 0.1.0 → 0.1.2
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/README.md +69 -9
- package/bthome.html +9 -4
- package/bthome.js +1 -1
- package/examples/bthome.json +137 -0
- package/examples/bthome.png +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,21 +29,81 @@ $ npm install @mschaeffler/node-red-bthome
|
|
|
29
29
|
|
|
30
30
|
|msg. | type | description |
|
|
31
31
|
|:-------|:-------|:----------------------------------|
|
|
32
|
-
|
|
|
33
|
-
|payload | | payload for the output message |
|
|
32
|
+
|payload | object | data from Shelly script|
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
### msg.payload
|
|
35
|
+
|
|
36
|
+
Only the first two values are needed, the others are optional.
|
|
37
|
+
|
|
38
|
+
|msg.payload| type | description |
|
|
39
|
+
|:----------|:-------|:----------------------------------|
|
|
40
|
+
|addr | string |mac of the BT-Home device (needed) |
|
|
41
|
+
|data | array of bytes|raw BT-Home message (needed) |
|
|
42
|
+
|rssi | number |signal strength |
|
|
43
|
+
|time | number |Javscript timestamp of the reception |
|
|
44
|
+
|gateway | string |name of the geteway |
|
|
45
|
+
|
|
46
|
+
This is an example of such a message payload:
|
|
47
|
+
```
|
|
48
|
+
{
|
|
49
|
+
"addr": "11:22:33:44:55:66",
|
|
50
|
+
"rssi": -85,
|
|
51
|
+
"time": 1745395033113,
|
|
52
|
+
"gateway": "Shelly Gateway",
|
|
53
|
+
"data": [68,0,164,1,100,46,56,69,43,255]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Outputs
|
|
58
|
+
|
|
59
|
+
There are two output ports:
|
|
60
|
+
1. one for meassurement values (states)
|
|
61
|
+
2. one for actions done with the devices (events)
|
|
62
|
+
|
|
63
|
+
### State
|
|
64
|
+
|
|
65
|
+
|msg. | type | description |
|
|
66
|
+
|:-------|:-------|:----------------------------------|
|
|
67
|
+
|topic | string | State-Prefix + name of the device|
|
|
68
|
+
|payload | object | decoded state data|
|
|
69
|
+
|
|
70
|
+
### Events
|
|
36
71
|
|
|
37
72
|
|msg. | type | description |
|
|
38
73
|
|:-------|:-------|:----------------------------------|
|
|
39
|
-
|topic | string |
|
|
40
|
-
|payload |
|
|
74
|
+
|topic | string | Event-Prefix + name of the device|
|
|
75
|
+
|payload | object | data of the decoded event|
|
|
41
76
|
|
|
42
77
|
## Parameters
|
|
43
78
|
|
|
44
|
-
|config| type | description |
|
|
45
|
-
|
|
46
|
-
|
|
|
79
|
+
|config | type | description |
|
|
80
|
+
|:------------|:-------|:----------------------------------|
|
|
81
|
+
|Devices | JSON | configuration of the BT-Home devices |
|
|
82
|
+
|Status-Prefix| string | prefix for the topic for state output |
|
|
83
|
+
|Event-Prefix | string | prefix for the topic for event output |
|
|
84
|
+
|Context-Variable| string | name of the variable in flow context storage |
|
|
85
|
+
|Contextstore | string | context store to be used |
|
|
86
|
+
|
|
87
|
+
### Device-Configuration
|
|
88
|
+
|
|
89
|
+
With this JSON string the installed [BT-Home](https://bthome.io) devices are configured:
|
|
90
|
+
```
|
|
91
|
+
{
|
|
92
|
+
"<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
An example for such a config from the unit tests:
|
|
97
|
+
```
|
|
98
|
+
{
|
|
99
|
+
"11:22:33:44:55:66": { "topic": "dev_unencrypted_1" },
|
|
100
|
+
"00:01:02:03:04:05": { "topic": "dev_unencrypted_2" },
|
|
101
|
+
"00:10:20:30:40:50": { "topic": "dev_encrypted_1", "key": "00112233445566778899AABBCCDDEEFF" },
|
|
102
|
+
"00:00:00:00:00:00": { "topic": "dev_encrypted_2", "key": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] }
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Context storage
|
|
47
107
|
|
|
48
108
|
## Example Flow
|
|
49
109
|
|
|
@@ -55,4 +115,4 @@ $ npm install @mschaeffler/node-red-bthome
|
|
|
55
115
|
|
|
56
116
|
## License
|
|
57
117
|
|
|
58
|
-
|
|
118
|
+
LGPL-2.1
|
package/bthome.html
CHANGED
|
@@ -7,20 +7,21 @@
|
|
|
7
7
|
devices:{value:"[]",required:true},
|
|
8
8
|
statusPrefix:{value:""},
|
|
9
9
|
eventPrefix:{value:""},
|
|
10
|
+
contextVar:{value:"bthome",required:true},
|
|
10
11
|
contextStore:{value:"",required:true}
|
|
11
12
|
},
|
|
12
13
|
inputs:1,
|
|
13
|
-
outputs:
|
|
14
|
+
outputs:2,
|
|
14
15
|
icon: "bthome.png",
|
|
15
16
|
label: function() {
|
|
16
|
-
return this.name||"
|
|
17
|
+
return this.name||"BT-Home";
|
|
17
18
|
},
|
|
18
19
|
labelStyle: function() {
|
|
19
20
|
return this.name?"node_label_italic":"";
|
|
20
21
|
},
|
|
21
22
|
paletteLabel: "bthome",
|
|
22
|
-
inputLabels: 'bthome frame',
|
|
23
|
-
outputLabels: '
|
|
23
|
+
inputLabels: 'raw bthome frame',
|
|
24
|
+
outputLabels: ['state output','event output'],
|
|
24
25
|
oneditprepare: function() {
|
|
25
26
|
const node = this;
|
|
26
27
|
$("#node-input-devices").typedInput({
|
|
@@ -61,6 +62,10 @@
|
|
|
61
62
|
<label for="node-input-eventPrefix"><i class="fa fa-star-o"></i> Event-Prefix</label>
|
|
62
63
|
<input type="text" id="node-input-eventPrefix"></input>
|
|
63
64
|
</div>
|
|
65
|
+
<div class="form-row">
|
|
66
|
+
<label for="node-input-contextVar"><i class="fa fa-database"></i> Context-Variable</label>
|
|
67
|
+
<input type="text" id="node-input-contextVar"></input>
|
|
68
|
+
</div>
|
|
64
69
|
<div class="form-row">
|
|
65
70
|
<label for="node-input-contextStore"><i class="fa fa-database"></i> Contextstore</label>
|
|
66
71
|
<select type="text" id="node-input-contextStore"></select>
|
package/bthome.js
CHANGED
package/examples/bthome.json
CHANGED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "3a9fcdbd98993dbc",
|
|
4
|
+
"type": "mqtt in",
|
|
5
|
+
"z": "8e0e9a167c607864",
|
|
6
|
+
"name": "",
|
|
7
|
+
"topic": "node-red/bleraw",
|
|
8
|
+
"qos": "0",
|
|
9
|
+
"datatype": "json",
|
|
10
|
+
"broker": "66b8b47e.0f87bc",
|
|
11
|
+
"nl": false,
|
|
12
|
+
"rap": true,
|
|
13
|
+
"rh": 0,
|
|
14
|
+
"inputs": 0,
|
|
15
|
+
"x": 140,
|
|
16
|
+
"y": 1460,
|
|
17
|
+
"wires": [
|
|
18
|
+
[
|
|
19
|
+
"c4df490573c18fc4"
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "c4df490573c18fc4",
|
|
25
|
+
"type": "bthome",
|
|
26
|
+
"z": "8e0e9a167c607864",
|
|
27
|
+
"name": "",
|
|
28
|
+
"devices": "{\"11:22:33:44:55:66\":{\"topic\":\"dev_unencrypted_1\"},\"00:01:02:03:04:05\":{\"topic\":\"dev_unencrypted_2\"},\"00:10:20:30:40:50\":{\"topic\":\"dev_encrypted_1\",\"key\":\"00112233445566778899AABBCCDDEEFF\"},\"00:00:00:00:00:00\":{\"topic\":\"dev_encrypted_2\",\"key\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}}",
|
|
29
|
+
"statusPrefix": "Status",
|
|
30
|
+
"eventPrefix": "Event",
|
|
31
|
+
"contextVar": "bt-home",
|
|
32
|
+
"contextStore": "memoryOnly",
|
|
33
|
+
"x": 340,
|
|
34
|
+
"y": 1440,
|
|
35
|
+
"wires": [
|
|
36
|
+
[
|
|
37
|
+
"3c9fee837ed43fc0"
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"26ebe1833f97c4d4"
|
|
41
|
+
]
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "3c9fee837ed43fc0",
|
|
46
|
+
"type": "debug",
|
|
47
|
+
"z": "8e0e9a167c607864",
|
|
48
|
+
"name": "debug 9",
|
|
49
|
+
"active": true,
|
|
50
|
+
"tosidebar": true,
|
|
51
|
+
"console": false,
|
|
52
|
+
"tostatus": false,
|
|
53
|
+
"complete": "false",
|
|
54
|
+
"statusVal": "",
|
|
55
|
+
"statusType": "auto",
|
|
56
|
+
"x": 520,
|
|
57
|
+
"y": 1420,
|
|
58
|
+
"wires": []
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "26ebe1833f97c4d4",
|
|
62
|
+
"type": "debug",
|
|
63
|
+
"z": "8e0e9a167c607864",
|
|
64
|
+
"name": "debug 10",
|
|
65
|
+
"active": true,
|
|
66
|
+
"tosidebar": true,
|
|
67
|
+
"console": false,
|
|
68
|
+
"tostatus": false,
|
|
69
|
+
"complete": "false",
|
|
70
|
+
"statusVal": "",
|
|
71
|
+
"statusType": "auto",
|
|
72
|
+
"x": 520,
|
|
73
|
+
"y": 1460,
|
|
74
|
+
"wires": []
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "e3ad83be53fa3fe3",
|
|
78
|
+
"type": "inject",
|
|
79
|
+
"z": "8e0e9a167c607864",
|
|
80
|
+
"name": "",
|
|
81
|
+
"props": [
|
|
82
|
+
{
|
|
83
|
+
"p": "payload"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"p": "topic",
|
|
87
|
+
"vt": "str"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"repeat": "",
|
|
91
|
+
"crontab": "",
|
|
92
|
+
"once": false,
|
|
93
|
+
"onceDelay": 0.1,
|
|
94
|
+
"topic": "",
|
|
95
|
+
"payload": "{\"addr\":\"11:22:33:44:55:66\",\"rssi\":-85,\"time\":1745395033113,\"gateway\":\"Shelly Gateway\",\"data\":[68,0,164,1,100,46,56,69,43,255]}",
|
|
96
|
+
"payloadType": "json",
|
|
97
|
+
"x": 170,
|
|
98
|
+
"y": 1420,
|
|
99
|
+
"wires": [
|
|
100
|
+
[
|
|
101
|
+
"c4df490573c18fc4"
|
|
102
|
+
]
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "66b8b47e.0f87bc",
|
|
107
|
+
"type": "mqtt-broker",
|
|
108
|
+
"name": "mqtt.lan",
|
|
109
|
+
"broker": "mqtt.lan",
|
|
110
|
+
"port": "1883",
|
|
111
|
+
"clientid": "node-red",
|
|
112
|
+
"autoConnect": false,
|
|
113
|
+
"usetls": false,
|
|
114
|
+
"compatmode": false,
|
|
115
|
+
"protocolVersion": "4",
|
|
116
|
+
"keepalive": "60",
|
|
117
|
+
"cleansession": true,
|
|
118
|
+
"autoUnsubscribe": true,
|
|
119
|
+
"birthTopic": "node-red/online",
|
|
120
|
+
"birthQos": "1",
|
|
121
|
+
"birthRetain": "true",
|
|
122
|
+
"birthPayload": "true",
|
|
123
|
+
"birthMsg": {},
|
|
124
|
+
"closeTopic": "node-red/online",
|
|
125
|
+
"closeQos": "1",
|
|
126
|
+
"closeRetain": "true",
|
|
127
|
+
"closePayload": "false",
|
|
128
|
+
"closeMsg": {},
|
|
129
|
+
"willTopic": "node-red/online",
|
|
130
|
+
"willQos": "1",
|
|
131
|
+
"willRetain": "true",
|
|
132
|
+
"willPayload": "false",
|
|
133
|
+
"willMsg": {},
|
|
134
|
+
"userProps": "",
|
|
135
|
+
"sessionExpiry": ""
|
|
136
|
+
}
|
|
137
|
+
]
|
package/examples/bthome.png
CHANGED
|
Binary file
|