BLAKADDERwhen buying from moeshouse.com store for a 20% discount.
To control the switch via MQTT you will need to monitor the Power1 state and send an ON/OFF as an event command.
If the light is backwards toggle the Power1 relay once on the Tasmota GUI to follow the light correctly. Power1 state should then follow the “light on” sensor after this.
rule1 on event#ON do power2 TOGGLE endon rule2 on event#OFF do power2 TOGGLE endon rule3 on power1#state=1 do backlog rule1 0; rule2 1 endon on power1#state=0 do backlog rule1 1; rule2 0 endon on switch2#state=3 do publish Moes3Way/Action Long endon rule3 1 switchtopic 0 switchmode1 2 switchmode2 5 setoption32 7
Optional: A long press rule can be added to the rule3 if needed for switch2#state=3 for a long press action.
Sample Home Assistant Config
- platform: mqtt name: "SW-HallWay" state_topic: "stat/SW-HallWay/POWER1" command_topic: "cmnd/SW-HallWay/EVENT" availability_topic: "tele/SW-HallWay/LWT" qos: 0 payload_on: "ON" payload_off: "OFF" payload_available: "Online" payload_not_available: "Offline"
Alternative ruleset using conditional expressions
Rule1 ON Switch2#State DO backlog rule2 0; IF ((Switch2#State==%value%) AND (Power1#State==%value%)) Power3 2 ENDIF; Power3 2; rule2 1 ENDON
Rule2 ON Power3#State DO backlog rule1 0; Power1 2; rule1 1 ENDON
This will provide a 3rd relay in Tasmota that will accurately track the STATE of the light. Using this information, be sure to name “FriendlyName3” and use that entity in Home Assistant to toggle/track the state of the light.