Being rather new in the field of node-red I have a conceptual question.
Lets say I have 3 lights I want to switch, for each light I define a switch. The switch has an MQTT input (for status update) and an MQTT output to instruct the hardware switch. Now I can choose to use one single MQTT input and one single MQTT output and filter the status update loop by topic:
[{"id":"2ae42f67.032e7","type":"mqtt in","z":"adc908d7.97de","name":"","topic":"#","qos":"2","datatype":"auto","broker":"e19f900c.f6ae38","x":90,"y":280,"wires":[["86c9f487.a21ad8","b4f9126c.9b34d8","222e071.bdfb7f8"]]},{"id":"77162795.3f4238","type":"mqtt out","z":"adc908d7.97de","name":"","topic":"","qos":"","retain":"","x":730,"y":280,"wires":},{"id":"86c9f487.a21ad8","type":"function","z":"adc908d7.97de","name":"pass topic1","func":"if(msg.topic == "topic1") {\n return msg;\n}","outputs":1,"noerr":0,"x":310,"y":240,"wires":[["66a86007.90ae18"]]},{"id":"b4f9126c.9b34d8","type":"function","z":"adc908d7.97de","name":"pass topic2","func":"if(msg.topic == "topic2") {\n return msg;\n}","outputs":1,"noerr":0,"x":310,"y":280,"wires":[["1322464a.2a26ea"]]},{"id":"222e071.bdfb7f8","type":"function","z":"adc908d7.97de","name":"pass topic3","func":"if(msg.topic == "topic3") {\n return msg;\n}","outputs":1,"noerr":0,"x":310,"y":320,"wires":[["9053d0b5.9937d8"]]},{"id":"66a86007.90ae18","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch1","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic1","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":240,"wires":[["77162795.3f4238"]]},{"id":"1322464a.2a26ea","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch2","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":280,"wires":[["77162795.3f4238"]]},{"id":"9053d0b5.9937d8","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch3","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":320,"wires":[["77162795.3f4238"]]},{"id":"e19f900c.f6ae38","type":"mqtt-broker","z":"","name":"Tree MQTT broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"58fac6f7.ee74d","type":"ui_group","z":"","name":"Home","tab":"8b2679bd.109a8","disp":true,"width":"6","collapse":false},{"id":"8b2679bd.109a8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
I can also define an MQTT input listening to a single topic for each switch and an MQTT output for each button:
[{"id":"604399bb.b34418","type":"mqtt in","z":"adc908d7.97de","name":"","topic":"topic1","qos":"2","datatype":"auto","broker":"e19f900c.f6ae38","x":90,"y":500,"wires":[["81b6ebc6.3c4738"]]},{"id":"81b6ebc6.3c4738","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch1","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic1","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":320,"y":500,"wires":[["5ea90fe5.259eb"]]},{"id":"5ea90fe5.259eb","type":"mqtt out","z":"adc908d7.97de","name":"","topic":"","qos":"","retain":"","x":510,"y":500,"wires":},{"id":"510bbcd6.5bc80c","type":"mqtt in","z":"adc908d7.97de","name":"","topic":"topic2","qos":"2","datatype":"auto","broker":"e19f900c.f6ae38","x":90,"y":540,"wires":[["226046b5.69d6da"]]},{"id":"226046b5.69d6da","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch2","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic2","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":320,"y":540,"wires":[["3d690a5e.261e16"]]},{"id":"3d690a5e.261e16","type":"mqtt out","z":"adc908d7.97de","name":"","topic":"","qos":"","retain":"","x":510,"y":540,"wires":},{"id":"3d6aebd3.5cfb3c","type":"mqtt in","z":"adc908d7.97de","name":"","topic":"topic3","qos":"2","datatype":"auto","broker":"e19f900c.f6ae38","x":90,"y":580,"wires":[["4fd716eb.d6c5e8"]]},{"id":"4fd716eb.d6c5e8","type":"ui_switch","z":"adc908d7.97de","name":"","label":"switch3","tooltip":"","group":"58fac6f7.ee74d","order":13,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic3","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":320,"y":580,"wires":[["8085cca.9e5853"]]},{"id":"8085cca.9e5853","type":"mqtt out","z":"adc908d7.97de","name":"","topic":"","qos":"","retain":"","x":510,"y":580,"wires":},{"id":"e19f900c.f6ae38","type":"mqtt-broker","z":"","name":"Tree MQTT broker","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"58fac6f7.ee74d","type":"ui_group","z":"","name":"Home","tab":"8b2679bd.109a8","disp":true,"width":"6","collapse":false},{"id":"8b2679bd.109a8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
Is there a preference for one of these approaches with respect to performance (eg in case of a multitude of buttons), flexibility, clarity of design? Or is it just a matter of taste?