I have following code:
Variable definition:
var Map<String,Timer> WtrTimers = newHashMap(
"WtrValveFront_StartTimer" -> null,
"WtrValveFront_StopTimer" -> null,
"WtrValveBack_StartTimer" -> null,
"WtrValveBack_StopTimer" -> null,
"WtrValveLine_StartTimer" -> null,
"WtrValveLine_StopTimer" -> null,
"Wtr_StopTimer" -> null
)
In rule:
if(WtrTimers == null) {
logError("FILE", "Wtr_starting_stoping: WtrTimer was not initialized")
WtrTimers = newHashMap(
"WtrValveFront_StartTimer" -> null,
"WtrValveFront_StopTimer" -> null,
"WtrValveBack_StartTimer" -> null,
"WtrValveBack_StopTimer" -> null,
"WtrValveLine_StartTimer" -> null,
"WtrValveLine_StopTimer" -> null,
"Wtr_StopTimer" -> null
)
logInfo( "FILE", "Wtr_starting_stoping: After reinitializing WtrTimers[" + WtrTimers + "]")
}
ā¦
and in the log Iāve got:
2018-06-19 05:00:00.711 [ERROR] [.eclipse.smarthome.model.script.FILE] - Wtr_starting_stoping: WtrTimer was not initialized
2018-06-19 05:00:00.728 [ERROR] [.script.engine.ScriptExecutionThread] - Rule āWtr_starting_stopingā: An error occurred during the script execution: Cannot assign a value in null context.
As you see WtrTimers == null returns null but āWtrTimers = newHashMap(ā¦ā raise error but why? It looks like normal initialization.
Michal Szymanski