# \#switch-node

**URL:** https://discourse.nodered.org/tag/switch-node/53.md

[Latest](https://discourse.nodered.org/latest.md) · [Categories](https://discourse.nodered.org/categories.md) · [Tags](https://discourse.nodered.org/tags.md)

---

## [Switch Node: Pass on regexp matches with the msg](https://discourse.nodered.org/t/switch-node-pass-on-regexp-matches-with-the-msg/99936)

<div class="topic-metadata">

**Author:** [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Replies:** 35\
**Last updated:** [14 December 2025 13:06 UTC](https://discourse.nodered.org/t/switch-node-pass-on-regexp-matches-with-the-msg/99936 "2025-12-14T13:06:01Z")

</div>

Hi there, I have this idea .... would it be possible to pass on the matches of a regexp in a switch node? The groupings in my regexp could be attached to the msg object and then used down the line ... instead of me …

---

## [Dashboard switch status](https://discourse.nodered.org/t/dashboard-switch-status/93866)

<div class="topic-metadata">

**Author:** [@horemansp](https://discourse.nodered.org/u/horemansp)\
**Replies:** 8\
**Last updated:** [12 December 2024 16:55 UTC](https://discourse.nodered.org/t/dashboard-switch-status/93866 "2024-12-12T16:55:53Z")

</div>

I was wondering if you can change the switch status via the input msg.payload true/false. My switch is configured to send "led=on" when switched on and "led=off" when switched off. Now I'm looking to control the switch…

---

## [How to add border to switch node](https://discourse.nodered.org/t/how-to-add-border-to-switch-node/92637)

<div class="topic-metadata">

**Author:** [@NodyRed](https://discourse.nodered.org/u/NodyRed)\
**Replies:** 11\
**Last updated:** [28 November 2024 18:46 UTC](https://discourse.nodered.org/t/how-to-add-border-to-switch-node/92637 "2024-11-28T18:46:06Z")

</div>

I'm using a dashboard switch node with icon, but with no label so it can be 1x1 in size. Can I somehow get a border around the 1x1 square so that it would look like a button. A dashboard button has this grey shine aroun…

---

## [Stop Switch Passing through Data](https://discourse.nodered.org/t/stop-switch-passing-through-data/90780)

<div class="topic-metadata">

**Author:** [@cameronjust](https://discourse.nodered.org/u/cameronjust)\
**Replies:** 4\
**Last updated:** [8 September 2024 01:10 UTC](https://discourse.nodered.org/t/stop-switch-passing-through-data/90780 "2024-09-08T01:10:58Z")

</div>

I've had this working for years but something has changed with a recent update where my dimming buttons no longer dim lights. When I press a button I pass the button action through to a "switch" which then routes based …

---

## [Use dynamic context based variable in change node for setting a variable](https://discourse.nodered.org/t/use-dynamic-context-based-variable-in-change-node-for-setting-a-variable/87519)

<div class="topic-metadata">

**Author:** [@psmtvdw](https://discourse.nodered.org/u/psmtvdw)\
**Replies:** 4\
**Last updated:** [29 April 2024 06:02 UTC](https://discourse.nodered.org/t/use-dynamic-context-based-variable-in-change-node-for-setting-a-variable/87519 "2024-04-29T06:02:44Z")

</div>

I have a subflow, inside this subflow I want to use the value of an env variable of this subflow in a change node to write a global variable This is how it looks like (and works succesfully) in a function node: global.…

---

## [Switch Node: Preventing Repeated Execution in Battery Monitoring](https://discourse.nodered.org/t/switch-node-preventing-repeated-execution-in-battery-monitoring/87169)

<div class="topic-metadata">

**Author:** [@Deunan](https://discourse.nodered.org/u/Deunan)\
**Replies:** 3\
**Last updated:** [11 April 2024 18:49 UTC](https://discourse.nodered.org/t/switch-node-preventing-repeated-execution-in-battery-monitoring/87169 "2024-04-11T18:49:00Z")

</div>

I'm extremely new to Node-RED. I'm monitoring the state of charge for a battery via MQTT. I created a switch node with three conditions: \<10, between 10 and 15, and over 15. It works well except for one issue: it keeps e…

---

## [Switch node improvement](https://discourse.nodered.org/t/switch-node-improvement/86870)

<div class="topic-metadata">

**Author:** [@IanAber](https://discourse.nodered.org/u/IanAber)\
**Replies:** 2\
**Last updated:** [31 March 2024 00:32 UTC](https://discourse.nodered.org/t/switch-node-improvement/86870 "2024-03-31T00:32:46Z")

</div>

I have a couple of flows with switch nodes containing multiple outputs. If I hover over an output it will show a tooltip which describes the output but it would be really nice to see an annotation against each output wit…

---

## [Behaviour of switch node not as expected (help needed)](https://discourse.nodered.org/t/behaviour-of-switch-node-not-as-expected-help-needed/85078)

<div class="topic-metadata">

**Author:** [@fnx2k](https://discourse.nodered.org/u/fnx2k)\
**Replies:** 1\
**Last updated:** [31 January 2024 14:03 UTC](https://discourse.nodered.org/t/behaviour-of-switch-node-not-as-expected-help-needed/85078 "2024-01-31T14:03:20Z")

</div>

Hello, I need some help to understand how to handle the switch node/and or the syntax of the msg. My aim is to compare Ta a temperature read from a sensor to a target temperature (Tconsigne). Tconsigne is set via a fl…

---

## [Node red switch](https://discourse.nodered.org/t/node-red-switch/84535)

<div class="topic-metadata">

**Author:** [@mike1976](https://discourse.nodered.org/u/mike1976)\
**Replies:** 4\
**Last updated:** [14 January 2024 20:43 UTC](https://discourse.nodered.org/t/node-red-switch/84535 "2024-01-14T20:43:05Z")

</div>

Hello, Can someone please help me. I would like to create a switch with true and false. It should be true if the msg.payload = "PUT operation successful." He should be bad if: "msg.error time out" Reason: If the t…

---

## [Too stupid to use switch node and/or function with Aqara magic cube T1 Pro :(](https://discourse.nodered.org/t/too-stupid-to-use-switch-node-and-or-function-with-aqara-magic-cube-t1-pro/84102)

<div class="topic-metadata">

**Author:** [@ikarisan](https://discourse.nodered.org/u/ikarisan)\
**Replies:** 27\
**Last updated:** [30 December 2023 10:59 UTC](https://discourse.nodered.org/t/too-stupid-to-use-switch-node-and-or-function-with-aqara-magic-cube-t1-pro/84102 "2023-12-30T10:59:49Z")

</div>

Hi! I hate to admit it, but I'm too stupid for the "switch-node". :frowning: I receive a msg.payload from my new "Aqara magic cube T1 Pro" that contains a msg.payload object with payload.side : int (1...6) payload.ac…

---

## [What is the correct way to use jsonata inside a switch node with "has key" rule?](https://discourse.nodered.org/t/what-is-the-correct-way-to-use-jsonata-inside-a-switch-node-with-has-key-rule/83616)

<div class="topic-metadata">

**Author:** [@alwinter](https://discourse.nodered.org/u/alwinter)\
**Replies:** 12\
**Last updated:** [12 December 2023 00:07 UTC](https://discourse.nodered.org/t/what-is-the-correct-way-to-use-jsonata-inside-a-switch-node-with-has-key-rule/83616 "2023-12-12T00:07:25Z")

</div>

Hi I have the following situation, I want to test if a given msg.payload has some keys. Let's say for example: msg.payload.keyOne msg.payload.keyTwo I know i can check that with a function node, but I'm curious about …

---

## [BUG: Opening the switch node has strange behavior](https://discourse.nodered.org/t/bug-opening-the-switch-node-has-strange-behavior/83320)

<div class="topic-metadata">

**Author:** [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Replies:** 23\
**Last updated:** [2 December 2023 09:45 UTC](https://discourse.nodered.org/t/bug-opening-the-switch-node-has-strange-behavior/83320 "2023-12-02T09:45:33Z")

</div>

When I open the switch node I have strange behavior: Works on Chrome but not on Safari (v17.1) Node-RED v3.1.1

---

## [Switch node jsonata predicate match](https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290)

<div class="topic-metadata">

**Author:** [@stevegroom](https://discourse.nodered.org/u/stevegroom)\
**Replies:** 2\
**Last updated:** [23 October 2023 16:55 UTC](https://discourse.nodered.org/t/switch-node-jsonata-predicate-match/82290 "2023-10-23T16:55:33Z")

</div>

I am trying to get a predicate match in a switch node to look up a device\_ieee and determine the device type - in this case Hue v1 or Hue v2. msg object has been supplemented with roominfo where the device\_ieee can be l…

---

## [Switch node not working for string comparison with 'on'/'off' values](https://discourse.nodered.org/t/switch-node-not-working-for-string-comparison-with-on-off-values/78222)

<div class="topic-metadata">

**Author:** [@ronyn77](https://discourse.nodered.org/u/ronyn77)\
**Replies:** 4\
**Last updated:** [6 May 2023 20:18 UTC](https://discourse.nodered.org/t/switch-node-not-working-for-string-comparison-with-on-off-values/78222 "2023-05-06T20:18:44Z")

</div>

I am trying to use the switch node after a current state node to check whether the device is turned on or off, and based on that value, perform a subsequent operation. Inside the switch node, I am doing a direct comparis…

---

## [How to always use the last item in an array?](https://discourse.nodered.org/t/how-to-always-use-the-last-item-in-an-array/73553)

<div class="topic-metadata">

**Author:** [@network\_potato](https://discourse.nodered.org/u/network_potato)\
**Replies:** 8\
**Last updated:** [19 January 2023 14:25 UTC](https://discourse.nodered.org/t/how-to-always-use-the-last-item-in-an-array/73553 "2023-01-19T14:25:44Z")

</div>

I have a switch node where I check a value. Feeding into this switch node is an array. Sometimes the array consists of 1 item, sometimes 2, sometimes 3, etc. How can I make the switch node always check the last item in…
