I wish to set my measurement (temperature) Maximum and Minimum to the current value on each startup.
The runonce method requires a specific time so I want to use the below "if (!state.initialized)...
My question is:
Can I rely on the state.initialized variable which at this point is undefined, to be recognized as not being "true" ?
It doesn't cause a "save" error but I'll have rethink the remaining code if this is not the case.
Thanks
John
def parse(String description){
if (!state.initialized) runIn(125, resetMaxMin, [overwrite: true]) // <--------
if (logEnable) log.info " Raw Description= $description"
if (description?.startsWith('read attr -')){ // in testing all messages are 'read attr -''
def descMap = zigbee.parseDescriptionAsMap(description)
if (logEnable) log.info (" descMap= $descMap")
......
def resetMaxMin(){
state.initialized = true
unschedule("resetMaxMin")
schedule("0 58 23 1/1 * ? *", resetMaxMin) // execute handlerMethod every day at 23:58.
state.Max = SensorValue
state.Min = SensorValue
}