node-red-contrib-relink 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Relink IoT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,144 @@
1
- # Temporary Holding Version
1
+ # Relink for Node-RED
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Put Node-RED on [Relink](https://relink-iot.com). Your flows read and write the same virtual pins as your ESP32, Python or C++ program, watch its camera and hear its microphone. Connect Relink to MQTT, serial ports, databases, webhooks and anything else Node-RED talks to.
4
+
5
+ ![MQTT reading → Relink pin; dashboard pin → serial command to a board](https://relink-iot.com/docs-img/node-red-mqtt-serial.png)
6
+
7
+ Full guide with every example: [relink-iot.com/docs/node-red](https://relink-iot.com/docs/node-red)
8
+
9
+ ## Install
10
+
11
+ In Node-RED: **Menu → Manage palette → Install**, search `node-red-contrib-relink`, then **Install**.
12
+
13
+ Or from your Node-RED folder (normally `~/.node-red`), then restart Node-RED:
14
+
15
+ ```bash
16
+ cd ~/.node-red
17
+ npm install node-red-contrib-relink
18
+ ```
19
+
20
+ Needs Node.js 18+ and Node-RED 3+. No other npm packages. The nodes appear in the **network** group.
21
+
22
+ ## The nodes
23
+
24
+ | Node | What it does |
25
+ |---|---|
26
+ | **relink in** | Sends a message when a pin changes. One pin (`V5`) or all pins (blank). |
27
+ | **relink out** | Writes `msg.payload` to a pin. A fixed pin, or `msg.pin` / `msg.topic` (`V2`). |
28
+ | **relink camera in** | One message per camera frame: `msg.payload` is a JPEG Buffer. |
29
+ | **relink camera out** | Streams JPEG Buffers on a Camera pin, like an ESP32-CAM. |
30
+ | **relink audio in** | Sound from a device: 16-bit samples in a Buffer, `msg.rate` 8000 / 16000 / 48000. |
31
+ | **relink audio out** | Sends 16-bit samples to the devices on this token. |
32
+ | **Relink connection** | Server, device token and encryption key. Nodes using it share one connection. |
33
+
34
+ ## Quick start
35
+
36
+ 1. On [relink-iot.com](https://relink-iot.com), open your device and add a datastream, for example **V0 Float**.
37
+ 2. In Node-RED, drag in **Inject → relink out**. Set the Inject payload to the number `23.5`, and relink out's Pin to `V0`.
38
+ 3. Open relink out, add a **Relink connection**:
39
+
40
+ | Field | Value |
41
+ |---|---|
42
+ | Server | `relink-iot.com` |
43
+ | UDP port | `7445` |
44
+ | API URL | `https://relink-iot.com` (no `/api` at the end) |
45
+ | Device token | From the device page |
46
+ | Encryption key | The device's 64-character key, from the device page |
47
+ | Direct mesh | On |
48
+
49
+ 4. **Deploy**, wait for the status to say **connected**, and click the Inject. The dashboard shows 23.5.
50
+
51
+ To receive, drag in **relink in → Debug**:
52
+
53
+ ```javascript
54
+ {
55
+ topic: "V1",
56
+ pin: 1,
57
+ payload: 42, // number, string or Buffer
58
+ dtype: "int16",
59
+ transport: "p2p", // "p2p" = direct, "relay" = through the server
60
+ checksum: 123456789 // the device id
61
+ }
62
+ ```
63
+
64
+ Use the same token as your ESP32 or program and Node-RED joins that device. The token and key are stored as Node-RED credentials and are never in exported flows.
65
+
66
+ ## Data types
67
+
68
+ relink out picks the type from the payload, unless you choose one. The datastream's type on the device page always wins: a whole number sent to a Float pin arrives as Float.
69
+
70
+ | Type | Payload | Range |
71
+ |---|---|---|
72
+ | Int16 | whole number | −32,768 to 32,767 |
73
+ | Int32 | whole number | −2,147,483,648 to 2,147,483,647 |
74
+ | UInt8 | whole number | 0 to 255 |
75
+ | Float | number | 32-bit float |
76
+ | Double | number | 64-bit float |
77
+ | String | text | up to 255 bytes UTF-8 |
78
+ | ByteArray | Buffer | up to 255 bytes |
79
+
80
+ A value that doesn't fit is refused and goes to a **Catch** node. Nothing is cut off silently.
81
+
82
+ ## Camera and audio
83
+
84
+ Camera frames and sound go directly between Node-RED and the device, never through the server, the same as the ESP32, Python and C++ libraries. On the same network this always works; across the internet it works when both networks allow a direct link.
85
+
86
+ - **relink camera in** asks for frames while deployed. A device streams to one viewer at a time: whoever started last. Send the node any message to take the stream back.
87
+ - **relink camera out** sends only while someone watches (the Android app, or another program). The web dashboard's Live Camera widget needs a browser link, which Node-RED doesn't have.
88
+ - **relink audio in**: Voice (8 kHz), Standard (16 kHz) or High (48 kHz). An ESP32 always sends Voice, so read `msg.rate`.
89
+ - **relink audio out**: any sample rate in `msg.rate`; each listener gets the quality it asked for.
90
+
91
+ Measured against the C++ library on one PC (direct link): camera 60 fps × 60 KB both ways with no lost or damaged frame; audio 50 packets/s at 8 kHz, 100/s at 48 kHz.
92
+
93
+ ## Firewalls and networks
94
+
95
+ - **UDP 7445 blocked:** after 10 s without an answer the connection moves to UDP 443 and keeps trying both.
96
+ - **Direct links through NAT:** Node-RED asks STUN servers for its public addresses and tells the server, so boards and phones can reach it even on networks that use a different public address per destination.
97
+ - **No direct link:** pin values go through the server instead. Only camera and audio need the direct link.
98
+ - **Outage:** the last value per pin is kept and sent when the connection is back. Direct links keep working without the server.
99
+
100
+ ## Examples
101
+
102
+ Import them from **Menu → Import → Examples → node-red-contrib-relink**.
103
+
104
+ **mqtt-serial**: MQTT reading → V28, and V5 from the dashboard → serial command to a board (picture at the top).
105
+
106
+ **schedule**: switch V1 on at 06:00 and off at 06:30 every day.
107
+
108
+ ![Two daily timers write 1 and 0 to V1](https://relink-iot.com/docs-img/node-red-schedule.png)
109
+
110
+ **alert**: when V20 goes above 30, post to a webhook (Discord, Slack, LINE), at most once per 10 minutes.
111
+
112
+ ![V20 above 30 → once per 10 minutes → webhook](https://relink-iot.com/docs-img/node-red-alert.png)
113
+
114
+ **camera-snapshots**: save one JPEG every 2 s from the camera on V10.
115
+
116
+ ![Camera V10 → one frame per 2 s → saved as JPEG](https://relink-iot.com/docs-img/node-red-camera.png)
117
+
118
+ **data-log**: append every pin change to a CSV file.
119
+
120
+ ![All pins → CSV line → relink-log.csv](https://relink-iot.com/docs-img/node-red-data-log.png)
121
+
122
+ **basic** and **bytes**: send and receive a number, and send raw bytes to a ByteArray pin.
123
+
124
+ ## Good to know
125
+
126
+ - Add each pin as a datastream on the device page first. Writes to other pins are refused.
127
+ - The server passes up to 100 writes per second per device. Faster writes to the same pin are merged: the latest value wins. Direct links are not limited.
128
+ - A write to a control pin moves real hardware. Test with a spare device.
129
+ - Numbers are summarised once a minute for the device's history charts.
130
+
131
+ ## Troubleshooting
132
+
133
+ | Problem | Check |
134
+ |---|---|
135
+ | No Relink nodes in the palette | Install in the folder the running Node-RED uses (`~/.node-red`), restart it, search `relink` |
136
+ | Status stays at *connecting* | Token, key, server name, and that the network allows outgoing UDP |
137
+ | No values arrive | The pin is a datastream on the device page; the Pin filter in relink in; Node-RED's own writes don't come back |
138
+ | Camera in shows nothing | The camera is on and on the same token; a direct link is possible; the Android app may have taken the stream |
139
+ | Camera out says *nobody watching* | Open the camera in the Android app or another program on the same token |
140
+ | A write fails | Connect a Catch node: check pin, type and range, and the 255-byte limit for text and Buffers |
141
+
142
+ ## License
143
+
144
+ MIT
@@ -0,0 +1,113 @@
1
+ [
2
+ {
3
+ "id": "relink-alert",
4
+ "type": "tab",
5
+ "label": "Relink — alert",
6
+ "disabled": false,
7
+ "info": "When V20 goes above 30, post one message per 10 minutes to a webhook (LINE, Discord, Slack...). Put your webhook URL in the HTTP request node."
8
+ },
9
+ {
10
+ "id": "al_in",
11
+ "type": "relink in",
12
+ "name": "Tank temp V20",
13
+ "connection": "rl_conn",
14
+ "pin": "V20",
15
+ "x": 150,
16
+ "y": 100,
17
+ "wires": [
18
+ [
19
+ "al_sw"
20
+ ]
21
+ ],
22
+ "z": "relink-alert"
23
+ },
24
+ {
25
+ "id": "al_sw",
26
+ "type": "switch",
27
+ "name": "Above 30 °C",
28
+ "property": "payload",
29
+ "propertyType": "msg",
30
+ "rules": [
31
+ {
32
+ "t": "gt",
33
+ "v": "30",
34
+ "vt": "num"
35
+ }
36
+ ],
37
+ "checkall": "true",
38
+ "repair": false,
39
+ "outputs": 1,
40
+ "x": 340,
41
+ "y": 100,
42
+ "wires": [
43
+ [
44
+ "al_rbe"
45
+ ]
46
+ ],
47
+ "z": "relink-alert"
48
+ },
49
+ {
50
+ "id": "al_rbe",
51
+ "type": "delay",
52
+ "name": "Once per 10 min",
53
+ "pauseType": "rate",
54
+ "timeout": "5",
55
+ "timeoutUnits": "seconds",
56
+ "rate": "1",
57
+ "nbRateUnits": "10",
58
+ "rateUnits": "minute",
59
+ "randomFirst": "1",
60
+ "randomLast": "5",
61
+ "randomUnits": "seconds",
62
+ "drop": true,
63
+ "allowrate": false,
64
+ "outputs": 1,
65
+ "x": 530,
66
+ "y": 100,
67
+ "wires": [
68
+ [
69
+ "al_fn"
70
+ ]
71
+ ],
72
+ "z": "relink-alert"
73
+ },
74
+ {
75
+ "id": "al_fn",
76
+ "type": "function",
77
+ "name": "Alert message",
78
+ "func": "msg.payload = { text: 'Tank is ' + msg.payload + ' °C' };\nreturn msg;",
79
+ "outputs": 1,
80
+ "x": 720,
81
+ "y": 100,
82
+ "wires": [
83
+ [
84
+ "al_http"
85
+ ]
86
+ ],
87
+ "z": "relink-alert"
88
+ },
89
+ {
90
+ "id": "al_http",
91
+ "type": "http request",
92
+ "name": "Webhook (LINE / Discord)",
93
+ "method": "POST",
94
+ "ret": "txt",
95
+ "paytoqs": "ignore",
96
+ "url": "https://example.com/webhook",
97
+ "x": 930,
98
+ "y": 100,
99
+ "wires": [
100
+ []
101
+ ],
102
+ "z": "relink-alert"
103
+ },
104
+ {
105
+ "id": "rl_conn",
106
+ "type": "relink-connection",
107
+ "name": "My Relink device",
108
+ "server": "relink-iot.com",
109
+ "port": 7445,
110
+ "apiBase": "https://relink-iot.com",
111
+ "mesh": true
112
+ }
113
+ ]
@@ -0,0 +1,9 @@
1
+ [
2
+ { "id": "relink-basic", "type": "tab", "label": "Relink basics", "disabled": false, "info": "1. settings: edit the Relink connection with your device token/key; add V0 Float and V1 Integer datastreams. 2. connect: Deploy. 3. handlers: received pins appear in Debug. 4. loop: the Inject sends V0 once a second when enabled." },
3
+ { "id": "relink-device", "type": "relink-connection", "name": "My Relink device", "server": "relink-iot.com", "port": 7445, "apiBase": "https://relink-iot.com", "mesh": true },
4
+ { "id": "relink-in", "type": "relink in", "z": "relink-basic", "name": "Receive all pins", "connection": "relink-device", "pin": "", "x": 180, "y": 120, "wires": [["relink-debug"]] },
5
+ { "id": "relink-debug", "type": "debug", "z": "relink-basic", "name": "Pin values", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 440, "y": 120, "wires": [] },
6
+ { "id": "relink-inject", "type": "inject", "z": "relink-basic", "name": "Send 23.5 on V0", "props": [{"p":"payload"},{"p":"topic","vt":"str"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "V0", "payload": "23.5", "payloadType": "num", "x": 190, "y": 200, "wires": [["relink-out"]] },
7
+ { "id": "relink-out", "type": "relink out", "z": "relink-basic", "name": "Write V0", "connection": "relink-device", "pin": "0", "dtype": "float", "x": 450, "y": 200, "wires": [] },
8
+ { "id": "relink-catch", "type": "catch", "z": "relink-basic", "name": "Write errors", "scope": ["relink-out"], "uncaught": false, "x": 190, "y": 280, "wires": [["relink-debug"]] }
9
+ ]
@@ -0,0 +1,8 @@
1
+ [
2
+ { "id": "relink-bytes", "type": "tab", "label": "Relink ByteArray", "disabled": false, "info": "1. settings: declare V2 ByteArray on a test device and fill in the connection credentials. 2. connect: Deploy. 3. handlers: Debug shows received Buffers. 4. loop: click Inject to send bytes; no automatic writes." },
3
+ { "id": "relink-bytes-device", "type": "relink-connection", "name": "My Relink device", "server": "relink-iot.com", "port": 7445, "apiBase": "https://relink-iot.com", "mesh": true },
4
+ { "id": "relink-bytes-in", "type": "relink in", "z": "relink-bytes", "name": "Receive V2 bytes", "connection": "relink-bytes-device", "pin": "2", "x": 180, "y": 100, "wires": [["relink-bytes-debug"]] },
5
+ { "id": "relink-bytes-debug", "type": "debug", "z": "relink-bytes", "name": "Binary buffer", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "x": 450, "y": 100, "wires": [] },
6
+ { "id": "relink-bytes-inject", "type": "inject", "z": "relink-bytes", "name": "Send 00 ff 80 01", "props": [{"p":"payload"},{"p":"topic","vt":"str"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "V2", "payload": "[0,255,128,1]", "payloadType": "bin", "x": 190, "y": 180, "wires": [["relink-bytes-out"]] },
7
+ { "id": "relink-bytes-out", "type": "relink out", "z": "relink-bytes", "name": "Write binary V2", "connection": "relink-bytes-device", "pin": "2", "dtype": "bytes", "x": 450, "y": 180, "wires": [] }
8
+ ]
@@ -0,0 +1,90 @@
1
+ [
2
+ {
3
+ "id": "relink-camera-snapshots",
4
+ "type": "tab",
5
+ "label": "Relink — camera snapshots",
6
+ "disabled": false,
7
+ "info": "Save one JPEG every 2 s from the camera on V10 (ESP32-CAM or another program on this token). Change the folder in the function node."
8
+ },
9
+ {
10
+ "id": "cm_in",
11
+ "type": "relink camera in",
12
+ "name": "Camera V10",
13
+ "connection": "rl_conn",
14
+ "pin": "V10",
15
+ "x": 150,
16
+ "y": 100,
17
+ "wires": [
18
+ [
19
+ "cm_rate"
20
+ ]
21
+ ],
22
+ "z": "relink-camera-snapshots"
23
+ },
24
+ {
25
+ "id": "cm_rate",
26
+ "type": "delay",
27
+ "name": "1 photo per 2 s",
28
+ "pauseType": "rate",
29
+ "timeout": "5",
30
+ "timeoutUnits": "seconds",
31
+ "rate": "1",
32
+ "nbRateUnits": "2",
33
+ "rateUnits": "second",
34
+ "randomFirst": "1",
35
+ "randomLast": "5",
36
+ "randomUnits": "seconds",
37
+ "drop": true,
38
+ "allowrate": false,
39
+ "outputs": 1,
40
+ "x": 350,
41
+ "y": 100,
42
+ "wires": [
43
+ [
44
+ "cm_name"
45
+ ]
46
+ ],
47
+ "z": "relink-camera-snapshots"
48
+ },
49
+ {
50
+ "id": "cm_name",
51
+ "type": "function",
52
+ "name": "File name with time",
53
+ "func": "msg.filename = '/tmp/relink-snaps/cam-' + Date.now() + '.jpg';\nreturn msg;",
54
+ "outputs": 1,
55
+ "x": 560,
56
+ "y": 100,
57
+ "wires": [
58
+ [
59
+ "cm_file"
60
+ ]
61
+ ],
62
+ "z": "relink-camera-snapshots"
63
+ },
64
+ {
65
+ "id": "cm_file",
66
+ "type": "file",
67
+ "name": "Save JPEG",
68
+ "filename": "filename",
69
+ "filenameType": "msg",
70
+ "appendNewline": false,
71
+ "createDir": true,
72
+ "overwriteFile": "true",
73
+ "encoding": "none",
74
+ "x": 760,
75
+ "y": 100,
76
+ "wires": [
77
+ []
78
+ ],
79
+ "z": "relink-camera-snapshots"
80
+ },
81
+ {
82
+ "id": "rl_conn",
83
+ "type": "relink-connection",
84
+ "name": "My Relink device",
85
+ "server": "relink-iot.com",
86
+ "port": 7445,
87
+ "apiBase": "https://relink-iot.com",
88
+ "mesh": true
89
+ }
90
+ ]
@@ -0,0 +1,65 @@
1
+ [
2
+ {
3
+ "id": "relink-data-log",
4
+ "type": "tab",
5
+ "label": "Relink — data log",
6
+ "disabled": false,
7
+ "info": "Append every pin change to relink-log.csv: time, pin, value, transport."
8
+ },
9
+ {
10
+ "id": "lg_in",
11
+ "type": "relink in",
12
+ "name": "All pins",
13
+ "connection": "rl_conn",
14
+ "pin": "",
15
+ "x": 140,
16
+ "y": 100,
17
+ "wires": [
18
+ [
19
+ "lg_fn"
20
+ ]
21
+ ],
22
+ "z": "relink-data-log"
23
+ },
24
+ {
25
+ "id": "lg_fn",
26
+ "type": "function",
27
+ "name": "CSV line",
28
+ "func": "const v = Buffer.isBuffer(msg.payload) ? msg.payload.toString('hex') : msg.payload;\nmsg.payload = [new Date().toISOString(), msg.topic, v, msg.transport].join(',');\nreturn msg;",
29
+ "outputs": 1,
30
+ "x": 320,
31
+ "y": 100,
32
+ "wires": [
33
+ [
34
+ "lg_file"
35
+ ]
36
+ ],
37
+ "z": "relink-data-log"
38
+ },
39
+ {
40
+ "id": "lg_file",
41
+ "type": "file",
42
+ "name": "relink-log.csv",
43
+ "filename": "relink-log.csv",
44
+ "filenameType": "str",
45
+ "appendNewline": true,
46
+ "createDir": true,
47
+ "overwriteFile": "false",
48
+ "encoding": "none",
49
+ "x": 510,
50
+ "y": 100,
51
+ "wires": [
52
+ []
53
+ ],
54
+ "z": "relink-data-log"
55
+ },
56
+ {
57
+ "id": "rl_conn",
58
+ "type": "relink-connection",
59
+ "name": "My Relink device",
60
+ "server": "relink-iot.com",
61
+ "port": 7445,
62
+ "apiBase": "https://relink-iot.com",
63
+ "mesh": true
64
+ }
65
+ ]
@@ -0,0 +1,139 @@
1
+ [
2
+ {
3
+ "id": "relink-mqtt-serial",
4
+ "type": "tab",
5
+ "label": "Relink — MQTT and serial bridge",
6
+ "disabled": false,
7
+ "info": "1. settings: open the Relink connection, enter your device token and key; add V28 Integer and V5 Integer datastreams. Set the MQTT broker and the serial port. 2. connect: Deploy. 3. handlers: a V5 change on the dashboard goes to the board as \"f <n>\". 4. loop: every MQTT reading on factory/line1/temp lands on V28."
8
+ },
9
+ {
10
+ "id": "pr_mqtt",
11
+ "type": "mqtt in",
12
+ "z": "relink-mqtt-serial",
13
+ "name": "Sensor temperature",
14
+ "topic": "factory/line1/temp",
15
+ "qos": "0",
16
+ "datatype": "auto-detect",
17
+ "broker": "pr_broker",
18
+ "nl": false,
19
+ "rap": true,
20
+ "rh": 0,
21
+ "inputs": 0,
22
+ "x": 170,
23
+ "y": 100,
24
+ "wires": [
25
+ [
26
+ "pr_fn1"
27
+ ]
28
+ ]
29
+ },
30
+ {
31
+ "id": "pr_fn1",
32
+ "type": "function",
33
+ "z": "relink-mqtt-serial",
34
+ "name": "To V28 number",
35
+ "func": "// MQTT gives text or JSON; Relink wants a number on V28\nconst v = typeof msg.payload === 'object' ? msg.payload.temp : Number(msg.payload);\nif (!Number.isFinite(v)) return null;\nmsg.pin = 28;\nmsg.payload = Math.round(v);\nreturn msg;",
36
+ "outputs": 1,
37
+ "x": 400,
38
+ "y": 100,
39
+ "wires": [
40
+ [
41
+ "pr_out"
42
+ ]
43
+ ]
44
+ },
45
+ {
46
+ "id": "pr_out",
47
+ "type": "relink out",
48
+ "z": "relink-mqtt-serial",
49
+ "name": "",
50
+ "connection": "pr_conn",
51
+ "pin": "V28",
52
+ "dtype": "int32",
53
+ "x": 620,
54
+ "y": 100,
55
+ "wires": []
56
+ },
57
+ {
58
+ "id": "pr_in",
59
+ "type": "relink in",
60
+ "z": "relink-mqtt-serial",
61
+ "name": "",
62
+ "connection": "pr_conn",
63
+ "pin": "V5",
64
+ "x": 160,
65
+ "y": 200,
66
+ "wires": [
67
+ [
68
+ "pr_fn2"
69
+ ]
70
+ ]
71
+ },
72
+ {
73
+ "id": "pr_fn2",
74
+ "type": "function",
75
+ "z": "relink-mqtt-serial",
76
+ "name": "Flash → serial command",
77
+ "func": "// V5 slider 0..255 → the board's serial command \"f <n>\"\nconst n = Math.max(0, Math.min(255, Math.round(Number(msg.payload))));\nmsg.payload = 'f ' + n + '\\n';\nreturn msg;",
78
+ "outputs": 1,
79
+ "x": 400,
80
+ "y": 200,
81
+ "wires": [
82
+ [
83
+ "pr_serial"
84
+ ]
85
+ ]
86
+ },
87
+ {
88
+ "id": "pr_serial",
89
+ "type": "serial out",
90
+ "z": "relink-mqtt-serial",
91
+ "name": "ESP32 board",
92
+ "serial": "pr_port",
93
+ "x": 630,
94
+ "y": 200,
95
+ "wires": []
96
+ },
97
+ {
98
+ "id": "pr_conn",
99
+ "type": "relink-connection",
100
+ "name": "My Relink device",
101
+ "server": "relink-iot.com",
102
+ "port": 7445,
103
+ "apiBase": "https://relink-iot.com",
104
+ "mesh": true
105
+ },
106
+ {
107
+ "id": "pr_broker",
108
+ "type": "mqtt-broker",
109
+ "name": "Local broker",
110
+ "broker": "127.0.0.1",
111
+ "port": "1883",
112
+ "clientid": "",
113
+ "autoConnect": true,
114
+ "usetls": false,
115
+ "protocolVersion": "4",
116
+ "keepalive": "60",
117
+ "cleansession": true
118
+ },
119
+ {
120
+ "id": "pr_port",
121
+ "type": "serial-port",
122
+ "name": "",
123
+ "serialport": "/dev/ttyUSB0",
124
+ "serialbaud": "115200",
125
+ "databits": "8",
126
+ "parity": "none",
127
+ "stopbits": "1",
128
+ "waitfor": "",
129
+ "dtr": "none",
130
+ "rts": "none",
131
+ "cts": "none",
132
+ "dsr": "none",
133
+ "newline": "\\n",
134
+ "bin": "false",
135
+ "out": "char",
136
+ "addchar": "",
137
+ "responsetimeout": "10000"
138
+ }
139
+ ]
@@ -0,0 +1,76 @@
1
+ [
2
+ {
3
+ "id": "relink-schedule",
4
+ "type": "tab",
5
+ "label": "Relink — schedule",
6
+ "disabled": false,
7
+ "info": "Switch V1 on at 06:00 and off at 06:30 every day. Add V1 Integer; edit the times in the two Inject nodes."
8
+ },
9
+ {
10
+ "id": "sc_on",
11
+ "type": "inject",
12
+ "name": "Every day 06:00",
13
+ "props": [
14
+ {
15
+ "p": "payload"
16
+ }
17
+ ],
18
+ "repeat": "",
19
+ "crontab": "00 06 * * *",
20
+ "once": false,
21
+ "payload": "1",
22
+ "payloadType": "num",
23
+ "x": 160,
24
+ "y": 80,
25
+ "wires": [
26
+ [
27
+ "sc_out"
28
+ ]
29
+ ],
30
+ "z": "relink-schedule"
31
+ },
32
+ {
33
+ "id": "sc_off",
34
+ "type": "inject",
35
+ "name": "Every day 06:30",
36
+ "props": [
37
+ {
38
+ "p": "payload"
39
+ }
40
+ ],
41
+ "repeat": "",
42
+ "crontab": "30 06 * * *",
43
+ "once": false,
44
+ "payload": "0",
45
+ "payloadType": "num",
46
+ "x": 160,
47
+ "y": 160,
48
+ "wires": [
49
+ [
50
+ "sc_out"
51
+ ]
52
+ ],
53
+ "z": "relink-schedule"
54
+ },
55
+ {
56
+ "id": "sc_out",
57
+ "type": "relink out",
58
+ "name": "Pump V1",
59
+ "connection": "rl_conn",
60
+ "pin": "V1",
61
+ "dtype": "auto",
62
+ "x": 420,
63
+ "y": 120,
64
+ "wires": [],
65
+ "z": "relink-schedule"
66
+ },
67
+ {
68
+ "id": "rl_conn",
69
+ "type": "relink-connection",
70
+ "name": "My Relink device",
71
+ "server": "relink-iot.com",
72
+ "port": 7445,
73
+ "apiBase": "https://relink-iot.com",
74
+ "mesh": true
75
+ }
76
+ ]