MQTT Input Node

Hello All,

I have been playing around with this for a few days and I have read a few documents, but I am either not quite understanding this or I am well short of being correct. Some assistance would be required.

What I am trying to achieve is:
Toggle switch on tasmotised sonoff basic called Kitchen1 when switched to trigger call service node to toggle the sonoff basic called Kitchen2.

I have set up nodes as per below:
image

When I click the inject node it triggers the call service node and the lights activate as required.

I am a bit confused on what I need to configure on the MQTT input node. What I have tried so far is as per below:
Capture2

Some advice would be greatly appreciated. Or pointing in the right direction for some good reading on the subject.

Thanks in advance.

Rob

Just set the Topic to stat/Kitchen1/POWER

It triggered the light but seemed to get itself in a loop turning on and off in a feedback loop.

Strobe lighting in the kitchen now.

ANy pointers to a 3Way(US) or 2Way(UK) set up using 2 sonoff basics (tasmotised) using switch9 inputs for the rocker switch.

It would be appreciated.

Regards

Rob

Ok so another experiment.

Set up below, with the MQTT topic as:

stat/Kitchen2/POWER

Capture3

This enables the switch on Kitchen2 when switched to toggle the light on Kitchen1 and Kitchen2 on

If I do the same in reverse for Kitchen 1 as per the link drawn in red above. Then it goes bonkers and flashes away like a disco…

Anyway to prevent this?

This is the sequence of events:

  1. You toggle the kitchen1 switch, and then it sends POWER.
  2. You respond to kitchen1’s POWER message, and send a request to kitchen2 to toggle.
  3. This toggles the kitchen2 switch, and then it sends POWER.
  4. You respond to kitchen2’s POWER message, and send a request to kitchen1 to toggle.
  5. See step 1

You could introduce something at step 4 to identify that kitchen1 just toggled, so don’t toggle it again. For example, at step 2 you could set a flow variable toggling to true, and also include a delay of (say) 5 seconds after which you set toggling back to false. And then before you send the toggle request, check that toggling is not true. This logic would have to be duplicated for both switches.

ok thanks Michael I get the logic.

in real terms I have looked at the delay node. Which node could I use as the flow variable “toggle”?

Ok after a fair bit of reading I have worked this out

2 tasmotised sonoff basics with switch09 connection to toggle lights on/off.

To 3 way switch (US) or 2 way switch (UK) using node red the flow looks like this

using the switch node to switch on or off enables the lights to work.

Hope this helps anyone else trying something similar, if you need more info just ask

I thought you were trying to accomplish it just using an mqtt node for input. Here’s another possible solution using a trigger-state node which can be enabled/disabled.

[{"id":"aee83183.f96c1","type":"trigger-state","z":"5eb3594f.d294b8","name":"","entityid":"light.kitchen1,light.kitchen2","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":288,"y":2112,"wires":[["6c9185fc.e1db0c","407505fc.03e79c"],[]]},{"id":"6c9185fc.e1db0c","type":"api-call-service","z":"5eb3594f.d294b8","name":"","service_domain":"light","service":"turn_{{payload}}","data":"{\"entity_id\":\"light.kitchen1,light.kitchen2\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":590,"y":2112,"wires":[["619e14fa.3ab16c"]]},{"id":"21eaf81.ccd7008","type":"change","z":"5eb3594f.d294b8","name":"enabled","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":924,"y":2112,"wires":[["aee83183.f96c1"]]},{"id":"407505fc.03e79c","type":"change","z":"5eb3594f.d294b8","name":"disable","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":2064,"wires":[["aee83183.f96c1"]]},{"id":"619e14fa.3ab16c","type":"delay","z":"5eb3594f.d294b8","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":780,"y":2112,"wires":[["21eaf81.ccd7008"]]}]