Kill node red if commands occurring too fast

Hi all

I have a pretty solid flow for my home automation. However, I am still going through a testing phase and there will be times I am away from home.

I would like to kill the node red flow if say 20 commands are triggered within a short time frame, as this would be a bug in the flow and if I am not home, the lights for example may keep flickering on/off and burn out.

Is there a clever way to achieve this?

That is a bit like using a sledgehammer to crack a nut IMO :wink:

Instead, you could add delay nodes (set to rate limit mode) inline?

Or you could add a counter that is reset every 60 seconds. If the counter gets above 20, then set a context flag (e.g. global.inhibit) then use switch nodes inline that test global.inhibit is false.

You could even have an inject set to reset global.inhibit every 30 minutes so things start working again after a cool down period.

There are a ton of other ways you could be smarter about this.

3 Likes

thanks for the reply. I've managed to setup a timer to look for the bug if it happens. I need to restart nodered if this occurs, is there a way to do that within the flow without resorting to command line?

You can use an exec node to run the restart command.

Thanks Colin - sorry for my ignorance but what is the restart command?

I don't want to reboot the whole machine, which I do know how to do.

Since you have not told us what OS and hardware you are running on neither do I know the command.

If it is a Pi then from the command line one would use
node-red-stop
node-red-start
or
node-red-reload

But in an exec node probably better just to restart the service (which is what the above commands end up doing.

sudo systemctl restart nodered

You will need to use sudo visudo to allow that command to run without needing a password to be entered. No doubt google will tell you how to do that.

Thank you - that did the trick!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.