[SOLVED] AC Relay to sense mains - general advice before I do something stupid

Hi All,

I have a series of lamps which can be switched from 5 different location. The switches are just a momentary switches which control a latching relay. One push send 220v live to the relay, it closes and stay as long an other 220v live signal from a switch goes to the relay. So no information whether the lights are on or off at the switch.

What I would like to do, is to know the lights state: ON or OFF and control them still using the switches and a sonoff mini(with tasmota) using as few component as possible.

My idea is: I have a junction box with permanent 220v mains, the control wire to the relay, and the wires to the lamp(coming from the relay). I would put a sonoff mini, so I can send the signal to the relay from it and using its free gpio (S1-S2 input) to sense if the lights are on or off.

To drive the input (S1-S2) I would put a 220v ac relay parallel to the lights, so if the main relay is activated (either from sonoff or manual switch), this small ac relay also activated (since the lights get the mains) and connect it contacts to S1-S2 and via tasmota rule send mqtt message about the lights state.

So my question is: Would this work just like this ? Is there any disadvantage of this, can this be dangerous on long run ?

Currently I am using a 2nd sonoff mini parallel to the lights, and checking its network presence, but afraid it wont last long due to the frequent turn on-off, plus it uses 2 sonoff mini instead of 1.

Any though is much appreciated,

Many thanks


Are the sonoff’s UI certified? For safety and insurance reasons I would make sure whatever device you use is UI certified. Take a look at the Shelly devices as they have the cert.

1 Like

The idea is perfectly sound.
Safety will be down to choosing the right parts and mechanically installing and wiring carefully.

An alternative is to replace the original latching/pulse relay with a version that has an extra contact pole. The extra pole would replace the separate mains sensing relay, and feed into the sonoff GPIO.
The choice is about where it is convenient to install your stuff.

1 Like

Cost wise a Shelly 1 would cost the same as a son off mini + ac relay, so probably will order a Shelly 1 and see if I can configure the SW input to send mqtt msg. This would be the optimal solution, one device does all.

Thanks for the inputs !


On my lighting circuits I have a second sonoff. When the lights are manually turned on they power up and using matt, publish a message to the say they’re on. I’ve set the mqtt lwt to publish an off when they disconnect (fingers turned the lights off) after 5 seconds.

That way I know almost immediately when power is there and not. No faffing with sensing 220v.

But you already have two sonoff and need add only cheapo relays … ?

I’m rather enamoured of the Shelly-4, but why didn’t they give it a wired ethernet socket?

Yes I have 2 sonoff but only to experiment before make mass order of things. So now just try to find the right solutions, devices for my needs.