Detecting if ZigBee devices enter/leave the network

Hi! I am brand new to zigbee2mqtt and it looks super cool!

I am looking for an option to detect whenever a ZigBee device enters or leaves the network. In particular, I would like to detect when a Phillips Hue light bulb is turned on by a mechanical light switch and trigger a script that sets that light bulb’s color depending on the current time of day.

Is this possible with the current implementation? As said I am fairly new to the project and documentation, so apologies if the answer is obvious.

That’s basically the question. What follows is a rant on why the heck I am even thinking about this use case. Feel free to read on if you’re interested :slight_smile:
I’ve been using Phillips Hue for a while and something that always bothered me about smart lighting is that lighting scenes do not get preserved when the (not smart) light switch is turned off and on again. The most simple solution of course would be to “not touch the physical light switches” but then I would need to do everything by smart phone or buy extra light switches. In addition, my girlfriend or guests would always go for the mechanical switches so that solution would not work. Another solution would be to replace the light switches by smart switches that keep power connected to the light bulbs at all times and simply reduce their brightness to zero. Whenever pressed they would trigger a scene change. This is maybe the most elegant solution. However, I do not like the idea of needing a network connection to be able to turn my lights on and of. A good old mechanical light switch works even when the network breaks down. Also, it saves energy and is not subject to any software vulnerabilities when turned off.