# Integrate Node-Red

# Integrate BLE sensors, devices and display a dashboard

Prerequisites: node-red, node-red-dashboard

# Broker connection

  • Add a new mqtt in node
  • Click 2 times on it
  • Add a new broker or connect to an existing one (server field)
  • Set the topic like below with the MAC address at the end being the one of the device you want to integrate

NodeRed integration

TIP

The "+" enables to process the data from all the gateways whatever name they have. So you may setup several OpenMQTTGateway, you will not have to change the Node-Red configuration.

This configuration enables to process all the data coming from the sensor.

  • Click on done
  • So as to monitor the traffic coming; you can add a debug node with msg.payload as Output

NodeRed integration

  • Link it to the mqtt in node

NodeRed integration

  • Deploy
  • Open the debug panel
  • You should see messages coming when the gateway will receive data

NodeRed integration

# Json message processing

We need to process the json message so as to extract the value that we want to display.

  • Add a change node
  • Configure it as Move
  • Add the msg value you would like to process example msg.payload.tempc and the target msg.payload

NodeRed integration

  • Connect the change node to the mqtt in node

# Dashboard

You can now add widget so as to display the value processed above

  • Add a gauge node
  • Add a group and organize your dashboard
  • Add your value format to process the payload like below

NodeRed integration

  • Click on Done
  • Deploy
  • Go to your node-red url/ui

You should see the gauge with the last value displayed

NodeRed integration

You can also add easily a chart node:

NodeRed integration

NodeRed integration

Or a function with a notification:

NodeRed integration

# Integrate RF

Here is a simple set of flows for integrating OpenMQTTGateway with NodeRED via an ESP8266 module.

In this example I have used a Wemos D1 Mini with some cheap RF modules.

NodeRed integration

A flow to receive 433MHz signals into NodeRED (you will need to update the IP address of your broker)

NodeRed integration

[
    {
        "id": "6d1b2915.7ce798",
        "type": "mqtt in",
        "z": "a9a9b76b.e69998",
        "name": "433MQTT",
        "topic": "home/OpenMQTTGateway/433toMQTT",
        "qos": "2",
        "broker": "4572f098.cc1",
        "x": 80,
        "y": 740,
        "wires": [
            [
                "fe53b819.4f9568"
            ]
        ]
    },
    {
        "id": "fe53b819.4f9568",
        "type": "debug",
        "z": "a9a9b76b.e69998",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 290,
        "y": 740,
        "wires": []
    },
    {
        "id": "4572f098.cc1",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "192.168.0.56",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": ""
    }
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

A flow to send 433MHz signals from NodeRED

NodeRed integration

[
    {
        "id": "ff924d56.459d6",
        "type": "mqtt out",
        "z": "a9a9b76b.e69998",
        "name": "MQTTto433",
        "topic": "home/OpenMQTTGateway/commands/MQTTto433",
        "qos": "",
        "retain": "",
        "broker": "4572f098.cc1",
        "x": 610,
        "y": 860,
        "wires": []
    },
    {
        "id": "6c25a2d4.6c733c",
        "type": "inject",
        "z": "a9a9b76b.e69998",
        "name": "",
        "topic": "",
        "payload": "On",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 840,
        "wires": [
            [
                "7689fe88.45679"
            ]
        ]
    },
    {
        "id": "a76d2f03.5f3",
        "type": "change",
        "z": "a9a9b76b.e69998",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "5510487",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 380,
        "y": 840,
        "wires": [
            [
                "ff924d56.459d6"
            ]
        ]
    },
    {
        "id": "7689fe88.45679",
        "type": "switch",
        "z": "a9a9b76b.e69998",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "On",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "Off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 210,
        "y": 860,
        "wires": [
            [
                "a76d2f03.5f3"
            ],
            [
                "6a7c2c3a.567794"
            ]
        ]
    },
    {
        "id": "7e52ec9.00dde14",
        "type": "inject",
        "z": "a9a9b76b.e69998",
        "name": "",
        "topic": "",
        "payload": "Off",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 880,
        "wires": [
            [
                "7689fe88.45679"
            ]
        ]
    },
    {
        "id": "6a7c2c3a.567794",
        "type": "change",
        "z": "a9a9b76b.e69998",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "4527444",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 380,
        "y": 880,
        "wires": [
            [
                "ff924d56.459d6"
            ]
        ]
    },
    {
        "id": "20991aea.cca8a6",
        "type": "comment",
        "z": "a9a9b76b.e69998",
        "name": "Set you RF codes here.",
        "info": "",
        "x": 380,
        "y": 800,
        "wires": []
    },
    {
        "id": "4572f098.cc1",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "192.168.0.56",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": ""
    }
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Last Updated: 12/18/2024, 1:55:14 PM