# Switch node labels

**URL:** <https://discourse.nodered.org/t/switch-node-labels/32162>\
**Category:** General\
**Created:** [28 August 2020 16:01 UTC](https://discourse.nodered.org/t/switch-node-labels/32162 "2020-08-28T16:01:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jontron123](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jontron123/32/27996_2.png) [@Jontron123](https://discourse.nodered.org/u/Jontron123)\
**Post date:** [28 August 2020 16:01 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/1 "2020-08-28T16:01:43Z")

</div>

I have a flow that has one input that needs to be switched between about 20 different paths.

When using a single switch node it is very cumbersome to try and follow the flow. I realize you can add labels and then hover over the output. But, when you have as many outputs as I do, trying to find the output you are looking for takes a while. Also when changing/reordering the labels get all out of alignment.

I would like to propose some upgrades to the switch node. I think the labels should be linked to the condition in the properties dialog. Something like this:

![properties](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43de543ad8c33274add9af25f31fc050a1af395a.png)

Also the labels should be displayed on the node itself like this:

![switch_labels](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a5203f1274ce5aa975e8b659997ea3133978f61.png)

Are these changes possible?

---

<div class="post-metadata">

**Author:** ![Jontron123](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jontron123/32/27996_2.png) [@Jontron123](https://discourse.nodered.org/u/Jontron123)\
**Post date:** [28 August 2020 16:02 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/2 "2020-08-28T16:02:22Z")

</div>

Currently I use a bunch of different switch nodes connected to a single input like below:

![multiple_switches](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42fb4eebc94d7f8824a7f2b4b17741c376b8d4b6.png)

Is there maybe a better way to do this, that is just as easy to follow?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 August 2020 16:20 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/3 "2020-08-28T16:20:59Z")

</div>

> [@Jontron123](#):
>
> I have a flow that has one input that needs to be switched between about 20 different paths.

Are you sure you need to do that? Often there are better ways of solving the problem. Can you say why you need to do it?

---

<div class="post-metadata">

**Author:** ![Jontron123](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jontron123/32/27996_2.png) [@Jontron123](https://discourse.nodered.org/u/Jontron123)\
**Post date:** [28 August 2020 16:34 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/4 "2020-08-28T16:34:26Z")

</div>

> [@Colin](#):
>
> Are you sure you need to do that? Often there are better ways of solving the problem. Can you say why you need to do it?

I have 433Mhz remote codes coming in and I need to perform different actions based on which code comes in. Each code has a unique action.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 August 2020 10:47 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/6 "2020-08-29T10:47:39Z")

</div>

I like the idea of this and as an workaround for now, I came up with this idea

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/920ad23689a51b9d4633aae9950f7b0fba3e6c1e.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/90681ec3c397487f3a8fef4924e9d39d8f46372a.png)

I think the downside of your proposal is the editing space taken up by the label

Maybe a compromise would be to have the output dots be evenly spaced instead of clustered in the vertical centre

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fe1545f3fe65a2cf813e383fbdcb5e428f59dfac.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/860400eb2ed70d224cb6c8ba2809406c0e73cc9b.png)

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [29 August 2020 16:59 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/7 "2020-08-29T16:59:12Z")

</div>

> [@cymplecy](#):
>
> evenly spaced

That makes more sense to me. However, if you go ahead with this labeling please make it optional as I prefer the way it is now for my few-output switches. Or maybe an add-on node instead of a replacement.

Thanks

---

<div class="post-metadata">

**Author:** ![Jontron123](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jontron123/32/27996_2.png) [@Jontron123](https://discourse.nodered.org/u/Jontron123)\
**Post date:** [31 August 2020 18:45 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/8 "2020-08-31T18:45:02Z")

</div>

> [@LosinIt](#):
>
> However, if you go ahead with this labeling please make it optional as I prefer the way it is now for my few-output switches.

Maybe an option could be that if all of the label boxes are empty, the look of the node would not change.

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [31 August 2020 18:47 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/9 "2020-08-31T18:47:00Z")

</div>

👆 There ya go

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [1 September 2020 02:25 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/10 "2020-09-01T02:25:05Z")

</div>

Since I'm addicted to mqtt and always have a broker running somewhere, I tend to approach this kind of problem "backward":

 ![Untitled](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/671588f3f8867600c8020fb6966458232d890d81.jpeg)

```auto
[{"id":"638aef5c.e41ba","type":"change","z":"5faee2f.474159c","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":300,"wires":[["43caf8f8.cae2b"]]},{"id":"43caf8f8.cae2b","type":"mqtt out","z":"5faee2f.474159c","name":"","topic":"","qos":"","retain":"","broker":"aab50065.4b5c8","x":450,"y":300,"wires":[]},{"id":"24c70407.2fa1ec","type":"mqtt in","z":"5faee2f.474159c","name":"","topic":"living","qos":"2","datatype":"auto","broker":"27637075.6e9868","x":590,"y":200,"wires":[["5e18a921.3db228"]]},{"id":"898811bf.1bab7","type":"mqtt in","z":"5faee2f.474159c","name":"","topic":"bedroom","qos":"2","datatype":"auto","broker":"27637075.6e9868","x":600,"y":260,"wires":[["1c2136d.9ad2a49"]]},{"id":"bea7aa24.47eac8","type":"mqtt in","z":"5faee2f.474159c","name":"","topic":"outside","qos":"2","datatype":"auto","broker":"27637075.6e9868","x":590,"y":320,"wires":[["dc4986df.54692"]]},{"id":"d1dd3d4f.9c9fa","type":"mqtt in","z":"5faee2f.474159c","name":"all","topic":"+","qos":"2","datatype":"auto","broker":"27637075.6e9868","x":590,"y":380,"wires":[["27254326.693194"]]},{"id":"5e18a921.3db228","type":"debug","z":"5faee2f.474159c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":200,"wires":[]},{"id":"4e9b5251.c8a2dc","type":"inject","z":"5faee2f.474159c","name":"","topic":"","payload":"living","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":260,"wires":[["638aef5c.e41ba"]]},{"id":"1c2136d.9ad2a49","type":"debug","z":"5faee2f.474159c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":260,"wires":[]},{"id":"dc4986df.54692","type":"debug","z":"5faee2f.474159c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":320,"wires":[]},{"id":"27254326.693194","type":"debug","z":"5faee2f.474159c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":380,"wires":[]},{"id":"67bce359.2111a4","type":"inject","z":"5faee2f.474159c","name":"","topic":"","payload":"bedroom","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":300,"wires":[["638aef5c.e41ba"]]},{"id":"b702c972.5e2088","type":"inject","z":"5faee2f.474159c","name":"","topic":"","payload":"outside","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":340,"wires":[["638aef5c.e41ba"]]},{"id":"aab50065.4b5c8","type":"mqtt-broker","z":"","name":"","broker":"pi3plus.local","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"27637075.6e9868","type":"mqtt-broker","z":"","name":"","broker":"pi3plus.local","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]

```

This is almost self-documenting and avoids problems when adding or removing branches.

---

<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:** [31 October 2020 02:25 UTC](https://discourse.nodered.org/t/switch-node-labels/32162/11 "2020-10-31T02:25:11Z")

</div>

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