Unable to compare two times in RM5 app: errorjava.lang.NullPointerException: Cannot execute null+0 on line 5566 (method selectActions)

Hi All

I'm trying to write a rule that compares two times (basically I have a variable for when a switch turned off and I want logic to turn it back on if it's within the last 60 minutes of turning off).

It seems like RM5 has a pretty easy way to do it, The logic would be

If (switchturnsOff) {
... (do stuff)
set offTimeLimit to now + 60 minutes
}

set nowTime to now()
if (offTimeLimit > nowTime){
turn light back on.
}

the problem is for that 2nd 'if' -- when I try to compare to time variables I get

java.lang.NullPointerException: Cannot execute null+0 on line 5566 (method selectActions)

Once you hit this error that rule is dead forever (you can't go in to edit it) with the above error message.

Screenshot attached of what (not) to do (t1 and t2 are defined as datetime variables in this example)

There are many more options, but what I typically do when I want to have a light turn off a set amount of time after it was turned on is typically either:

  1. (This will always turn off the light after the set time and the other rule items will run immediately)
    Turn on light
    Turn off light -> delay X minutes
    Other rule itemsā€¦

  2. (This will re-start the timer if the rule is triggered again. Also, anything after the wait will not run before the X minutes is passed.)
    Turn on light
    Wait X minutes
    Turn off light

Is there something specific you are looking to do where this wouldnā€™t work?

1 Like

Agree that the easiest way to conduct a 'timer' event is to trigger on the opposite of how you want the device to end up, then set the desired state with the time delay. I use this method for auto-locks.

Trigger: (lock device) UNLOCKED
Action: Set (lock device) LOCKED delay HH:MM:SS

A Predicate condition can be added with a switch to turn on/off the auto function.

I also use MODE conditionals to set different time delays for different times of day (day/evening/away or night) with separate rules for each different delay, just put the conditions in front of the action.

Finally, a variable can be used in place of a set time, the variable is in seconds will convert to minutes/etc in the delay.

HOWEVER - I am also running into the same problem as above with a more complex requirement. I have a keypad set to control my z-wave garage door opener. The garage door opener will only accept a new command if more than 30 seconds have passed since the last command to ensure the garage door has fully opened or shut.

I would like to update my rules so that if a new command was sent in less than 30 seconds since the previous event, then the new command is delayed before telling the door to open / close. This would ensure the door still responds without the user having to enter the keypad code a second time.

I have started this rule as:
Set LastGarageDoorEvent to GarageDoorEvent
Set GarageDoorEvent to Now
If GarageDoorEvent - LastGarageDoorEvent < 30 (seconds) THEN wait 30 - (GarageDoorEvent - LastGarageDoorEvent)
OPEN/CLOSE Garage Door

I also get the same error which is unrecoverable. NOTE/HINT: I found that starting the base rule, then saving it and cloning it saves me time when I have to delete the rule and start over after the error.

Any more recommendations?

@bravenel - I saw the post here:

But I don't know how to implement that in RM 5.0.

Thanks!

I can confirm this bug. Good news is that it was found a fixed, and the fix will be in the next release.

Thanks -- I found a workaround but I was hoping it would be noticed and fixed as it would be a handy feature......