Help with Sonoff Duo2 and configuring Detached Relay mode correctly

I have three led downlights and an extract fan controlled by a Luxomat PIR in our ensuite. At night when using the wc its like walking into an floodlight football pitch :joy: I am trying to use a Sonoff Duo2 relay and HA to only switch on 1 of the three LEDs between the hours of 23:30 and 07:00. I have used ChatGPT for a solution and it came up with the following diagram


However it doesn’t work as expected. The following is true:-
1)Sonoff Duo recognised and configured by zigbee2Mqtt
2) I can use HA to manually toggle led 1 and led 2 on an off so relay is working
3) if I short L to S1 led comes on so relay is being triggered
4) If I remove relay from circuit and connect LEDs directly to PIR they operate via PIR
5) With Sonoff Duo back in circuit and PIR triggered with multimeter there is 240v at S1
6) The output from the switched lives from the PIR is via a normally open relay

Chat GPT tried to get me to use a trigger for L1 as Following (Off) and then Edge when the former didn’t work.
I’m sure its something to do with the relay entity configuration so I ran the same thing through Claude which came up with an almost identical arrangement. However, Claude said to enable
“Detached Relay mode” which currently appears to be off

Can anyone shed any light on the correct configuration of the z2m entity settings to get this to work please?

Hi. Not sure if im correct but it says on the notes at the bottom to leave s1 and s2 empty. Can you not put led2 and led3 into the same point which would be L2 on the relay?

Thanks @Darlofezza . That’s a typo on the drawing which I should have removed. I used one of the earlier drawings produced by ChatGPT before triggering S1 was suggested, to upload to the post. Later schematics were just block diagrams like this:-


and I wanted to show the full wiring diagram as confirmed by Claude.

I really think this is a configuration issue of the Sonoff Duo in z2m rather than a problem with the PIR or wiring. However there are so many entity variables exposed for this device I could do with some pointers from others who may have used this relay e.g. should I use Following (Off) as the trigger for L1? Should I enable Detached Relay Mode and turn off inching and other parameters?

Your bot/s are hallucinating. This is a fundamental electrical wiring flaw. Lucky it isn’t working for want of a modified connection or two, rather than have a safety issue.

According to the diagram you posted, downlight1 is incorrectly shown as in series with the other two - the bottom end of all three should be be connected together as shown, but going to neutral, not just the other two. Follow the current flow (or in this case, absence of it) for the downlights - it doesn’t make sense.

How to fix: Connect the blue line at the bottom of the diagram to the other blue line (the Neutral) and your circuit should work as long as the automation code is correct.

Explanation: The L1 and L2 switch the Line to the downlights. The other end of the downlights goes to Neutral so that current flows correctly across the lights.

Being picky: The Wiring Legend is also incorrect for the red line going to the downlight1

The PIR wiring looks dodgy too - is the PIR a SPDT or DPDT or SPST output? Why does the fan have three connections? Why is there two output connections from the PIR? Why is the top of Switched Line 1 connected to Neutral and not Live - check the manual for the Sonoff before wiring that into the S1 connection to prevent charcoal.

What model is the PIR - can it handle the load for the fan?

Manual, with correct wiring diagram is at MINI-ZB2GS-SONOFF Help Center - the vendor knows best!

Simplez!

Thanks @IOT7712 . I appreciate ALL replies but I think you are reading the diagram too literally. I used the diagram created by ChatGPT to post on this forum without having to redraw the whole thing in Paint. It is more of a schematic rather than a point to point connection diagram. The blue line at the bottom of the LEDs, whilst not directly shown as connected to the neutral, is “Implied” by its colour as a neutral. The leds are not in series.
I used the manufacturers wiring diagram and information from their website and as a qualified electrician, with electronic engineers qualifications, I think I know how to wire up a relay safely :wink:

The issue is NOT the wiring its to do with the trigger in Home Assistant. A number of other users have had similar issues with using PIRs to trigger smart relays. On the Shelly website there is also a suggestion by the manufacturer to connect a 330K ohm resistor in series between the PIR and S1 on the relay. I am waiting for one to be delivered.
In the meantime I have also reached out to ITEAD for technical support but still hopeful another HA user may have encountered this issue and resolved it by configuration.

Assuming you have the wiring correct:-

Normally, that module will control each relay output, according to the signal on S1 & S2.
S1 controls Relay1.
S2 controls Relay2.

To control the relay outputs from HA, you need to enable ‘Detach Relay Outputs’

That stops the internal switch - to - relay path working.
So S1 is ‘detached’ from relay1 and S2 is ‘detached’ from relay 2

You have already used Ha to turn the relays on and off so you have the ID’s for them…

Identify the signals received in HA from S1 and/or S2.

You will need to write an ‘Automation’ which uses the S1 input (controlled by the PIR) and switches the appropriate Relay Output

I’ve no idea why or where a 330k resistor would be used.

The ‘Inching Mode’ can remain OFF / Disabled.

Many thanks @johnBoy for confirming settings. Could you perhaps also confirm trigger mode? Should this be following(off) as suggested by Claude?

Incidentally I have a response from BEG who make the PIR. They confirm there is an " internal solid-state and snubber circuitry to support capacitive loads (like LEDs)" .This can keep the output L’ on the PIR, high when connected to a high impedance input (like the Sonoff Duo S1) and have suggested using a drain resistor to neutral to pull down the output when the PIR is off.
Will feed back when I receive and install resistors for anyone else finding this post

Can’t be sure about the Trigger mode as I’ve not used that particular module.

I’d suggest using ‘following mode’. Which I’d assume sets the input ON in HA, when S1 input is ON and OFF when S1 input is OFF.

Connect a temporary switch to input S1 and check in HA, if that’s what happens.

(I would guess the trigger modes allow for using spring return type rocker switches, or pushbuttons. Thereby allowing the input to be latched on and off with just a pulse input. But that is a complete guess and you don’t need it, 'cos you’re using HA to control things and not a Sonoff hub/iHost).

You ought to have mentioned the PIR model and type in the first post.
Data sheets likely give the output switching information, relevant to assessing a high input impedance switch issue. (S1).

But you’ve resolved that now.

(PIR’s I’ve used are the intruder alarm type and just have a reed relay for low voltage switching into an ESP32).

Good luck.