6 min read

How to make ordinary lamps smart and keep the wall switches

A relay behind the wall switch makes an ordinary lamp smart and leaves the switch on the wall. You learn when you need a relay with a neutral, when one without, and what you lose with Detached mode.

Level
Intermediate
Active time
30–60 minutes
Home Assistant required
Optional

A smart bulb stops being smart as soon as someone turns off the wall switch: the bulb is left without power and the app has nothing to control. A relay behind the switch solves this. It powers the lamp instead of the switch, and the switch only tells it “turn on” or “turn off”.

How it works

The relay is installed in the switch box, on the path of the live wire to the lamp. The wall switch is connected to its inputs (S1 and S2 in the Sonoff documentation) and no longer breaks the power to the lamp. The relay reads the switch and changes its state. Home Assistant can change the same state over Zigbee or Wi-Fi.

The lamp stays ordinary, the switch stays on the wall. The switch and Home Assistant talk to the same relay, so whoever gave the last command wins. The automation and the switch do not “know” about each other.

Neutral or no neutral: choosing a relay

The neutral wire is the second wire the current returns through. In many switch boxes it does not reach, because the switch is placed only on the live wire to the lamp. The relay has its own electronics and must be powered all the time. If there is a neutral, it takes power from there. If there is none, it passes a very small current through the lamp itself.

More than one switch, or the circuit of another lamp in the same box, can make the wiring different from what you expect.

RelayNeutralConnectionMaximum load (per the manufacturer)Detach mode
Sonoff ZBMINIL2not neededZigbee, end device (does not relay the signal)6 A; LED up to 300 W at 230 V; inductive loads such as fans are not supportednot described in the documentation
Sonoff ZBMINIR2requiredZigbee, can relay the signal10 A resistive, up to 2400 W at 240 Vyes
Sonoff MINIR4requiredWi-Fi 2,4 GHz, eWeLink10 A resistive, up to 2400 W at 240 V; not for inductive loads above their rated poweryes

The relay without a neutral has a price. The manufacturer states a minimum supported load of 3 W LED and says an anti-flicker module is not needed. Below 3 W the relay is not guaranteed. Some LED lamps also react to the small current through them: they glow faintly when off or flicker. So try the relay with the lamp that will stay in place.

Detached mode: what it does and what it costs

Normally pressing the switch changes the relay’s state. In Detach Relay (Detached) mode the switch and the relay are separated: pressing does not change the relay, it only sends a signal. The relay is controlled only by an app, a scene or an automation. Sonoff describes it for MINIR4 and ZBMINIR2. For ZBMINIL2 there is no such mode in the documentation.

Separation makes sense when the switch has to trigger a scene and not turn on its own lamp. The price is high: the wall switch no longer turns the lamp on. If Wi-Fi, the coordinator, Home Assistant or the relay itself stops, nobody can turn on the lamp from the wall. A guest or a child presses the switch and nothing happens.

So for a room where there must always be light, leave the relay in ordinary mode. If you want a scene button, it is safer to add it separately, for example with the wireless button Sonoff SNZB-01P, and not to take the lamp’s switch for a button.

Installing the relay

The relay must be fully enclosed in the box, and neither neutral nor earth is ever connected to S1 and S2.

Adding it to Home Assistant

Zigbee relay (ZBMINIL2, ZBMINIR2). You need a Zigbee coordinator with ZHA or Zigbee2MQTT. In Settings → Devices & services open ZHA and choose Add device. Put the relay in pairing mode: hold its button for 5 seconds. If the button is not accessible, Zigbee2MQTT describes an alternative for ZBMINIL2: ten consecutive toggles of the external switch. The green indicator shows whether the relay is in pairing mode.

Wi-Fi relay (MINIR4). It is added first in the eWeLink app, because the Sonoff integration takes the device list from your account there. After that the relay is visible in Home Assistant. The integration prefers the local network when the relay is reachable, and goes through the cloud otherwise. Local mode needs working mDNS between Home Assistant and the relay.

After adding, the relay appears as switch.* with the device’s name. If it is a lamp, turn it into a light: Settings → Devices & services → Helpers → Create helper → Switch as X, choose the relay and the type Light. This way it behaves as a light in dashboards and voice assistants, not as a plug.

Also set what the relay does when power comes back. ZHA shows select.*_start_up_behavior for ZBMINIL2, and the Sonoff integration shows select.* with a choice between off, on and stay. For a lamp you usually choose off or the last state. Choosing “on” means the lamp lights up after every power cut, even when you are on holiday.

Check

  1. Press the wall switch. The lamp should light up, and the state of switch.* in Developer tools → States should change.
  2. Turn the lamp on and off from Home Assistant. Then press the switch. If the switch has a fixed position, you will sometimes have to press it twice, because its position no longer matches the state of the lamp. This is normal for a relay without Detached.
  3. Turn off the circuit breaker and put it back. The lamp should become what is chosen in start_up_behavior.
  4. Stop the Zigbee coordinator or the Wi-Fi router for a while. The wall switch must turn the lamp on and off even without them.

If it does not work

  • The relay does not pair. Check that it is wired and powered correctly, especially the L In input, and that the coordinator is close during the first pairing. If the coordinator is far away, add a Zigbee router: ZBMINIL2 itself does not relay the signal.
  • The switch does the opposite of what you expect. ZBMINIL2 is set for a switch with a fixed position. If you have a push button, press the relay’s button three times until the green indicator blinks three times. This changes the type of the external switch.
  • The lamp glows faintly or flickers when off. Stop. This is a sign of too small a load for the relay without a neutral. Change the lamp.
  • The device is unavailable. With a Wi-Fi relay this is most often the network or range. With Zigbee: the coordinator or a missing router on the path.

Limitations

  • The relay is an on/off switch, not a dimmer. It does not adjust brightness, even if it controls a dimmable lamp.
  • Do not use it on motors and fans, unless the manufacturer of the specific relay allows them. For ZBMINIL2 inductive loads are not supported.
  • Sonoff describes that in eWeLink the click of the external switch becomes a scene condition on MINIR4. Check it yourself in Developer tools → States, watching the sensor.*_action of the relay when pressed.
  • If you stop Home Assistant, the relay in ordinary mode is still controlled by the switch (according to the manufacturer, the switch controls it locally). In Detached the switch does not control the lamp.

Sources

The models, their number and their state are from Marto’s Home Assistant as of 19.10.2026. The description of the modes, loads and installation follows the manufacturer’s documentation.

At home

MartoSince February 2025 (the Sonoff integration in Home Assistant)

In Home Assistant there are seven Sonoff MINIR4 relays: five for lighting (kitchen, living room, bathroom, outdoor lighting) and two for fans. Two more Sonoff ZBMINIL2 control balcony lamps through ZHA. We use neither Detached mode nor a switch as a scene button in any automation.

Need a hand?

We can set up and install everything in this project. In some regions we install it ourselves — ask us.

Contact us

Related projects

Smart WiFi relay Sonoff MINIR4, 10A, 1 channel

9,90 €
View parts

What you need

Requires a Zigbee hub or Home Assistant with a Zigbee adapter.

Added to cart

Real Home Automations

Sign in to your account

With a code sent to your email

Continue with Google
or

By continuing, you accept the Terms and Conditions and the Privacy Policy.