# Switch nodes problem - change nodes when certain value and reset

**URL:** https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367
**Category:** General
**Created:** [7 January 2024 19:36 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367 "2024-01-07T19:36:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 19:36 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/1 "2024-01-07T19:36:05Z")

</div>

Hello All,

I wonder if anyone can help solving this. I can't for the life of me work out a solution.

When the raspberry switch node gets a 0 and it goes to the '66' switch node, I want it to be active until the value is greater than 69 and then switch to the '70' node and reseting to use '66' node when the raspberry node switches to 1.

I hope that makes sense.

Thanks in advance.

 ![Screenshot 2024-01-07 at 19.32.52](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0546c41822c73eceb076cc391e93613d3ebc089.png)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 20:13 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/3 "2024-01-07T20:13:14Z")

</div>

It may help everyone if you did NOT include the `sonoff` nodes.

Also include some `inject` nodes that inject the values _above, below and equal_ to what you are wanting.

That way _we_ can press the `inject` nodes and see what is happening.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 20:17 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/4 "2024-01-07T20:17:42Z")

</div>

Part of the possible problem is the first `switch` node looks at `msg.payload.raspberry`.

The second (mentoined) `switch` node looks at `msg.payload.test`

So unless **BOTH** of those are parts of the message, it won't work.

You seem to be making it complicated.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 20:34 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/5 "2024-01-07T20:34:59Z")

</div>

This may be of use.

I'm not sure.

```auto
[{"id":"9ca02b1571269132","type":"switch","z":"7f2f416d9e78b7fb","name":"Raspberry switch","property":"payload.raspberry","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":470,"wires":[["debe912c9a806cdd","2db82bb311c86903"],[]]},{"id":"545f2b6d0466fb4f","type":"junction","z":"7f2f416d9e78b7fb","x":570,"y":470,"wires":[["9ca02b1571269132","d78b19a8f58e55b5"]]},{"id":"debe912c9a806cdd","type":"switch","z":"7f2f416d9e78b7fb","name":"66","property":"payload.test","propertyType":"msg","rules":[{"t":"btwn","v":"1","vt":"num","v2":"63","v2t":"num"},{"t":"btwn","v":"64","vt":"num","v2":"100","v2t":"num"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":410,"wires":[["9f265664d400cc51","719fac3de4790af6"],["3356f23f37385155","27e3b90516fa3e30"]]},{"id":"2db82bb311c86903","type":"debug","z":"7f2f416d9e78b7fb","name":"debug 306","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.test","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":340,"wires":[]},{"id":"496fd9e9e862e46b","type":"function","z":"7f2f416d9e78b7fb","name":"function 36","func":"let msg1 = {};\n\nlet x = msg.payload;\n\nmsg1.payload = {\"raspberry\":0,\"test\":x};\n\n//node.warn(msg1);\n\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":470,"wires":[["545f2b6d0466fb4f"]]},{"id":"d78b19a8f58e55b5","type":"debug","z":"7f2f416d9e78b7fb","name":"debug 305","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":400,"wires":[]},{"id":"9f265664d400cc51","type":"change","z":"7f2f416d9e78b7fb","name":"payload off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":550,"wires":[["6cc39d704b5f95a1"]]},{"id":"719fac3de4790af6","type":"change","z":"7f2f416d9e78b7fb","name":"payload on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":390,"wires":[["9689cb5b53fb22ea"]]},{"id":"3356f23f37385155","type":"change","z":"7f2f416d9e78b7fb","name":"payload off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":430,"wires":[["9689cb5b53fb22ea"]]},{"id":"27e3b90516fa3e30","type":"change","z":"7f2f416d9e78b7fb","name":"payload on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":510,"wires":[["6cc39d704b5f95a1"]]},{"id":"2c995f110bcb3e56","type":"junction","z":"7f2f416d9e78b7fb","x":320,"y":470,"wires":[["496fd9e9e862e46b"]]},{"id":"1a347da86ce0a986","type":"switch","z":"7f2f416d9e78b7fb","name":"30","property":"payload.test","propertyType":"msg","rules":[{"t":"btwn","v":"1","vt":"num","v2":"30","v2t":"num"},{"t":"btwn","v":"31","vt":"num","v2":"100","v2t":"num"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":530,"wires":[["719fac3de4790af6","9f265664d400cc51"],["3356f23f37385155","27e3b90516fa3e30"]]},{"id":"6cc39d704b5f95a1","type":"debug","z":"7f2f416d9e78b7fb","name":"debug 304","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1300,"y":530,"wires":[]},{"id":"9689cb5b53fb22ea","type":"debug","z":"7f2f416d9e78b7fb","name":"debug 303","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1290,"y":410,"wires":[]},{"id":"7741af307c5dcca9","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"65","payloadType":"num","x":190,"y":410,"wires":[["2c995f110bcb3e56"]]},{"id":"01ae580f9cb43a2e","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"66","payloadType":"num","x":190,"y":450,"wires":[["2c995f110bcb3e56"]]},{"id":"9292b064e410ebf8","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"67","payloadType":"num","x":190,"y":490,"wires":[["2c995f110bcb3e56"]]},{"id":"e98f580ef72ebc4b","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"68","payloadType":"num","x":190,"y":530,"wires":[["2c995f110bcb3e56"]]},{"id":"57523052acf0ef2f","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"69","payloadType":"num","x":190,"y":570,"wires":[["2c995f110bcb3e56"]]},{"id":"6fd47af761d226b6","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"70","payloadType":"num","x":190,"y":610,"wires":[["2c995f110bcb3e56"]]},{"id":"1b91dd0e75f154ab","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"64","payloadType":"num","x":190,"y":370,"wires":[["2c995f110bcb3e56"]]},{"id":"b4e0f6edec31c29e","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"63","payloadType":"num","x":190,"y":330,"wires":[["2c995f110bcb3e56"]]},{"id":"dd9f6d812efd2fe9","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"62","payloadType":"num","x":190,"y":290,"wires":[["2c995f110bcb3e56"]]},{"id":"8e9bab76ff1d0c35","type":"inject","z":"7f2f416d9e78b7fb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"61","payloadType":"num","x":190,"y":250,"wires":[["2c995f110bcb3e56"]]},{"id":"3507a88de0877375","type":"switch","z":"7f2f416d9e78b7fb","name":"70","property":"payload.test","propertyType":"msg","rules":[{"t":"btwn","v":"1","vt":"num","v2":"69","v2t":"num"},{"t":"btwn","v":"70","vt":"num","v2":"100","v2t":"num"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":290,"wires":[[],[]]}]

```

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 22:42 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/6 "2024-01-07T22:42:21Z")

</div>

Hello, thank you very much for the reply.

Sorry that was unclear. I have revised the flow and will upload below.

I don't think I explained what I am trying to do properly.

When 'Raspberry Switch' gets a payload.raspberry 0 and payload.test \<70 it will use switch node '66'

If then 'Raspberry Switch' gets a payload.raspberry 0 and payload.test =\>70 it will use switch node '70' until 'Raspberry Switch' gets a payload.raspberry 1 which then uses '30' and also resets back to switch node '66' next time a payload.raspberry 0 sent.

I hope that makes more sense.

 ![Screenshot 2024-01-07 at 22.27.16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc1d0c2410ab681300500c7e4516e4bf2d63e20f.jpeg)

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 22:43 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/7 "2024-01-07T22:43:10Z")

</div>

```auto
[
    {
        "id": "7f2f416d9e78b7fb",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "9ca02b1571269132",
        "type": "switch",
        "z": "7f2f416d9e78b7fb",
        "name": "Raspberry switch",
        "property": "payload.raspberry",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 450,
        "y": 200,
        "wires": [
            [
                "debe912c9a806cdd"
            ],
            [
                "1a347da86ce0a986"
            ]
        ]
    },
    {
        "id": "debe912c9a806cdd",
        "type": "switch",
        "z": "7f2f416d9e78b7fb",
        "name": "66",
        "property": "payload.test",
        "propertyType": "msg",
        "rules": [
            {
                "t": "btwn",
                "v": "1",
                "vt": "num",
                "v2": "63",
                "v2t": "num"
            },
            {
                "t": "btwn",
                "v": "64",
                "vt": "num",
                "v2": "100",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 670,
        "y": 140,
        "wires": [
            [
                "9f265664d400cc51",
                "719fac3de4790af6"
            ],
            [
                "3356f23f37385155",
                "27e3b90516fa3e30"
            ]
        ]
    },
    {
        "id": "719fac3de4790af6",
        "type": "change",
        "z": "7f2f416d9e78b7fb",
        "name": "payload on 1",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 120,
        "wires": [
            [
                "bd43c590d23e78f1"
            ]
        ]
    },
    {
        "id": "3356f23f37385155",
        "type": "change",
        "z": "7f2f416d9e78b7fb",
        "name": "payload off 2",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 160,
        "wires": [
            [
                "bd43c590d23e78f1"
            ]
        ]
    },
    {
        "id": "27e3b90516fa3e30",
        "type": "change",
        "z": "7f2f416d9e78b7fb",
        "name": "payload on 3",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "on",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 240,
        "wires": [
            [
                "03481e5864a7e85f"
            ]
        ]
    },
    {
        "id": "9f265664d400cc51",
        "type": "change",
        "z": "7f2f416d9e78b7fb",
        "name": "payload off 4",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "off",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 910,
        "y": 280,
        "wires": [
            [
                "03481e5864a7e85f"
            ]
        ]
    },
    {
        "id": "3507a88de0877375",
        "type": "switch",
        "z": "7f2f416d9e78b7fb",
        "name": "70",
        "property": "payload.test",
        "propertyType": "msg",
        "rules": [
            {
                "t": "btwn",
                "v": "1",
                "vt": "num",
                "v2": "69",
                "v2t": "num"
            },
            {
                "t": "btwn",
                "v": "70",
                "vt": "num",
                "v2": "100",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 770,
        "y": 60,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "1a347da86ce0a986",
        "type": "switch",
        "z": "7f2f416d9e78b7fb",
        "name": "30",
        "property": "payload.test",
        "propertyType": "msg",
        "rules": [
            {
                "t": "btwn",
                "v": "1",
                "vt": "num",
                "v2": "30",
                "v2t": "num"
            },
            {
                "t": "btwn",
                "v": "31",
                "vt": "num",
                "v2": "100",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 670,
        "y": 260,
        "wires": [
            [
                "719fac3de4790af6",
                "9f265664d400cc51"
            ],
            [
                "3356f23f37385155",
                "27e3b90516fa3e30"
            ]
        ]
    },
    {
        "id": "c265b105186137a7",
        "type": "inject",
        "z": "7f2f416d9e78b7fb",
        "name": "R0 - 60",
        "props": [
            {
                "p": "payload.raspberry",
                "v": "0",
                "vt": "num"
            },
            {
                "p": "payload.test",
                "v": "60",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "9ca02b1571269132"
            ]
        ]
    },
    {
        "id": "bd43c590d23e78f1",
        "type": "debug",
        "z": "7f2f416d9e78b7fb",
        "name": "debug 306",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 140,
        "wires": []
    },
    {
        "id": "03481e5864a7e85f",
        "type": "debug",
        "z": "7f2f416d9e78b7fb",
        "name": "debug 307",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1110,
        "y": 260,
        "wires": []
    },
    {
        "id": "53f9a4e635f358ec",
        "type": "inject",
        "z": "7f2f416d9e78b7fb",
        "name": "R1 - 60",
        "props": [
            {
                "p": "payload.raspberry",
                "v": "1",
                "vt": "num"
            },
            {
                "p": "payload.test",
                "v": "60",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 400,
        "wires": [
            [
                "9ca02b1571269132"
            ]
        ]
    },
    {
        "id": "f62007c40ba7b4f8",
        "type": "inject",
        "z": "7f2f416d9e78b7fb",
        "name": "R0 - 65",
        "props": [
            {
                "p": "payload.raspberry",
                "v": "0",
                "vt": "num"
            },
            {
                "p": "payload.test",
                "v": "65",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 140,
        "wires": [
            [
                "9ca02b1571269132"
            ]
        ]
    },
    {
        "id": "36f784e373f66a1b",
        "type": "inject",
        "z": "7f2f416d9e78b7fb",
        "name": "R0 - 72",
        "props": [
            {
                "p": "payload.raspberry",
                "v": "0",
                "vt": "num"
            },
            {
                "p": "payload.test",
                "v": "72",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 180,
        "wires": [
            [
                "9ca02b1571269132"
            ]
        ]
    },
    {
        "id": "a75bd4a9ee8a1b78",
        "type": "inject",
        "z": "7f2f416d9e78b7fb",
        "name": "R0 - 30",
        "props": [
            {
                "p": "payload.raspberry",
                "v": "1",
                "vt": "num"
            },
            {
                "p": "payload.test",
                "v": "30",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 360,
        "wires": [
            [
                "9ca02b1571269132"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 22:46 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/8 "2024-01-07T22:46:45Z")

</div>

> [@btbr](#):
>
> If then 'Raspberry Switch' gets a payload.raspberry 0 and payload.test =\>70 it will use switch node '70' until 'Raspberry Switch' gets a payload.raspberry 1

I think the word **UNTIL** is the problem.

The `switch` node works on a message by message basis.

NOT what the last one was, or **UNTIL** something else.

If you are wanting to use the `70`, please wire it in how you think it needs to be done.

(And for me: please only export the nodes, not the entire flow. Each time I import your code it is another tab)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 22:52 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/9 "2024-01-07T22:52:21Z")

</div>

> [@btbr](#):
>
> If then 'Raspberry Switch' gets a payload.raspberry 0 and payload.test =\>70 it will use switch node '70'

This it also a problem because of the `switch` node you call `66`.

![Screenshot from 2024-01-08 09-50-23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/7/47c28234203d7e753ca8f87b22ffc7bbf3eb266d.png)

Where is the test of `=> 70`?

You are saying if `is between 64 and 100` send it to output 2.

So where does the `=> 70` fit in?

Just asking.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 22:58 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/10 "2024-01-07T22:58:54Z")

</div>

That's the issue I cannot think how to wire '70' in. or anyway to make it work. I presume it can be done, but no idea how.

After payload.test gets =\>70 it needs to switch on/off as switch node '70' until the raspberry switch node changes. When raspberry switch node changes back it needs to use '66' again.

payload.test is usually around 65 when raspberry switch node gets its first '0'. This rises every input to around 73 and then drops down again. When it is dropping down I need it to follow '70' not '66'. Then when raspberry switch node changes back I need it to be reset to '66'

Its baffling me how to attempt to do it.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 23:02 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/11 "2024-01-07T23:02:48Z")

</div>

> [@btbr](#):
>
> After payload.test gets =\>70 it needs to switch on/off as switch node '70' until the raspberry switch node changes. When raspberry switch node changes back it needs to use '66' again.

But you haven't shown that in any of the `switch` nodes.

On a side note:  
The flow (screen shot) you posted.

It helps people if you _group_ the `inject` nodes so they make sense.

Something like this:

 ![Screenshot from 2024-01-08 09-57-57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d72bcfc61929c5d9782317394c3ce52b5a6602e.png)

Because you put the `30` at the bottom beside the one which is in an entirely different group/set.

The top two get an `on` and the bottom two get an `off`.

Mixing the `inject` nodes as you did kind of throws confusion into the mix.

Hang on and I will see if I can understand your last post with some code.

# EDIT

Nah, you are really going to have to explain the 0 - 63 and 64 - 100.

What is the importance of this?

Because until I understand what that means, I am not really going to be able help you.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:04 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/12 "2024-01-07T23:04:40Z")

</div>

The two Sonos switches are effecting payload.test number. Payload on 1 making it go up, Payload on 3 slowly stopping it going up and then go down. Payload off 2 and 4 just turning the opposing item off.

I need payload on 3 to start at =\>64 initially, but after going over payload.test =\>70 I need it to turn off when =\<69.9.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 23:06 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/13 "2024-01-07T23:06:46Z")

</div>

Why TWO `sonos` devices?  
One.  
If it is below 69, turn on.  
If it is above 70, turn off.

Or am I still missing something?

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:08 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/14 "2024-01-07T23:08:08Z")

</div>

I'm going to draw it so it makes sense.

Sorry the inject nodes were in the correct place, just didn't see that I labeled one wrong.

 ![Screenshot 2024-01-07 at 23.06.31](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a86fe9260fb4b8486f43c136db0025b60bccf811.jpeg)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 23:12 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/15 "2024-01-07T23:12:54Z")

</div>

> [@btbr](#):
>
> Payload on 3 slowly stopping it going up and then go down. Payload off 2 and 4 just turning the opposing item off.
> 
> I need payload on 3 to start at =\>64 initially, but after going over payload.test =\>70 I need it to turn off

What is/are these `3`, `2` and `4` you are mentioning?

And changing from `payload.test` to `payload.(something else)` isn't helping me understand what you are wanting to do.

## Suggestion:

Forget (for now) that the reading/s sometimes go WAY OUT OF SPEC.  
And forget the second (lower) `debug` node. Just leave it turned off for now.  
You can leave it in the flow, but don't worry about what it is doing.

1 - what is the input range SUPPOSED TO BE? Min-Max  
2 - at what values do you want things to change?  
(Say \< 40 off, =\>40 on)

Just to establish a base line.

## P.S.

This is the only part of the code (and I know I said forget about the flow for now) but to just establish the parts on which we are working now.

 ![Screenshot from 2024-01-08 10-18-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d7f667a4780791c232d5d1f09a1c533683f2bed.png)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 23:27 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/17 "2024-01-07T23:27:47Z")

</div>

Well, I was half way through reading it and you deleted it.

Not helping.

SMALL SUGGESTION:

change `msg.payload.test` to `msg.payload.temp` (or better still `msg.payload.temperature`) if possible.

`test` is not really representing what it is giving you.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:28 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/18 "2024-01-07T23:28:03Z")

</div>

The flow was taken from a larger working flow. The two Sonos devices control two different bits of kit. This is not exactly what it is doing but hopefully this will make it make sense. Drawing didn't work.

Sonos device 1 = debug 306 = Heater

Sonos device 2 = debug 307 = Chiller

payload.test = temp

Raspberry switch (RS)

RS gets 0 goes to '66' 64-100 switches on chiller. Payload.test rises every 15 seconds.

might start at 66 then 69, 71, 73 then it goes back down. 72, 71, 69. It takes a few mins to start chilling properly and rises until it does.

This is fine until it hits 69 when I want the chiller to turn off now and the heater to turn on instead. Switching as per settings in '70'. If it doesn't change it carries on chilling down to whatever '66' is set to.

It can't be just '70' as it doesn't switch on in time.

Hope that is clearer.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:28 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/19 "2024-01-07T23:28:43Z")

</div>

Sorry I realised that I had written heater and chiller the wrong way around.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:29 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/20 "2024-01-07T23:29:51Z")

</div>

I should have done for this you are correct. I should make it as clear as possible. It's hard enough to explain any way.

Sorry and thank you for being patient.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [7 January 2024 23:30 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/21 "2024-01-07T23:30:40Z")

</div>

> [@btbr](#):
>
> RS gets 0 goes to '66' 64-100 switches on chiller. Payload.test rises every 15 seconds.

Confusing.

_gets_....?????

`RS`.....???? Raspberry Switch - ok, you kind of did declare that above, but.....  
gets?

If the temperature is **RISING** every 15 seconds and it is se to CHILL - your words - you have a bigger problem.

or do you mean the temperature VALUE is RECEIVED every 15 seconds?

BIG difference.

---

<div class="post-metadata">

### Author: ![btbr](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@btbr](https://discourse.nodered.org/u/btbr)
#### Post date: [7 January 2024 23:31 UTC](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367/22 "2024-01-07T23:31:34Z")

</div>

Sorry yes value received.

[Next page](https://discourse.nodered.org/t/switch-nodes-problem-change-nodes-when-certain-value-and-reset/84367.md?page=2)
