It’s very simple. The relay inside Sonoff actually controls the mains to the bulb. So you would have a switch inside the app that turns the relay on or off. If it’s off, no power going to the bulb.
It seems a little complicated but it’s a win/win situation for using both the power switch and having a smart lamp.
I’m gonna overanalyse things now, so be prepared!
So, when choosing lights, you have 2 options:
i) Having dumb bulbs with a smart switch
ii) Having smart bulbs and disabling the switch
The switch is the on/off switch you already have for turning the lights on or off. With the first option, you can turn the bulb with a flick (or rather, touch) of the switch and also control it from hass. Advantage is you don’t have to open the app everytime you want to turn the light on or off, and to be honest, it “feels” better to have a switch. For us that setup the home it may be easy, but for a guest it’s frustrating to search for a switch that isn’t there! Greatest disadvantage is that the bulb is dumb. No brightness, no colors. And going with a smart bulb along with the smart switch is even worse. When flicking the switch, the bulb gets power, starts its firmware, searches for the wifi(or the zigbee coordinator), then IF the command is retained, turns on. BIG delay.
With the second option, you have the bulbs that can do brightness and colors(depending on the bulb), but no way to physically control them. You flick the dumb switch, you cut the power to the bulb. You flick the switch again, you give power to the bulb but you didn’t command the bulb to do anything.
Best option is to combine the 2 worlds with a twist. You install a smart bulb. You install a smart switch. But now you still cut the power to the bulb when flicking the switch. That’s where Tasmota firmware comes to play. Tasmota has an option where it “disconnects” the smart switchs’ button from it’s relay. So when you press the switch, it only sends an update to Hass that the switch was pressed and nothing else.
So, you program hass to command the smart bulb directly when pressing the switch (turn on or off, change color etc), rather than cutting the power.
But you also have relays inside the smart switch that are presented to hass. It depends on the number of buttons, so either 1,2 or 3. These relays cut and give power directly to the bulbs(mains power). So on your dashboard, you add these relays so when a bulb is burnt or you want to move it and play safe, go on the dashboard, flick the switch to cut the bulbs mains and do your job. When done, flick the switch from hass and the bulb has power again.
With this solution, the ONLY disadvantage (apart from programming the 2 to do what you want), is that the buttons on the Sonoff depend on Hass. If something happened (Hass got stuck or you lost power and came back) you would have to wait for hass to come up to control the lights from the Sonoff. But I guess if something like that happened, you would have larger problems than this one.