How to trigger scene update on light connection event

I have set up 5 different scenes that I trigger based on time of day.

The problem that I have is that if light is switched off by physical switch then on power on it will start with the scene that was activated when it was powered down.

I would like to set up some kind of script/action that would be triggered when light is powered ON and connected to the network. That script would apply the scene based on time of day.

Please give some tips on how to implement that!

Thank You in advance!

Hello, zigbee device need to be always powered.

That is what I figured.
I guess what I am asking is not a standard setup. I would like to leave the existing light switch that was there for the regular light. And to trigger the scene update on light connect event.

Not a good idea, the zigbee network is alive (and it’s a mesh), if you add/remove a device, it change, and it’s not immediate.

On the logic the value “lastannounced” is the last time the device have rejoin the network, can try with this value, but not sure it’s something reliable.

Thank You for the advice!

I guess I am leaning to not continuing this experiment but will install the zigbee switches as it is supposed to be done.
Have a nice day!