The Mini R2 can be said to consist of two parts - a detector and a relay. The detector detects the state of the switch and, depending on the settings in Ewelink, drives the relay accordingly. By switch I mean relay.
What I want to achieve is to separate these parts or use another device/software change that has such a separation. But I need both a detector and a relay. An example application could be: press the bell switch, HomeAssistant detects the event and checks if it is after sunset, if so, it short-circuits the relay and turns on the lights.
Your solution is good, but I would have to give up the relay in the Mini R2 and use a separate relay (e.g. Sonoff Basic). Connecting the lights to the relay on the Mini R2 would cause the lights to come on when the bell switch is pressed. Alternatively, I could immediately switch them off at the HA if it is not after sunset. But that's not the effect I'm after. If it's not after sunset, the light is not supposed to turn on at all. Not even for a moment. That's why I would have to use a separate relay that would be connected to the light, and the Mini R2 would only be for detection. It's a bit of a shame about the relay that sits in it.
I wonder if:
(a) there are devices that are detector only like the Mini R2 and fit in a box or.
(b) there are devices like the Mini R2 but are detected by HA as a detector as well as a relay/switch
(c) it is possible to achieve b) in the Mini R2, for example by changing the software