I’ve put the toggle code in a subflow. It’s explained here. https://nodered.org/docs/user-guide/editor/workspace/subflows