translator, wb_editors
4539
правок
Matveevrj (обсуждение | вклад) (Новая страница: «Install the necessary components: <syntaxhighlight lang="bash"> apt update && apt install -y nodejs git make g++ gcc build-essential </syntaxhighlight>») Метки: правка с мобильного устройства правка из мобильной версии |
Matveevrj (обсуждение | вклад) |
||
(не показаны 23 промежуточные версии этого же участника) | |||
Строка 30: | Строка 30: | ||
== Creating a project == | == Creating a project == | ||
To autostart Node-RED, you need to configure the service. To do this, in the <code>/etc/systemd/system/</code> folder, create the <code>nodered.service</code> file: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Строка 36: | Строка 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Then paste the lines into this file: | |||
<pre> | <pre> | ||
[Unit] | [Unit] | ||
Строка 59: | Строка 59: | ||
</pre> | </pre> | ||
Save changes and close the file. Now enable the service and start it with the command: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Строка 65: | Строка 65: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Check the status of the service with the command, the output should contain the line <code>Active: active (running)</code>: | |||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
# systemctl status nodered | # systemctl status nodered | ||
Строка 85: | Строка 85: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | == Delete == | ||
If you no longer need Node-RED, then you can remove it: | |||
# | # Stop, disable and remove the service: | ||
#:<syntaxhighlight lang="bash"> | #:<syntaxhighlight lang="bash"> | ||
systemctl stop nodered && systemctl disable nodered && rm /etc/systemd/system/nodered.service | systemctl stop nodered && systemctl disable nodered && rm /etc/systemd/system/nodered.service | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# | # Remove Node-RED: | ||
#:<syntaxhighlight lang="bash"> | #:<syntaxhighlight lang="bash"> | ||
npm -g remove node-red && npm -g remove node-red-admin && rm -R ~/.node-red | npm -g remove node-red && npm -g remove node-red-admin && rm -R ~/.node-red | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Node.js, | Node.js can also be removed, but make sure you don't have other programs installed that use it, such as zigbee2mqtt. To remove node.js run the command: | ||
:<syntaxhighlight lang="bash"> | :<syntaxhighlight lang="bash"> | ||
apt remove nodejs | apt remove nodejs | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==Node-RED Web Interface== | ||
After starting the service, open a browser and enter the address of your controller on the network and port 1880. | |||
For example: http://192.168.42.1:1880 | |||
Instructions for working with Node-RED can be found at [https://nodered.org/docs/getting-started/ site nodered.org] | |||
== WB Nodes == | == WB Nodes == | ||
[[ | [[File:Installing node-red-contrib-wirenboard.PNG|500px|thumb|right| Installing WB Nodes on a Wiren Board Controller]] | ||
[[Image: nr+wb-settings.png |600px|thumb|right| | [[Image: nr+wb-settings.png |600px|thumb|right|Configuring the connection to the Wiren Board controller]] | ||
To simplify the interaction of Node-RED with the Wiren Board controller, the user [https://support.wirenboard.com/t/node-red-contrib-wirenboard/2019 Andrej_Popov] wrote the module <code>node-red-contrib-wirenboard</code>. | |||
=== | === Installation === | ||
Install it via Node-RED web-interface: | |||
{{Node-RED Installing plugin | {{Node-RED Installing plugin | ||
|search= wirenboard | |search= wirenboard | ||
|name= node-red-contrib-wirenboard | |name= node-red-contrib-wirenboard | ||
|en= true | |||
}} | }} | ||
After installation, the Wiren Board section will appear in the left panel. | |||
=== | === Setting === | ||
After you have installed WB Nodes, you need to set up a connection to the MQTT broker of the Wiren Board controller: | |||
# | # Add a '''WB-input''' node to the workspace, which is located in the left panel, in the '''Wiren Board''' section. | ||
# | # Double click on it, the '''Edit in node''' window will open. | ||
# | # Find the field '''Server''' and click on the pencil button. The '''Add new wirenboard-server config node''' window will open. | ||
# | # Fill in the '''Name''', '''Host''' and '''MQTT Port''' fields. If Node-RED is installed on the controller, enter <code>localhost</code> in the Host field. Enter an arbitrary name in the '''Name''' field, and 1883 in the '''MQTT Port''' field. | ||
# | # Save the server settings by clicking on the '''Done''' button. | ||
# | # Close the '''Edit in node''' window by clicking on '''Cancel'''. | ||
{{note|info| | {{note|info| After setting up the connection, apply the server setting by clicking the '''Deploy''' button on the top right. Only after that the list of channels of the Wiren Board controller will be available.}} | ||
You have set up WB Nodes and can write automations using Node-RED. | |||
=== | === Checking settings === | ||
To check if the settings are correct: | |||
# | # Add any node from the Wiren Board group to the workspace, for example, '''WB-input'''. | ||
# | # Double click on the '''WB-input''' node, the '''Edit in node''' window will open. | ||
# | # In the '''Edit in node''' window, click the '''Refresh Device List''' button. | ||
If the connection is configured correctly, then the drop-down list of the '''Сhannel''' field will display a list of channels available for use. | |||
=== | === Examples === | ||
WB-Nodes comes with examples for [[Node-RED Apple HomeKit | Apple HomeKit]] and Yandex.Alice, you can find them in '''Menu''' → '''Import''' → '''Examples'''. | |||
<gallery mode="packed" heights="200px" caption=" | <gallery mode="packed" heights="200px" caption="Examples from WB-Nodes"> | ||
Image: WB-Nodes Examples 1.png | | Image: WB-Nodes Examples 1.png | List of examples | ||
Image: WB-Nodes Examples 2.png | | Image: WB-Nodes Examples 2.png | Example in workspace | ||
</gallery> | </gallery> | ||
== | == Using the ''mqtt in'' and ''mqtt out'' nodes to interact with the Wiren Board == | ||
=== | === Connection setup === | ||
[[Image: NodeRed_mqtt_nodes.jpg |300px|thumb|right| | [[Image: NodeRed_mqtt_nodes.jpg |300px|thumb|right| MQTT Nodes in Node-Red ]] | ||
An alternative is to use the '''mqtt in''' and '''mqtt out''' nodes. To do this, you need the addresses of the topics, you can get them in the controller web interface on the [[Wiren Board Web Interface#mqtt-channels |MQTT-channels]] page. | |||
To set up an MQTT connection in Node-RED, follow these steps: | |||
# | #Drag the '''mqtt in''' node to the workspace. | ||
# | #Enter the node configuration and click on the '''Pencil''' next to the '''Server''' field. | ||
# | #On the '''Connecting''' tab, set the broker address and port number. | ||
#: | #:In the '''Name''' field, enter any server name. | ||
#: | #:On the '''Security''' tab, you can specify the Username and Password to connect to the broker. If the Wiren Board controller acts as a broker, this field must be left blank. | ||
# | #After filling in all the fields, click the '''Update''' button. The created broker can now be used to set up all connections. | ||
# | #Select the created broker from the list in the '''Server''' field. | ||
# | #Enter mqtt-topic address in the '''Topic''' field. | ||
# | #Press the '''Done''' button. | ||
The '''mqtt out''' node is configured according to the same principle. | |||
<gallery mode="packed" heights="150px" caption=" | <gallery mode="packed" heights="150px" caption="Configuring MQTT Broker (Server)> | ||
Image: NodeRed_mqtt2.jpg | | Image: NodeRed_mqtt2.jpg | ''Connecting'' tab | ||
Image: NodeRed_mqtt3.jpg | Image: NodeRed_mqtt3.jpg | Tab ''Security'' | ||
</gallery> | </gallery> | ||
=== | === Sending commands === | ||
The '''mqtt out''' node is used to send a command to the controller via MQTT. In this case, the '''Topic''' field specifies the address of the mqtt-topic of the controller, in which the parameter must be written. Please note that at the end of the node address '''mqtt out''' you need to write <code>/on</code>, otherwise the parameter will not be written to the topic. For example, <code>/devices/wb-mrgbw-d-fw3_129/controls/RGB Strip/on</code>. Read more on the [[MQTT | MQTT]]. | |||
<gallery mode="packed" heights="150px" caption=" | <gallery mode="packed" heights="150px" caption="Configuring nodes to work with MQTT"> | ||
Image: NodeRed_mqtt4.jpg | | Image: NodeRed_mqtt4.jpg | '''mqtt in''' node configuration example | ||
Image: mqtt_out_no.jpg | Image: mqtt_out_no.jpg | '''mqtt out''' node setup example | ||
Image: NodeRed_mqtt1.jpg | | Image: NodeRed_mqtt1.jpg | Communication via MQTT in Node-Red | ||
</gallery> | </gallery> | ||
To send a parameter to the '''mqtt out''' node, you can use the '''inject''' node. | |||
# | #Drag the '''inject''' node to the workspace. | ||
# | #Connect it to the input of the '''mqtt out''' node. | ||
# | #Go to the settings of the '''inject''' node and set the ''Name'' of the node, the ''Variable Type'' and its ''Value''. Click the '''Done''' button. | ||
<gallery mode="packed" heights="130px"> | <gallery mode="packed" heights="130px"> | ||
Image: Inject1.jpg | | Image: Inject1.jpg | An example of '''inject''' node settings for controlling a discrete parameter | ||
Image: Inject2.jpg | | Image: Inject2.jpg | '''inject''' node retry period setting field | ||
</gallery> | </gallery> | ||
<gallery mode="packed" heights="100px"> | <gallery mode="packed" heights="100px"> | ||
Image: Node_inject.jpg | | Image: Node_inject.jpg | An example of using the '''inject''' node | ||
</gallery> | </gallery> | ||
After setting up input and output, you can process data inside Node-RED and set up the use of third-party services, for example, [[Node-RED_Alice | Smart home with Alice]]. | |||
<gallery mode="packed" heights="150px"> | <gallery mode="packed" heights="150px"> | ||
Image: NodeRed_mqtt5.jpg | | Image: NodeRed_mqtt5.jpg | Alice control example | ||
</gallery> | </gallery> | ||
== | == Usage examples == | ||
Examples of using Node-RED with WB-Nodes on Wiren Board controllers: | |||
* [[Node-RED_Telegram | | * [[Node-RED_Telegram | Telegram bot settings]]. | ||
* [[Node-RED_Alice | | * [[Node-RED_Alice | Setting up Alice on the Wiren Board controller]]. | ||
* [[Node-RED Apple HomeKit | | * [[Node-RED Apple HomeKit | Setting up Apple HomeKit on a Wiren Board controller]]. | ||
* [[Node-RED Dashboards| | * [[Node-RED Dashboards|Creating Dashboards in Node-RED]]. | ||
* [https://youtu.be/cKQmU4LZo4c | * [https://youtu.be/cKQmU4LZo4c Video from our partner: Wiren Board + Node-RED] |