# Repost State of Mqtt Topic if other Topic's state is 1

**URL:** <https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040>\
**Category:** General\
**Created:** [1 April 2020 15:34 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040 "2020-04-01T15:34:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 15:34 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/1 "2020-04-01T15:34:48Z")

</div>

Hi,  
I've run into a problem: I'd link to have a trigger on an MQTT topic(for ex. TopicY's state is 1 ) that repeats a current topic (TopicX(State: 3)) to topicX like this: [https://imgur.com/a/RtuGcbJ](https://imgur.com/a/RtuGcbJ)  
It is for an AV-Receiver with an Ir Remote build myself. The receiver only wakes up when I switch Channels which sends an Ir command with the Channel I'd like to select. I tried understanding another post, but since I'm a Newbee I can't quite rewrite the code myself. Here is the Thread: [Simple repeat last msg node to re-send MQTT](https://discourse.nodered.org/t/simple-repeat-last-msg-node-to-re-send-mqtt/4558/14)  
Thanks a lot for any Help 🙂

---

<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:** [1 April 2020 15:57 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/2 "2020-04-01T15:57:37Z")

</div>

For future reference you should be able to paste an image directly in here.  
Firstly you need to get both of the inputs together in one message. To do that you can use a Join node in key/value pair mode. See [this post in the cookbook](https://cookbook.nodered.org/basic/join-streams) for how to join the two streams. Have a go at that (start by downloading the example there to see how it works). You will need And Every Subsequent Message ticked in the Join node, I am not sure if that is included in the example or not. You can use the topic coming out of the join node to determine which input has triggered and then setup the message to send to the MQTT Out node.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 16:32 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/3 "2020-04-01T16:32:03Z")

</div>

Thanks a lot for your answer. I'm not quite sure how I should do the last part of your answer:

> You can use the topic coming out of the join node to determine which input has triggered and then set up the message to send to the MQTT Out node.

How should I do this? Do you have any ideas?

---

<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:** [1 April 2020 16:44 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/4 "2020-04-01T16:44:55Z")

</div>

Have you got the first bit going? Feed the output of the Join node into a debug node set to show complete message and see what you get out.  
You can use a Switch node to only pass through messages out of the Join that have the TopicY topic.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 16:50 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/5 "2020-04-01T16:50:04Z")

</div>

Yes, the join node works flawless, but I'm not quite sure how I can switch the topics so that If topic 1 is high that topic 2 is resend

---

<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:** [1 April 2020 17:02 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/6 "2020-04-01T17:02:48Z")

</div>

I realise that for a simple solution you will need two switch nodes (they can probably be combined but get it working with two first) Configure the first to pass on the message to output 1 if the topic is TopicY. That is all you need configure as it means that any other message will be dropped. Then send that to another one that only passes it on if the value of TopicY in the payload is 1. Now you know that if a message is passed on then you need to publish the mqtt out, so use a Change node to setup the topic and payload appropriately and pass it to the MQTT node.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 17:18 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/7 "2020-04-01T17:18:48Z")

</div>

I tried following your instructions as closely as I could, but after the second switch node, nothing gets recognized. Any Ideas why?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db0886d74287921b3ddf56188878425529cd901f.png)

---

<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:** [1 April 2020 18:15 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/8 "2020-04-01T18:15:09Z")

</div>

What are you switching on in the second one? It should actually msg.payload.topicy (or whatever the topic actually is). My previous post seems to have had a mistake that I assume I subconsciously made in order to see if you were paying attention 🙂

If still no joy then post the flow after reading

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<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:** [1 April 2020 19:30 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/10 "2020-04-01T19:30:26Z")

</div>

In the second switch you need to switch on `msg.payload.Sportraum/Av_turnoff == 1` but that isn't valid javascript syntax because it thinks the `/` is a divide symbol. So in the Switch node you have to use `msg.payload["Sportraum/Av_turnoff"]`

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 20:11 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/11 "2020-04-01T20:11:24Z")

</div>

I tried uploading the script, but it needs to be checked, so I try showing you what I did with Pictures:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66ee6c79d464db4d4b7fd4b214c21f326562d586.png)  
Firstly I tried this config for switch 1 and this config for switch 2:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/566c0c9146e29ac616c05b836f98867ce2ddb4e5.png)  
and this as a whole:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/287db59758398f471982da24f7c03c89792a19e3.png)  
but all of this effort does nothing.  
After your message I've as well tied this:  
Conf1:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e2a8747b8563a4fdfd7af73fc4360f72a0b4b8f0.png)  
Conf2:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/5/6564ba1aa2c8cdc3187e26202441f4572b08c7ab.png)  
All:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/a/4a2b0c71d24b2ceeef548f9b0ede5e917db0f181.png)  
But the last config did not return anything at all. I'm very sorry to steal your time that way. I hope you can help me 🤞. Thanks a lot again.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 20:12 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/12 "2020-04-01T20:12:24Z")

</div>

Try Nr.2 Posting the code:

```auto
[{"id":"a2922961.12cbf8","type":"tab","label":"Sportraum 2","disabled":false,"info":""},{"id":"77627e6e.f1c15","type":"mqtt in","z":"a2922961.12cbf8","name":"If Sportraum/Av_turnoff = 1","topic":"Sportraum/Av_turnoff","qos":"0","datatype":"auto","broker":"7f43c1db.c7b8b","x":210,"y":240,"wires":[["a7166a66.6ab018"]]},{"id":"e37cbd7c.725c1","type":"mqtt in","z":"a2922961.12cbf8","name":"Sportraum/Av_input Topic to resend","topic":"Sportraum/Av_input","qos":"0","datatype":"auto","broker":"7f43c1db.c7b8b","x":180,"y":320,"wires":[["a7166a66.6ab018"]]},{"id":"a7166a66.6ab018","type":"join","z":"a2922961.12cbf8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":410,"y":260,"wires":[["f23daef9.1fac7"]]},{"id":"29a376dc.69643a","type":"debug","z":"a2922961.12cbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"Sportraum/Av_turnoff","targetType":"msg","x":810,"y":200,"wires":[]},{"id":"f23daef9.1fac7","type":"switch","z":"a2922961.12cbf8","name":"switch msg.Sportraum/Av_turnoff","property":"Sportraum/Av_turnoff","propertyType":"msg","rules":[{"t":"eq","v":"Sportraum/Av_turnoff","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":320,"wires":[["29a376dc.69643a","92d6c292.fe17c"]]},{"id":"92d6c292.fe17c","type":"switch","z":"a2922961.12cbf8","name":"switch msg.payload[\"Sportraum/Av_turnoff\"]","property":"msg.payload[\"Sportraum/Av_turnoff\"]","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":380,"wires":[["2c12c89a.c71678"],["2c12c89a.c71678"]]},{"id":"2c12c89a.c71678","type":"debug","z":"a2922961.12cbf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":950,"y":280,"wires":[]},{"id":"7f43c1db.c7b8b","type":"mqtt-broker","z":"","name":"192.168.178.15","broker":"192.168.178.15","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<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:** [1 April 2020 20:44 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/13 "2020-04-01T20:44:53Z")

</div>

In the second one you have `msg.msg.payload["..."]`. Should be `msg.payload[".."]`  
It puts the first msg in for you.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 21:07 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/14 "2020-04-01T21:07:03Z")

</div>

One mistake, changing did sadly not help. Maybe the join node is wrong:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff31ec73e194ee4b32a8bbe9a48da8152299764b.png)  
Is this correct? It worked and pasted out both values to the msg.payload debug node.

---

<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:** [1 April 2020 21:13 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/15 "2020-04-01T21:13:11Z")

</div>

Look in a debug node showing the output of the Join node and see what type the value of the trigger (0 or 1) is. Is it a string (it will be be shown with double quotes round it) or a number? In the second Switch you are testing for it to be a string value, but I suspect it should be a number (select 0/9 in the type dropdown).

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [1 April 2020 21:21 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/16 "2020-04-01T21:21:40Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/524f298dca76d1b145790ffd3a87842e316da48b.png)  
That's the output of the debug node. So it is not a string? What else is it when it is not a string?

---

<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:** [2 April 2020 06:22 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/17 "2020-04-02T06:22:19Z")

</div>

It is in quotes so it is a string, not at PC at the moment, will have a look a bit later.

---

<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:** [2 April 2020 07:27 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/18 "2020-04-02T07:27:26Z")

</div>

You had the first switch wrong too, it was supposed to be checking what the topic was. This is working for me. I have replaced the MQTT In with inject nodes for testing and added a Change node to set the topic and payload ready to send to the MQTT Out node.  
Once you are happy that all is working properly you can remove the output 2 test in the second node which was just for checking it is working.

```auto
[{"id":"2af783ff.e1ec6c","type":"debug","z":"d5c4fed6.cd462","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"Sportraum/Av_turnoff","targetType":"msg","x":810,"y":200,"wires":[]},{"id":"e904c3b3.9ee6d","type":"debug","z":"d5c4fed6.cd462","name":"OP 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":814,"y":436,"wires":[]},{"id":"43f567b3.9a1218","type":"debug","z":"d5c4fed6.cd462","name":"OP 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":868,"y":290,"wires":[]},{"id":"222f68fb.5674c8","type":"comment","z":"d5c4fed6.cd462","name":"MQTT Out here","info":"","x":825,"y":478,"wires":[]},{"id":"88708445.b9f158","type":"change","z":"d5c4fed6.cd462","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Sportraum/Av_input","tot":"str"},{"t":"move","p":"payload[\"Sportraum/Av_input\"]","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":601,"y":438,"wires":[["e904c3b3.9ee6d"]]},{"id":"d1fe14e8.baa538","type":"switch","z":"d5c4fed6.cd462","name":"switch msg.payload[\"Sportraum/Av_turnoff\"]","property":"payload[\"Sportraum/Av_turnoff\"]","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":642,"y":353,"wires":[["88708445.b9f158"],["43f567b3.9a1218"]]},{"id":"fd4f5815.711428","type":"switch","z":"d5c4fed6.cd462","name":"switch msg.Sportraum/Av_turnoff","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"Sportraum/Av_turnoff","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":575,"y":276,"wires":[["2af783ff.e1ec6c","d1fe14e8.baa538"]]},{"id":"8fec44bf.38cd88","type":"join","z":"d5c4fed6.cd462","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":355,"y":275,"wires":[["fd4f5815.711428"]]},{"id":"6a81500e.aff508","type":"inject","z":"d5c4fed6.cd462","name":"","topic":"Sportraum/Av_input","payload":"Some Message","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":184,"y":382,"wires":[["8fec44bf.38cd88"]]},{"id":"d1690923.b09c","type":"inject","z":"d5c4fed6.cd462","name":"","topic":"Sportraum/Av_turnoff","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":151,"y":296,"wires":[["8fec44bf.38cd88"]]},{"id":"633b02b0.9c363c","type":"inject","z":"d5c4fed6.cd462","name":"","topic":"Sportraum/Av_turnoff","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":152,"y":259,"wires":[["8fec44bf.38cd88"]]}]

```

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [2 April 2020 09:00 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/19 "2020-04-02T09:00:46Z")

</div>

Thank you for all of your help. It finally works 😄. This is the final code that I use if somebody else wants to use this flow in the future. I had to change a bit to work with my arduino Ir remote(on my github) but now it works:

```auto
[{"id":"a2922961.12cbf8","type":"tab","label":"Sportraum 2","disabled":false,"info":""},{"id":"77627e6e.f1c15","type":"mqtt in","z":"a2922961.12cbf8","name":"If Sportraum/Av_turnoff = 1","topic":"Sportraum/Av_turnoff","qos":"0","datatype":"auto","broker":"7f43c1db.c7b8b","x":250,"y":200,"wires":[["166bc5af.1e762a"]]},{"id":"e37cbd7c.725c1","type":"mqtt in","z":"a2922961.12cbf8","name":"Sportraum/Av_input Topic to resend","topic":"Sportraum/Av_input","qos":"0","datatype":"auto","broker":"7f43c1db.c7b8b","x":220,"y":280,"wires":[["166bc5af.1e762a"]]},{"id":"cc98b6ac.188d58","type":"debug","z":"a2922961.12cbf8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"Sportraum/Av_turnoff","targetType":"msg","x":950,"y":140,"wires":[]},{"id":"6e1263c8.61fcbc","type":"debug","z":"a2922961.12cbf8","name":"OP 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1010,"y":340,"wires":[]},{"id":"97d8506b.0dd06","type":"debug","z":"a2922961.12cbf8","name":"OP 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1008,"y":230,"wires":[]},{"id":"6e5d5fc3.bc2db","type":"change","z":"a2922961.12cbf8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Sportraum/Av_input","tot":"str"},{"t":"move","p":"payload[\"Sportraum/Av_input\"]","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":741,"y":378,"wires":[["6e1263c8.61fcbc","b07fb8c3.a75848","5a7f217e.7bdcc"]]},{"id":"3008ca8d.5b3e96","type":"switch","z":"a2922961.12cbf8","name":"switch msg.payload[\"Sportraum/Av_turnoff\"]","property":"payload[\"Sportraum/Av_turnoff\"]","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":782,"y":293,"wires":[["6e5d5fc3.bc2db"],["97d8506b.0dd06"]]},{"id":"f1791f5e.67d14","type":"switch","z":"a2922961.12cbf8","name":"switch msg.Sportraum/Av_turnoff","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"Sportraum/Av_turnoff","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":715,"y":216,"wires":[["cc98b6ac.188d58","3008ca8d.5b3e96"]]},{"id":"166bc5af.1e762a","type":"join","z":"a2922961.12cbf8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":495,"y":215,"wires":[["f1791f5e.67d14"]]},{"id":"faa7aba5.be5718","type":"mqtt out","z":"a2922961.12cbf8","name":"","topic":"Sportraum/Av_input","qos":"","retain":"","broker":"7f43c1db.c7b8b","x":1150,"y":420,"wires":[]},{"id":"5a7f217e.7bdcc","type":"delay","z":"a2922961.12cbf8","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":940,"y":440,"wires":[["faa7aba5.be5718"]]},{"id":"b07fb8c3.a75848","type":"trigger","z":"a2922961.12cbf8","op1":"0","op2":"","op1type":"str","op2type":"nul","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":960,"y":380,"wires":[["faa7aba5.be5718"]]},{"id":"7f43c1db.c7b8b","type":"mqtt-broker","z":"","name":"192.168.178.15","broker":"192.168.178.15","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<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:** [2 April 2020 11:21 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/20 "2020-04-02T11:21:57Z")

</div>

Excellent.  
The challenge now (if you choose to accept it) is to work out how to combine the two switch nodes. You have to use a JSONata expression in the Property field and then switch based on the value of the expression.  
On the other hand if you just want to get on and get other more interesting things going then I shouldn't worry, what you have is completely acceptable. I haven't worked out the solution myself so I can't just post it.

---

<div class="post-metadata">

**Author:** ![Chaosflori25](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@Chaosflori25](https://discourse.nodered.org/u/Chaosflori25)\
**Post date:** [9 April 2020 19:14 UTC](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040/21 "2020-04-09T19:14:07Z")

</div>

> Never change a running system!

--My Dad  
😄

[Next page](https://discourse.nodered.org/t/repost-state-of-mqtt-topic-if-other-topics-state-is-1/24040.md?page=2)
