I’m looking to set data values in my child apps that will not be displayed as a tile/state.
a) is it really true that childDevice.updateDataValue(“variable”, value) can only take value as a String object? Whenever I try to do something like childDevice.updateDataValue("index", 5) I get an error to the effect of no method available for type string, type integer.
b) In leiu of casting my values to String and back to Integer, I thought I would try using the childDevice state. I was also surprised to find that childDevice.state.index=5 would not work. (There is no error returned; rather the value is never set.) What I did get working is:
//parent device
childDevice.setState("index", 5)
//child device
def setState (_variable, _value){
state."$_variable" = _value
}
My initial thought was that I would need a matching getter (eg getState) function, but was again surprised to find that
//parent device
log.debug "child index state value is ${childDevice.state?.index}" // logs "child index state value is 5"
//and also
log.debug "all child states are ${childDevice.state}" // logs "all child states are [index:5]"
Is my understanding of these two items correct?
a) updateDataValue can only take strings?
b) I can’t set a childDevice’s state from the parent, but I can access it?
Both of these seem rather odd, so thank you for validating or correcting my assumptions with the ST platform.