[BUG] java.lang.NullPointerException in Notifications app for temperature

Pretty simple to reproduce. I have a notification that looks at a temperature sensor:

and I see errors in the log:

Have you tried putting a value into "Temp Greater Than"? Even if you put 999, I'm pretty sure it needs to be populated.

I will look into this.

No, it does not need to be populated.

What type of device is PWS_Pete? It is likely that it is not sending a properly formatted temperature event.

Confirming what Bruce said: I put 0 in for "Temp Greater Than" and got the same error

Please show me the Application State from the App Status page (gear icon) for that Notifier. Also please show the Events log for PWS_Pete, from its device page (link at top of page).

Ah, sorry. Shot in the dark...blank...null. Seemed logical didn't it?

But I think I see where you're going. Probably the driver formatting as a string, isn't it?

np...

PWS_Pete:

If you can't read those let me know and I'll find a different way to get them to you.

For PWS_Pete, I need the Events Log, not the Logs. On the device page, click on Events at the top of the page. Also, what kind of device is this? What driver does it have?

This is custom driver I built to read my PWS data from Weather Underground.

Happy to send you the Driver code if you need it.

OK, since you have the driver. Please put something in the event description text for the temperature event. I suspect that's what is causing the error. In sendEvent, you would add

descriptionText: "any text"

But, I'm not sure that is the problem. One other thing you could try is to remove this instance, and recreate it. See if it still throws the error.

That was it, Bruce. I added descriptionText: "any text" to sendEvent, saved the driver, then clicked Poll on PWS_Pete. I immediately got the Temperature notification on my phone. Thanks for your help!

It usually would have informative text, not "any text". Like "Temperature is 32°"

I can fix Notifier also, now that I know the weakness there.

1 Like

Really?? That is so interesting!!

I have so many questions now..... When Notifier subscribes to the event, it's expecting that field to be filled in? Is that because it subscribes to the events in a specific way? Or because of the way it's parsing out the data in the event? When you're writing a driver, should you always have an event description filled in with something? Could not having one cause other problems behind the scenes, even if an error is not posted?

(I don't mean to bombard you Bruce...just curious, that's all. Drivers make sense to me but apps are still a struggle. If you're too busy to go into detail, then don't worry about it. Thanks!)

I'm actually not sure at the moment exactly why it threw the error. I need to do more testing to determine exactly why it threw it. Notifier allows %text% in the message to be replaced by event.descriptionText. So it grabs that field from the event. If that field is not in the event, presumably it grabs null. But, I'm not clear yet on why that threw an error where it did. All built-in drivers DO put something in descriptionText. It shouldn't need it, and when I get a bit more time I'll figure out why it seems to need it.

Figured it out. There was a state variable in the app that holds descriptionText for use in the %text% replacement. That didn't exist, meaning that a reference to it would be null --> null pointer exception. Fix is in.

4 Likes

AH HA! So interesting!!! (My geek colors are showing today.) Thanks Bruce. Truly...I appreciate it.

This bug, that was caused by not having descriptionText in the event, has been fixed in Release 2.1.6.113.