Msg.topic previously set still appearing

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

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).

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.

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

[{"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

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

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

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

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

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