Custom zigbee switch handler....when offline set current switch status to off

I have poblems with my family manually turning smart bulbs off in the bathroom, so the hub doesnt know their state. If the hub last saw them in the off state when they are powered back on they trigger an on event - which can trigger a further planned event such as turn off after 5 minutes.
I want to write a custom zigbee switch handler that detects the offline status and sets the last known state to off. this seems to involve the native zigbee.XXXX functions that aren’t docmented…
please help…