OK - that’s great. I’m with you now.
With the light not updating HA when it suffers from a power cut, it looks like I’ve got a problem on my hands. I’m going to have to try ShadowFist’s code and see what happens.
I might just try the old code anyway, because if HA and the light do update, in say five or ten minutes… is that so bad? But the problem is that the bright light wakes people up.
I might use a low power ESP to monitor the power so that I’ve got a different way to detect when there has been a power cut. The Pi and other equipment is on a UPS, so they don’t notice in themselves.
Got a chunk of thinking to do on this.
Thanks very much for your help.