01/08/2024

Systematic Reboot with REST API and Node-RED example

Disclaimer

There are many ways to achieve this result. The REST API end-point can be called inside an app or from outside. Someone may want to create an app that is able to manage this task. In this guide we are going to see how this task can be achieved easily with the web-interface and Node-RED. 

Prerequisites

  • Being able to use REST API with Node-RED
  • Basic REST API comprension

Equipment needed

  • ctrlX CORE with 2.02 or higher.
  • Node-RED installed for the last part.
  • Internet access for the palette.

Test the API

To test the reboot API is quite easy! We need to go to the API page, the link is already on the top-right:

REST API link

Then we need to select the right API category which is "System-API":

System API

What we need to do is to create a "reboot task" but first don't forget to authorize using the Authorize button! 

Authorize Button
We're almost done! We have to find the Task section (1) then move to "Create a new task" (2) and select reboot then click on "Try it out" (3).

Try a task

Clicking on "Execute" the system will send a post containing the reboot request!

REST API example

Now the system is rebooting!

Automatize with Node-RED 

Here is the final code. Really easy, any time that the "cron-plus" or the "inject" nodes emits a signal the device is rebooted.

Node-Red Code

To implement this the "cron-plus" node has been used (just because personally I find it really easy and configurable). To have it we have to install with the palette this extension:

Node-RED Palette Cron

Once we have it the configuration is really easy, just add the node and configure the schedule!

Configure the schedule

I personally use the "Easy Expression Builder" because I am lazy. Anyway, it is really easy to configure and adjust.

Easy Configuration

Easy Configuration Example

Have Fun 😎

1
reboot cron-Node-Red.zip
1.4KB

Latest published/updated articles

Types
How-to
Categories
IOT
Attachments
Project