Error: Cannot invoke method toInteger() on null object

I updated my C7 yesterday or the day before. Last night I noticed that "null" was showing up in some of my rules and I don't remember seeing it in any rules prior to that. I tried editing the rules to get rid of "null" and now I can't view or modify those rules. When I click on them I get:
"Unexpected Error
An unexpected error has occurred trying to load the app. Check Logs for more information.
Error: Cannot invoke method toInteger() on null object"
My logs show this:
"java.lang.NullPointerException: Cannot invoke method toInteger() on null object on line 7804"
with one of these at the end:
"(method mainPage)" "(method selectActions)" "(method selectConditions)" "(method periodicHandler)"

Could you please share which app is throwing this error? Also, a screenshot of the past Logs, as well as app settings (from Apps page click on the gear icon next to the rule with problems) would be very helpful.

Sounds like this is the same issue:

We need more information if you can give it to us. In Past Logs you should be able to see the error, and it has a line number that we need. It would be super helpful if you could post the rule, assuming you can open it, or if not, recreate it and show us what it is.

You can delete it by opening the App Status page with the gear icon just left of the rule in the Apps list, then lower right corner of the page that opens.

Thanks for all of that. You had a condition Time Since Event. Can you tell me the specifics of how that was setup? That is the source of the error.

Also, what release version are you running?

I think I know what the problem is.... Investigating a fix...

Fix for this will be in the next release. You won't need to do anything other than update. This was caused by a change to Time Since Event. Before, it only allowed minutes and seconds, and now it allows hours, minutes and seconds. Rules created before 2.3.1 were blowing up because of that change.

What you posted above had the key clue: in your Settings, state_5 had the value 7:45 -- only minutes and seconds. The rule was wrongly expecting 0:07:45.

2 Likes

I know I was using If-Then (or sometimes Required Expressions) to compare current time plus offset to a time variable set when the rule last finished to limit how often it ran.

2.3.1, as in Rule Machine 2.3.1? I'm pretty certain none of my rules are that old as I've only had my Hubitat for a year. Next release as in 2.3.1.136, or 2.3.2.xxx?

No, I meant release 2.3.1. This rule that you posted was created on a prior release, and blows an error on 2.3.1. It's a Rule 5.1.

@bravenel @bobbyD
Hey Bruce/Bobby,
I'm getting this error flooding my logs from the Orbit BHyve community app. I have it set to refresh every 5 minutes from within the app... I know the app is no longer maintained, but it has worked great for several years... I hope this is something we can fix as I don't like seeing red in my logs... :slight_smile:

java.lang.NullPointerException: Cannot invoke method toInteger() on null object on line 265 (method refresh)

The App

Your issue is totally unrelated to this thread, the only thing in common is the same type of error, but totally different code and reason.

Line 265 in the app:

if (it.status.watering_status.current_station.toInteger() == deviceStationId.toInteger()) {

I am suspecting you have done something to one of the child devices, like removed it or changed the DNI thus breaking the app.

You would have to add some logging to the app to see which of the two variables it is complaining about. May also help if you enable the debug/verbose logging in the app to get the most info in the logs. Add the middle logging line, the above/below shown for reference.

def deviceStationId = getStationFromDNI(valveDevice.deviceNetworkId)
log.debug "*** NULL CHECK *** ${it.status.watering_status.current_station} || ${deviceStationId}"
if (it.status.watering_status.current_station.toInteger() == deviceStationId.toInteger()) {
1 Like

See this post for the fix to the error in the Orbit BHyve App.

https://community.hubitat.com/t/no-longer-maintained-orbit-bhyve-integration/48194/89?u=swade

2 Likes

Thanks @swade ! I did your fix and it works... And thanks @jtp10181 for taking a look... :slight_smile: