Using device and dashboard templates functionalities, it is possible to automatically create a device and a dashboard for every new Node-RED instance connected to Databoom.
- 1. Creating a device template
- 2. Node-RED configuration
- 3. Transmitting to a template/Device generation
- 4. Creating a dashboard as template model
- 5. Creating a dashboard template
- 6. Set dashboard tempalte in device template
- 7. Configuration complete
1. Creating a device template
The template is the "model" that is used to create all the devices that use it to connect to Databoom. Therefore every new Node-RED will have same settings and signals.
To create a device template:
- Choose the type of device Template Device
- Fill other fields in Info section as you please
- Select type of device MQTT Template Device section
- Add signals to the template, in the example the following signals were added template_signal and template_virtual
- template_virtual is a template of a virtual signal that uses tempate_signal as variable
- Every device created with the template will have the same signals
- Once signals are added to the template it is possible to access their edit page by clicking their labels in the device template view page
- Signals removal must be done in the template edit page, by clickyng the X next to the corresponding label
- Set a project, we use MQTTTest for the example
- Set a data publication topic and a info reception topic, in the example we have data and info
- After all the fields have been filled, the situation should reflect the one in the image:
- For the Node-RED configuration you need to jot:
- the device template token
- signal templates token
- the ClientID
- the Topic where publish data
2. Node-RED configuration
For the example flow you'll need the following blocks; input block inject, output block mqtt and function block function.
![](https://storage.googleapis.com/databoom-support/Node-RED_inject.png)
![](https://storage.googleapis.com/databoom-support/Node-RED_function.png)
![](https://storage.googleapis.com/databoom-support/Node-RED_MQTT.png)
To create a device from a template you can build your diagram as follows (attached at the end of the article)
timestamp block represents a time interval, when it ends a random value is generated to valorize template_signal that is then forwarded to Databoom. Interval value should be greater than 60 seconds, no value is loggend under this threshold.
In prepare-data-to-push block, previously jotted values are required:
- template_signal token (row 8);
- device template token (row 16);
In mqtt-to-databoom block you need to specify MQTT connection fields
- in node properties, the Topic field must be filled with MQTTTest/<user generated unique value>/data. We use NodeRED as user generated unique value (value has to be changed for any other NodeRED instance), so the topic is MQTTTest/NodeRED/data
- by clicking the pencil icon next to the server field, you can access edit window where the Client ID can be specified. Client Id is V9Gg-<user generated unique value>, with NodeRED as user generated unique value it's V9Gg-NodeRED;
- in the Security tab you need to specify credentials for authentication
- username is the same as for Databoom
- the password is an OAuth token generated in Databoom with Publish and Create permissions
- In the side menu Settings -> Credentials, click the Add OAuth button in the OAuth keys box
- To grant an optimal security we advise to generate a different OAuth token for every new template istance
3. Transmitting to a template/Device generation
Once the template in Databoom is created and Node-RED configured, the first communication between the device and the platform automatically creates a device with the same settings of the template.
- The template token followed by the <user generated unique value> is used as description for the new device, so it's 0ay3at2v1i-NodeRED
- Description can be edited from device edit page
4. Creating a dashboard as template model
To create a dashboard template at least a signal of a device generated by a template has to be included in each of its widgets, so they can be subsequently substituted with the signals of other devices generated by the same template.
The example dashboard template_signals is filled with widgets that rapresent the signals template_signal and template_virtual of the device 0ay3at2v1i-NodeRED generated by template.
5. Creating a dashboard template
To generate a template click the + button in the row corresponding to the dashboard created in the previous step in the Dashboard Manager page. By confirming the modal, the template is listed in the dedicated section.
6. Set dashboard template in device template
By accessing the device template edit page, it is possible to set the dashboard template in the Template dashboard field.
7. Configuration complete
Once the dashboard template is set in the device template, configuration is complete. Every new Node-RED instance that is connected to Databoom will automatically have a corresponding device and dashboard.
0 Comments