Canary Bulb App

Does anyone else here use the Canary Bulb app?

It works great for the most part, but I noticed that not all of my Zigbee bulbs would turn off because there is a delay of when some of my bulbs turn back on after an outage. Sometimes, they turn back on AFTER the Canary App issues the “off” command. I think this is because the Canary Bulb might be coming on before those other bulbs. The difference is literally like 1-2 seconds. Here’s an example. Canary Bulb App issues the “off” at 7:50:36.870 but the bulb doesn’t actually turn back on after the outage until 7:50:37.729

Can someone more tech savvy than I am please take a look at this app and tell me where to add a delay please? Like, even just a 5 second delay before issuing the “off” command would work.

I’m assuming I probably want to add the delay before the restoreState() method here, but I don’t know what the syntax is. I have useless C# coding skills lol.

def checkRestore(evt) {
    if(debugEnable) log.debug "Checking Restore"  
    pollCanary() 
    if(debugEnable) log.debug "Canary is ${canary.currentSwitch}"
    if ("on" == canary.currentSwitch) { 
    	if(debugEnable) log.debug "Turning stuff off"
        restoreState()
        canary.off()
        }
    pollmonitors()
    saveStates(evt)
}

I probably also want to add a new input variable here to store the delay. I think this part I can manage.

preferences {
	section("Settings") {
        input "canary", "capability.switch", title: "Bulb to indicate power failure"
        input "monitors","capability.switch", multiple: true, title: "Bulbs to restore state"
		input "debugEnable", "bool", title: "Enable debug logging?"
	}