# Stop a node from running

**URL:** <https://discourse.nodered.org/t/stop-a-node-from-running/82714>\
**Category:** General\
**Created:** [8 November 2023 14:20 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714 "2023-11-08T14:20:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![richiep](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@richiep](https://discourse.nodered.org/u/richiep)\
**Post date:** [8 November 2023 14:20 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/1 "2023-11-08T14:20:59Z")

</div>

Hey All,  
I've got a motion sensor that triggers a Light Transition Node which dims down for 3 minutes to a dim level. Then holds at that brightness for 5 minuets at which point it trips the next Light Transition Node which dims it all the way down.

If motion is detected while the second Light Transition Node is running they will both be running causing the light to flicker.

How can I set this up so the second Light Transition Node stops when the motion sensor detects more movement?

```auto
[
    {
        "id": "4e0717ed72f9a962",
        "type": "light-transition",
        "z": "b8865bf6a1a8afeb",
        "name": "",
        "startRGB": "#ff0000",
        "transitionRGB": "#ffc864",
        "endRGB": "#ffffff",
        "startMired": "",
        "endMired": "",
        "transitionTime": "3",
        "transitionTimeUnits": "Minute",
        "steps": "200",
        "startBright": "250",
        "endBright": "5",
        "brightnessType": "Percent",
        "transitionType": "Linear",
        "colorTransitionType": "Weighted",
        "x": 550,
        "y": 440,
        "wires": [
            [
                "88431beee925b54e"
            ],
            []
        ]
    },
    {
        "id": "ebe7b499e58b0fa1",
        "type": "mqtt in",
        "z": "b8865bf6a1a8afeb",
        "name": "",
        "topic": "/shop/motionSensor",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "e8de652f3f0d5685",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 90,
        "y": 480,
        "wires": [
            [
                "21ef253f129e2dac"
            ]
        ]
    },
    {
        "id": "21ef253f129e2dac",
        "type": "switch",
        "z": "b8865bf6a1a8afeb",
        "name": "ON?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "onPirActive",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 270,
        "y": 480,
        "wires": [
            [
                "4a81ebe9ad59f31b",
                "4e0717ed72f9a962",
                "27058b8614cfa4e4",
                "9b3422149211a344"
            ]
        ]
    },
    {
        "id": "4a81ebe9ad59f31b",
        "type": "trigger",
        "z": "b8865bf6a1a8afeb",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "date",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 530,
        "y": 500,
        "wires": [
            [
                "50778a92a191dc0a"
            ]
        ]
    },
    {
        "id": "50778a92a191dc0a",
        "type": "light-transition",
        "z": "b8865bf6a1a8afeb",
        "name": "",
        "startRGB": "#ff0000",
        "transitionRGB": "#ffc864",
        "endRGB": "#ffffff",
        "startMired": "",
        "endMired": "",
        "transitionTime": "1",
        "transitionTimeUnits": "Minute",
        "steps": "10",
        "startBright": "5",
        "endBright": "0",
        "brightnessType": "Percent",
        "transitionType": "Linear",
        "colorTransitionType": "Weighted",
        "x": 550,
        "y": 560,
        "wires": [
            [
                "88431beee925b54e"
            ],
            []
        ]
    },
    {
        "id": "27058b8614cfa4e4",
        "type": "trigger",
        "z": "b8865bf6a1a8afeb",
        "name": "",
        "op1": "",
        "op2": "0",
        "op1type": "nul",
        "op2type": "num",
        "duration": "7",
        "extend": true,
        "overrideDelay": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 530,
        "y": 620,
        "wires": [
            [
                "88431beee925b54e"
            ]
        ]
    },
    {
        "id": "e8de652f3f0d5685",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.1.154",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 November 2023 14:23 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/2 "2023-11-08T14:23:32Z")

</div>

You can use either maintain a flow or global var with a true/false entry and then use a switch node to only allow traffic when the variable is TRUE. Or you could use one of the contributed GATE nodes.

---

<div class="post-metadata">

**Author:** ![richiep](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@richiep](https://discourse.nodered.org/u/richiep)\
**Post date:** [8 November 2023 14:45 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/3 "2023-11-08T14:45:38Z")

</div>

Hmm, I'm doing that with the first switch node. I'm trying to Stop the Light Transition Node when it's already running.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 November 2023 14:57 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/4 "2023-11-08T14:57:19Z")

</div>

According to the read me

> This node will stop running when it has reached the last step. It will send a `msg.payload` of `complete` out of the second output on the node. You can also manually stop the node by sending a `msg.payload` of `stop` or `STOP`. The node will end its loop and send a `msg.payload` of `stopped` out of the second output.

If this is the node in question

> **[node-red-contrib-light-transition](https://flows.nodered.org/node/node-red-contrib-light-transition)**
>
> Transitions a light's color & brightness based on defined settings.

---

<div class="post-metadata">

**Author:** ![richiep](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@richiep](https://discourse.nodered.org/u/richiep)\
**Post date:** [8 November 2023 15:33 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/5 "2023-11-08T15:33:09Z")

</div>

Thanks for reading the manual for me... I'll start there next time.

But seriously, thank you!  
Rich

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 November 2023 15:33 UTC](https://discourse.nodered.org/t/stop-a-node-from-running/82714/6 "2023-11-22T15:33:58Z")

</div>

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