Using Tasmota MQTT Switch toggle to control lighing

Hi All,

Working on a small project using Tasmota on the Wemos D1 Mini, I am connecting one of the input to a momentary switch and I have de-attached switches to relay using setoption 114.
I am getting this mqtt message when PB is pushed:
"stat/Wemos_PB/RESULT = {"Switch1":{"Action":"TOGGLE"}}"

I like to use this PB to control the output of another Tasmota device with the mqtt topic:

What I am trying to resolve is that, the hot water system could be in ON or OFF state, and each time when the PB is pushed, I want it to toggle the statement (ie, from ON to OFF, or from OFF to ON).
Anyone know how this can be achieved? I think this needs to be done through a function node, and I need to feed both mqtt topics into this function so that each time when the PB is pushed, it knows which state to toggle to.
Appreciated if someone can assist. Let me know if you need more details.

you would send the toggle

  • The relay can be controlled with cmnd/tasmota/POWER on, cmnd/tasmota/POWER off or cmnd/tasmota/POWER toggle. Tasmota will send a MQTT status message like stat/tasmota/POWER ON.

So the topic would be cmnd/HotWaterSystem/POWER
and payload toggle

Thanks E1cid, that's actually a very simple workaround, didn't know tasmota/POWER can be controlled by "toggle" payload, and it alternates the current as required! This is perfect! Didn't need to write complex function to read both topic and determine the correct payload state to output. Appreciated!

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