Initializing values in device type


(Richard Lee) #1

How does one initialize values in the device to some pre-set settings? There doesn’t seem to be a ‘constructor’ or anything, and the parse() method never seems to get called for non-zigbee/non-zwave devices.


#2

I too am looking for a solution to this problem. I want to setup my device to operate before launching the device. I need to setup my input output variables.

Anyone… anyone? Bueler… bueler


(Mike Maxwell) #3

Not following you, are you talking about setting hardware device parameters?
Not getting what you’re trying to do.


#4

Thanks Mike-

I am setting up my raspberry pi. It has several input/output ports which you can set for input or output. I was trying to do it in the device type definition but there was no initialize method like there is in a SmartApp defnintion.

I ended up setting the default settings in the raspberry pi instead. It uses a REST API through webiopi which runs a python script when it loads the webiopi service so I set my port defaults there.


(Mike Maxwell) #5

Ah, I see. Device types do have an initialize section.

def configure() {
}

Add this in if it’s not there, it’s called each time anything setup in the preferences panel is changed.


#6

Great, where did you find the documentation on that? So far I’ve found it to be quite sparse.


(Mike Maxwell) #7

In an existing device type unforch…
Figured out how and when it worked with log.debug…


(Mike Maxwell) #8

Gave you the wrong one
Configure is called when the device pairs.
updated is called on preference changes, sorry about that


#9

Merci Beaucoup Monsieur