Error using val variables

Hi there,

i am on the latest snapshot and working on the setup of my pir sensors. A goal is to define an individual duration for the timers associated with the PIR and the correponding switch. To store the value i use a map and i’d like to have some kind of default value in the map. And here come the problem. Themap and the default value are defined as follows

val Integer defaultOnDuration = 5

val Map<String, Integer> onDurationMap = newHashMap("BM_EC_Motionsensor" -> defaultOnDuration,
                                                    "GF_GT_Multisensor"  -> defaultOnDuration,
                                                    "BM_LC_Multisensor"  -> defaultOnDuration,
                                                    "GF_BA_Multisensor"  -> defaultOnDuration)

With this definition i get the following error while accessing the value in the map

2018-08-03 16:41:47.034 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'PIR Tripped Swicthing': cannot invoke method public int java.lang.Integer.intValue() on null

If i change the the defaultOnDuration to a distinct value in the map there is no error.

Has anyone an idea?


afaik you can’t use a val within a val or var definition. I’m not familiar with hashmaps, maybe as a workaround you could set the default value in a “system started” rule?

Can you post the rule Rule 'PIR Tripped Swicthing'