#NR2V1 : Router Information

Application-Note: #NR2V1 : Router Information

Related Documents:

  • Application-Note: #NR0V1 : Get Node-RED ready on my router
  • Application-Note: #NR1V1 : Hello World
  • https://nodered.org/docs/user-guide/

This application describes how the router information and settings can be used in Node-RED. Router information’s are: Logs, Status of digital Inputs and Outputs, LEDs.

To manage the communication between Node-RED and the router we provide our own node called mbconnect24. This node can be used to get access to the local information of the router but also to communicate between Node-RED and mbCONNECT24 Server (see other application-note: Node-RED & mbCONNECT24).

For this application-note we provide an Example Flow for Node-RED which displays a few information on a Node-RED dashboard and shows how to force the LED FC4 on the router.

Description 1 – Dashboard

This Dashboard displays the LEDs and In-/Outputs as gray and green dots. All this status is also available to control events, like Email, Twitter or messages to industrial communication protocols like S7, Modbus, OPC-UA or MQTT. Everything is connectable through the Node-RED flows. The following picture shows the flow and gives an impression on how it is organized.

Description 2 - Node-RED Flow

On the left side you see the library of Node-RED. These are the available nodes which can be drag&drop to the flow. There are input, output, function and dashboard node. Every input node sends messages on his output-connector to the nodes where he is connected to. We have our own library called "IoT Tools" (red frame). The "cloud" nodes is the connector between Node-RED application and mbCONNECT24. The "device" node can be used to control the router with commands like email, sms, reboot. The third node "fieldbus" is only for devices like mbXLINK who have an build-in fieldbus-processor.

For example the above node “Set FC4” is an input-dashboard-node (switch) which sends a message whenever the switch is pushed on the dashboard. Here a function node “Set FC4 on/off” is connected in between to the cloud-node "mbCONNECT24". Inside this function we transform the message of the switch into an understandable message of the cloud-node "mbCONNECT24". Like “true” will be “1” and “false” will be “0”.

Description 3 - nodes to set the LED

The descripted nodes turns the LED FC4 on or off. The cloud-node "mbCONNECT24" is used as an output here.

 

The cloud-node supports all Tags from the router and the exchange tags of mbCONNECT24:

Description 4 - How to setup the mbCONNECT24 node in Node-RED

Besides the standard Tags which comes with the default configuration, there could also be added user Tags. These have to be added in mbCONNECT24 System-Menu and after synchronizing the router with the server, the Tags will appear in the node for usage. (more in this application-note: Node-RED & mbCONNECT24)

The next part describes how to use the mbconnect24 as an input node. The node sends regualry (every 5 seconds) and update message on his output connector. Within this message all Tags are packed as an message-payload-object (learn more from node-red-guide/messages). To split this message in several messages the node “switch” is used here.

Description 5 - router information to display on dashboard

The switch node has so several outputs for each information it provides. F.e. the function node “Digital Input 1” transform the message payload from “1” to “green” and “0” to “gray” that it is untestable by the LED Di1 node to display the LED color on the dashboard.

 

Step-by-Step for setting LED FC4

Add cloud node, set entry point and select FC4 as the variable

 

Add dashboard switch node.

Create a new Group (ui_group). This will be the selectable group item on the dashboard.

Add function node and write the transformation code

Connect all nodes

Deploy and test

 

Step-by-Step for displaying router information

Add cloud node, set entry point and select FC4 as the variable

 

Add switch node and define the Variable you want to split. Select “msg.topic” and compare with “DIN1” for example

Add function node and write the transformation code

Add dashboard template node for your visual component of an LED

Code:

<style>

.led {

margin: 0 auto;

width: 24px;

height: 24px;

background-color: gray;

border-radius: 50%;

{

</style>

<table>

<tr>

<td>{{msg.topic}}</td>

<td><div class="led" style="background-color:{{msg.payload}}"></div></td>

</tr>

</table>

 

Connect all nodes

Deploy and test

See below the Flow as a file to Import in your application.