Received my boards and started to perform some testing. It worked OK when powering front plates loaded with Bluetooth LE software which are drawing only ~500uA. But as soon as I tried to power a Bluetooth mesh node which draws constantly around 5-6mA then the stand-by supply (the one built around LNK364 IC) didn't acted fast enough when performing the switching causing the BLE mesh node to reset. In other words the power supply startup time was pretty slow for this kind of circuit.
After some serious investigations and headaches (around 3-4 days or so) I finally found why. It has to do with the AC-DC converter "capacitive loading". Initially I though that it was because of the output filtering capacitors and which are also used to store energy between cycling the bi stable relay on and off. As you all know capacitors are good for filtering the ripple and storing electric energy...BUT and very important for this project over here - if they're too big they make the power supply to react a little bit slow.
Why? The reason is very simple: if you use too large capacitors then it takes longer to charge (not to mention about high inrush currents) and because of that they slow down things affecting the AC-DC converter feedback loop.
Well, in a normal use of the power supply and when not cycling between on and off power states too fast this won't be noticed and doesn't matter too much. In my case it matters and guess what? - not the output capacitors were the culprit after tinkering a little bit with their values.
The input filtering capacitor was causing issues. Yes, I'm talking about the input filtering stage after the bridge rectifier. But in this case I started to "attack" the AC/DC power supply in a different way and that is: what happens at the input stage when the supply is switched on and off ?
Let's not forget that in this project the stand-by AC/DC converter is in series with the load (light bulb) and it "breathes" and draws power from the mains voltage and the leakage current from the light bulb which can be very small especially when using LED bulbs.
So what happens actually? As you all know the AC/DC converter won't work if the input AC voltage is less than 85V or so as most are rated to work between 85-265Vac right? But what this means after the rectifier/filtering stage where we have a continuous voltage (let's forget about ripple right now)?
Taking the minimum ac voltage value of 85V this translates to: 85 x 1.41 =~120Vdc. So untill the input filtering capacitor won't reach that dc voltage value the LNK364 chip won't work and here I'm referring to it's internal voltage regulator that powers the internal circuitry or it's "start up" circuit. (in reality it may be less than 120Vdc, but still...)
But then you may think: yes, yes but the input filtering capacitor is only 4.7uF - won't it charge fast enough? Well no, and not quite - let's not forget that it's an electrolytic capacitor with higher ESR and not only that - what matters here the most is the fact that the leakage current from the light bulb dictates it's charging rate an that current can be very small !!!
And now you have it - the input capacitor in this case slows down things and affects the power supply start up time. And it doesn't matter that much if you increase the output capacitors and it becomes even worse because then we end up affecting the feedback loop from the converter.
So what I did was to remove completely the input filtering capacitor and now it's damn fast - yes the power supply still works as expected but it's much faster between on and off cycles. And if you look at the original Livolo switch it doesn't have it either but now I understand why.
We have enough filtering at the output stage so it won't affect our powered circuits. It's a little bit noisy at the input but not that much I would say because we have a bridge rectifier. And the load doesn't draw too much current so it should keep up without the input capacitor which also stores energy for the primary inductor. The LNK364 internal MOSFET shouldn't be affected as it's rated to support the peak input values and even more (700Vdc) as the input capacitor was averaging a little bit the rectified voltage waveform (but not that much anyways because it's small value). I will try with a 1uF/2.2uF and see if that slow things again.
So yes..I was almost ready to give up on this project. Now I'm more happy than ever and also because I learned new stuff. And designing/playing with offline AC/DC converters is kinda new for me. There are still many things to learn of course.
I also need to thank @axillent for its "AC-DC at own" post from where I got inspired a little bit.