HowTo: Node Red – Execute Action at ServerStart

Depending on how you configure your Node Red installation, it may be practical for it to notify you as soon as Node Red is restarted.
For example, you will be informed about crashes and associated errors in your Node-Red configuration.

How you set up such a status message is explained in the following article.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
So that you can install new nodes, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

NodeRed – Installing NodeRed on the RaspberryPi

Required material:
-no-

Required material:

In the following list you will find all the parts you need to implement this article.


Log into the NodeRed configuration interface

Before you can edit your NodeRed configuration, you must - if activated - first log into the NodeRed configuration interface.

View of the login dialog. Here you have to enter the login data that you specified during the configuration of the login. You can find information about this in the article NodeRed - set up user login.

Node code example

In principle, the server start message “only” consists of an inject node with a tick “Inject once after … seconds then…”. As described, this causes this inject node to be executed after a restart.

Here you can see the configuration of the inject node. By checking “Inject after…” the node will be executed after restarting Node-Red. Delayed execution can also be set in the input field.

The following node code prints a message about the debug node after the restart. The complete configuration is contained in the node code.

Following code

[{"id":"5c21935a.39e70c","type":"inject","z":"8c9f8f17.13eb78","name":"","topic":"","payload":"NodeRed just started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":3530,"y" :240,"wires":[["b3fff434.c1a8c8"]]},{"id":"b3fff434.c1a8c8","type":"debug","z":"8c9f8f17.13eb78","name" :"","active":true,"console":"false","complete":"false","x":3710,"y":240,"wires":[]}]

Node code example with Pushbullet message

A sensible combination is to combine the inject node with a pushbullet node. After a restart of Node-Red, a push bullet message is sent.
This way you'll know when you're on the go whether your Node Red installation may have been restarted.

You can find the node code for this in this example.

[{"id":"a604fa0e.8c5138","type":"pushbullet","z":"8c9f8f17.13eb78","config":"5ab02a71.121594","pushtype":"note","title ":"","chan":"","name":"","x":3470,"y":380,"wires":[]},{"id":"3017f8fc.bcd818", "type":"inject","z":"8c9f8f17.13eb78","name":"","topic":"","payload":"NodeRed has just been started!","payloadType":"str ","repeat":"","crontab":"","once":true,"onceDelay":"","x":3270,"y":380,"wires":[["a604fa0e. 8c5138"]]},{"id":"5ab02a71.121594","type":"pushbullet-config","z":"","name":""}]

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.