Hi, I'm new to Node Red and I'm stuck with what seems the simplest of problems. I've changed the light switches in my house to Tasmota flashed smart switches. I've followed Peter Scargill's advice and avoided "rules" within the tasmota flashed devices relying on Node Red to handle the logic. I'm not using Home Assistant and just have a Raspberry Pi running NR and a MQTT broker. All communication is done by MQTT.
I've installed a double gang light switch in the hall that is hard wired to the house electrics. This switch also operates the landing light. Electrically this all works fine. Upstairs I've fitted a single light switch (a dummy that's not connected to the switching circuit) that I'd hoped to link with the hall switch to provide 2 way switching. I thought it would be straightforward in that I'd make the dummy subscribe to the "state" of the master and vise versa. But, if I do that, all that happens is the switches operate rapidly in a loop making the light flash like a strobe. Obviously this isn't the way to do it.
Here is the flow when I just subscribe the landing (dummy) to the hall switch. This works in that the landing switch follows the state of the hall switch.
[{"id":"e2bbc2fc.09d1","type":"mqtt in","z":"c4180017.527bc","name":"Hall (2 gang)","topic":"stat/TWS-43/POWER1","qos":"2","datatype":"auto","broker":"7668ef17.d8043","nl":false,"rap":true,"rh":0,"x":150,"y":2680,"wires":[["14b93dc9.c20892"]]},{"id":"14b93dc9.c20892","type":"mqtt out","z":"c4180017.527bc","name":"Landing (1 gang)","topic":"cmnd/TWS-17/POWER1","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"7668ef17.d8043","x":570,"y":2680,"wires":[]},{"id":"7668ef17.d8043","type":"mqtt-broker","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
But when I subscribe the hall switch to the state of the landing switch it causes an infinite loop.
I'm told I need to use a Function node to add some logic but at this stage of my knowledge it's beyond me.
I'd really appreciate if someone could point me in the right direction.