Driver initialize question

Question.... I am trying to figure out why a driver is not initializing after a reboot as expected.

So I stuck some debug logging as well as a scheduled runIn in there. After a reboot I don't see either happen, and I can't figure out why.

Here is what is in the driver right now. I get ZERO logs after a reboot, and the scheduled task is never scheduled - making me thing initialize isn't actually running for some reason after a reboot???

def initialize() {
    
	log.debug "----- IN INITIALIZE -----"
	log.debug "----- IN INITIALIZE -----"
    pauseExecution(1000)
	log.debug "----- IN INITIALIZE -----"	
	runInMillis(5000, heartbeat)	
}

def updated() {
	log.debug "----- IN UPDATED -----"
}

what is in the device capabilities list?

1 Like

Didn't think about that affecting it! But maybe that's it - only thing in there is:
capability "Notification"

I'll add actuator or something and see if it wakes up.

if you want initialize to run, Initialize needs to be added as a capability

2 Likes

sigh

I get the dunce cap for the day. :cry: :cry: :cry:

Thanks @mike.maxwell and @bcopeland

4 Likes

won't be much consolation but I stumbled upon the need for capability initialize only a week or so ago... so I barely beat you at removing my dunce cap. :slight_smile:

I've had this set of hints in my "Templates" for years...

/**
mike.maxwell (Leader)
May 25, 2018

installed() - runs when driver is installed, via pair or virtual
configure() - runs when driver is installed, after installed is run. if capability Configuration exists, a Configure command is added to the ui
initialize() - runs first time driver loads, ie system startup when capability Initialize exists, a Initialize command is added to the ui.
updated() - runs when save is clicked in the preferences section

Initialized() is not a capability or built in driver command, it's a local method only, I've never understood it either, i guess it saves a few lines of duplicate calls...
**/

One must read EVERY word Mike writes :smiley:

4 Likes

Yeah... I knew better on that one. Have done that same mistake before - but it has been a year or so.... So I forgot. :slight_smile:

Thank goodness I don't have to rely on my shitte coding skills for a paycheck.

1 Like

Do you happen to have a "driver" which initializes a driver so that I can start fresh on a device?

You can usually do that by changing the device type to "Device" and then clicking on each delete command button, then set it back to whichever driver you need.