# Msg.topic previously set still appearing

**URL:** <https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364>\
**Category:** General\
**Created:** [8 November 2021 10:13 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364 "2021-11-08T10:13:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoffreydemaagd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoffreydemaagd/32/16248_2.png) [@geoffreydemaagd](https://discourse.nodered.org/u/geoffreydemaagd)\
**Post date:** [8 November 2021 10:13 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/1 "2021-11-08T10:13:16Z")

</div>

The msg.topic seems to be stored in the node but what of you don't want this? But only pushing the topic received by a earlier node in the flow?

When using for example a switch with topic = msg.topic, the topic set before, is still present. If started with the switch, no topic should be mentionned.

Is there a way, besides using for example a newTopic in the payload?

Many thanks

---

<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:** [8 November 2021 10:25 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/2 "2021-11-08T10:25:56Z")

</div>

Why are you worried about what the topic is? If you are using the topic then you need to set it to whatever it needs to be, if you are not using it then usually it will not matter.

If you really need to remove it then the Change node has a Delete option (click the Set dropdown).

---

<div class="post-metadata">

**Author:** ![geoffreydemaagd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoffreydemaagd/32/16248_2.png) [@geoffreydemaagd](https://discourse.nodered.org/u/geoffreydemaagd)\
**Post date:** [8 November 2021 10:30 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/3 "2021-11-08T10:30:32Z")

</div>

Topic is crucial for the behaviour of some home automation. For example when the topic is 'all\_lights\_out' then for example the fan speed should not be changed. But if topic is for example "shower" then fan speed etc should be high. Reset can not be done otherwise I do not know the trigger. Thus an old msg.topic should not be passed if no nodes are setting that topic.  
Change or delete is not a solution.

---

<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 2021 10:35 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/4 "2021-11-08T10:35:16Z")

</div>

Try setting your switches like this if you want a different/no topic when switch is pressed

```auto
[{"id":"45d92381.558c1c","type":"inject","z":"7f59364f045fd16d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"old","payload":"false","payloadType":"bool","x":180,"y":20,"wires":[["48582633.1e76c8"]]},{"id":"48582633.1e76c8","type":"change","z":"7f59364f045fd16d","name":"","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":315,"y":20,"wires":[["22f5fbba.31be4c","57d42838.19bc28"]],"l":false},{"id":"4e3cf3a7.84925c","type":"inject","z":"7f59364f045fd16d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"old","payload":"true","payloadType":"bool","x":180,"y":60,"wires":[["48582633.1e76c8"]]},{"id":"22f5fbba.31be4c","type":"debug","z":"7f59364f045fd16d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":60,"wires":[]},{"id":"57d42838.19bc28","type":"ui_switch","z":"7f59364f045fd16d","name":"","label":"switch","tooltip":"","group":"8b5cde76.edd58","order":9,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"new","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":440,"y":20,"wires":[["22f5fbba.31be4c","48582633.1e76c8"]]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

when the switch is set by incoming it passes the topic old and when you set the switch from the dashboard it passes new

---

<div class="post-metadata">

**Author:** ![geoffreydemaagd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoffreydemaagd/32/16248_2.png) [@geoffreydemaagd](https://discourse.nodered.org/u/geoffreydemaagd)\
**Post date:** [8 November 2021 10:58 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/6 "2021-11-08T10:58:18Z")

</div>

Good idea, but because the value isn't passed anymore the output of the switch isn't triggered anymore. and when enabling the flag pass msg, we are getting an endless loop.

Ok if you link indeed the output of the msg.topic node, but the switch node doesn't show the correct status

---

<div class="post-metadata">

**Author:** ![geoffreydemaagd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoffreydemaagd/32/16248_2.png) [@geoffreydemaagd](https://discourse.nodered.org/u/geoffreydemaagd)\
**Post date:** [8 November 2021 11:08 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/8 "2021-11-08T11:08:15Z")

</div>

When pressing the True inject, the switch stays OFF. I has to be ON.

---

<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 2021 11:10 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/9 "2021-11-08T11:10:01Z")

</div>

Not if set up as in my example, again i ask for you to show a example of your flow that is not working.

---

<div class="post-metadata">

**Author:** ![geoffreydemaagd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoffreydemaagd/32/16248_2.png) [@geoffreydemaagd](https://discourse.nodered.org/u/geoffreydemaagd)\
**Post date:** [8 November 2021 11:14 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/10 "2021-11-08T11:14:52Z")

</div>

Yes you' re right it works in your example, I've done something wrong when implementing this in my flow. Many thanks for the solution

---

<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 2021 11:15 UTC](https://discourse.nodered.org/t/msg-topic-previously-set-still-appearing/53364/11 "2021-11-22T11:15:40Z")

</div>

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