Sonoff-mini with a fixed state relay

Hello all!

I’m trying to setup a sonoff-mini to control my ceiling lights (ikea tradfri) without switching the relay status.

Currently, I’ve hooked the sonoff-mini to the physical switch, and everything works great. The problem is that when the switch is off, the current is cutoff from the lights, making then unavailable as expected. I would like to know if it is possible to trigger the switch as usual (mqtt message is sent), but without toggling the relay state - this way I would be able to setup an automation in HA that would turn the lights off…

Any help is appreciated!

Just wanted to share that I found two possible solutions for my use-case.

Note: you need to access Tasmota console so that you can input some commands.

Solution 1: Create a rule

By setting up a rule, you are overriding the switch state. In the example below, I’m publishing a message instead of activating the relay. You can then subscribe to the message and do whatever you want.

rule1 on switch1#state do publish %topic%/stat/custom/switch-2 {"STATE":"TOGGLE"} endon

# Enable or disable rules
rule1 off
rule1 on

Solution 2: Disable relay control and set a fixed state

More info: https://tasmota.github.io/docs/#/PowerOnState?id=poweronstate-functionality

This method simply forces the relay state to ON and prevents any changes to it.
You can then watch for changes on the binary_sensor.switch_state which will be either ON or OFF depending the physical switch state.

PowerOnState 4 # Relay is always on
PowerOnState 3 # Default