# Inject node with multiple payload and topic

**URL:** <https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265>\
**Category:** General\
**Created:** [11 July 2021 10:25 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265 "2021-07-11T10:25:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [11 July 2021 10:25 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/1 "2021-07-11T10:25:58Z")

</div>

Hi

If I need to use an inject node and need to work with two msg.topic where the topic text is:  
zigbee2mqtt/name1/set  
zigbee2mqtt/name2/set

And name1 is using one payload and name2 another payload, how can I make the inject node and send the data to a switch node, so name1/payload1 is send to one output and name2/payload2 is send to another output?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 July 2021 10:32 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/2 "2021-07-11T10:32:47Z")

</div>

The `inject` node will only allow one msg.topic for a single msg.

Why not use two `inject` nodes connecting to the `switch` node?

---

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [11 July 2021 10:43 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/3 "2021-07-11T10:43:37Z")

</div>

Hi Zenofmud

My problem is, that I have a motion detector, when that is "motion=true" then it fires an payload to my alarm to trigger (That is one topic and payload) but then I also need to activate a siren (smoke detector) so I use that to sound an alarm-siren (That's another topic and payload)

So the thats why I think one inject node with to topic, that have a relationship... if i'm using two inject nodes, how can I then trigger inject node 2, if inject node 1 motion is true?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [11 July 2021 11:07 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/4 "2021-07-11T11:07:42Z")

</div>

Wont this work?  
 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75dfa93423ca53a4347cc5a09970ccb14f2d5003.jpeg)

```auto
[{"id":"b63aca45.aa973","type":"inject","z":"f28c9311.213ba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":140,"wires":[["2ba89f82.e7991","94e1cb39.5b633"]]},{"id":"2ba89f82.e7991","type":"change","z":"f28c9311.213ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload1","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"zigbee2mqtt/name1/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":120,"wires":[[]]},{"id":"94e1cb39.5b633","type":"change","z":"f28c9311.213ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload2","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"zigbee2mqtt/name2/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":160,"wires":[[]]}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [11 July 2021 11:10 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/5 "2021-07-11T11:10:45Z")

</div>

Or if you prefer:

 ![Untitled 4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58560186fd1ea0aeed82d5171f3ea3c9fbb872a5.jpeg)

---

<div class="post-metadata">

**Author:** ![tpbillund](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tpbillund/32/37410_2.png) [@tpbillund](https://discourse.nodered.org/u/tpbillund)\
**Post date:** [11 July 2021 11:12 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/6 "2021-07-11T11:12:27Z")

</div>

> [@jbudd](#):
>
> ```auto
> [{"id":"b63aca45.aa973","type":"inject","z":"f28c9311.213ba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":140,"wires":[["2ba89f82.e7991","94e1cb39.5b633"]]},{"id":"2ba89f82.e7991","type":"change","z":"f28c9311.213ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload1","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"zigbee2mqtt/name1/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":120,"wires":[[]]},{"id":"94e1cb39.5b633","type":"change","z":"f28c9311.213ba","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload2","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"zigbee2mqtt/name2/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":160,"wires":[[]]}]
> 
> ```

Thx Jbudd that will work ok.

---

<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:** [25 July 2021 11:12 UTC](https://discourse.nodered.org/t/inject-node-with-multiple-payload-and-topic/48265/7 "2021-07-25T11:12:56Z")

</div>

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