Maker API Error

Anyone else ever see this?

I get this every once in a while in my Hubitat log. Unfortunately, I do tons of Maker API calls, so there is no easy way to tell/correlate what specifically is causing it based on that error message alone.

app:11002020-03-06 04:16:30.702 pm errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 400 (sendDeviceCommandSecondary)

Is there logging in the external system calling the MakerAPI? I had an odd random error too that my Homebridge was using and was able to narrow it down that way:

So here is what Maker API logs with debug logging turned on. Two different error instances.

Is any of that useful for troubleshooting or to tell what command actually is generating the error? Any thoughts @bravenel ?

#1:

app:11002020-03-06 07:12:14.632 pm errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 400 (sendDeviceCommandSecondary)

app:11002020-03-06 07:12:14.618 pm debug

app:11002020-03-06 07:12:14.612 pm debug[configure, off, off, on, on, refresh, setLevel]

app:11002020-03-06 07:12:14.605 pm debug[49]

app:11002020-03-06 07:12:14.600 pm debugoff

app:11002020-03-06 07:12:14.597 pm debugfindDevice called

app:11002020-03-06 07:12:14.595 pm debugsendDeviceCommandSecondary called

app:11002020-03-06 07:12:12.760 pm debugdevice event: {"name":"temperature","value":"74.48","displayName":"Laundry Room Temperature and Humidity","deviceId":"1681","descriptionText":"Temperature is 74.48\u00b0F","unit":"\u00b0F","data":null}

app:11002020-03-06 07:12:12.726 pm debugdevice event: {"name":"humidity","value":"44.1","displayName":"Laundry Room Temperature and Humidity","deviceId":"1681","descriptionText":"Humidity is 44.1%","unit":"%","data":null}

#2:

app:11002020-03-06 07:26:43.087 pm errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 400 (sendDeviceCommandSecondary)

app:11002020-03-06 07:26:43.071 pm debug

app:11002020-03-06 07:26:43.065 pm debug[configure, off, off, on, on, refresh, setLevel]

app:11002020-03-06 07:26:43.057 pm debug[49]

app:11002020-03-06 07:26:43.054 pm debugoff

app:11002020-03-06 07:26:43.049 pm debugfindDevice called

app:11002020-03-06 07:26:43.048 pm debugsendDeviceCommandSecondary called

app:11002020-03-06 07:26:39.604 pm debugdevice event: {"name":"currentSensorCal","value":"-3","displayName":"Master Bedroom Thermostat","deviceId":"1674","descriptionText":null,"unit":"F","data":null}

app:11002020-03-06 07:26:37.787 pm debugdevice event: {"name":"temperature","value":"71.6","displayName":"Guest Bedroom Temperature and Humidity","deviceId":"1678","descriptionText":"Temperature is 71.6\u00b0F","unit":"\u00b0F","data":null}

app:11002020-03-06 07:26:32.620 pm debugdevice event: {"name":"pushed","value":"2","displayName":"Breakfast Nook Light","deviceId":"1191","descriptionText":"Breakfast Nook Light had Down Pushed (button 2) [physical]","unit":null,"data":null}

app:11002020-03-06 07:26:32.599 pm debugdevice event: {"name":"switch","value":"off","displayName":"Breakfast Nook Light","deviceId":"1191","descriptionText":"Breakfast Nook Light was turned off [physical]","unit":null,"data":null}

app:11002020-03-06 07:26:31.149 pm debugdevice event: {"name":"motion","value":"inactive","displayName":"Master Bedroom Light","deviceId":"807","descriptionText":"Master Bedroom Light motion has stopped","unit":null,"data":null}

app:11002020-03-06 07:26:28.338 pm debugdevice event: {"name":"motion","value":"active","displayName":"Kitchen Light","deviceId":"484","descriptionText":"Kitchen Light detected motion","unit":null,"data":null}

app:11002020-03-06 07:26:27.845 pm debugdevice event: {"name":"motion","value":"inactive","displayName":"Master Bathroom Sink Lights","deviceId":"772","descriptionText":"Master Bathroom Sink Lights motion has stopped","unit":null,"data":null}

What device command are you trying to send?

That's the rub... I haven't figured out which command is causing the error... yet.

I send so many Maker API commands it is hard to isolate it. Would be nice if debug told me. :slight_smile:

I'm going to keep testing and see if I can figure out the exact command that is generating the error, though. I'm sure it is likely a faulty command (although I'm not sure if a faulty formatted command should generate an error).

I found what caused the error.

I'll work it with the Hubitat Node-Red dev and see if we can get it resolved on that end long term.

@bravenel So the issue is that if you send a Maker API command such as "off" and incorrectly specify an argument for the command (like "49") it errors out as that command is not supposed to have an argument.

This came into play with Node-Red. The default action on a command node was setLevel, and the default argument was 49. When I overrode the command with an "off" it still sent the argument of 49 along with the "off" command, which Maker API obviously was not expecting.

If you are ever bored and poking around in the Maker API code, it would be good if it were a little more resilient/forgiving, and just toss arguments for commands that don't take arguments, instead of erroring out.

In the meantime, I will obviously fix the logic that was sending both an "off" command and an argument...

Mystery solved! User error, as usual.

Not sure this is a good idea. The whole point of an error is so you know something is wrong. Your specific case was a benign mistake. In other contexts it could have been an important mistake.

4 Likes

Good point. That's why you make the big bucks I guess. :slight_smile:

Because you're right, I probably would have never found that issue without the error.

1 Like

@bravenel I’ve run into errors with MakerAPI as well. Could the error be enhanced to include the URL, device number, etc? Just something to help identify the issue versus a general error. The errors are so vague it’s often hard to figure out what the cause is without additional details.

The thing about an error is that it is unexpected by the code. It's not as though the code can anticipate mistakes. Also, as the user of Maker API presumably you are in control of what is being sent to the app, so you should be able to isolate the cause, and see what you are sending that is causing an error. If you are using someone else's software to send things to Maker API, then you're in a situation where you're essentially asking us to deal with their mistakes.

Maker API is an expert's tool. If you bring specifics of errors that you think should not be thrown, we'll look at them. But be prepared, as in the case above, to answer the obvious question: what did you send to Maker API that threw the error.

3 Likes

Not to necropost, but I came across this while trying to troubleshoot the (hotfix-broken) issue I was having.

It would be reasonable for Maker API to provide an error like: "parameter not expected for command 'off'" or "unknown command: 'Off'"

Also, if you're going to throw an error, the debug log should include the request that caused it. So if the request was:
http://IPADDR/apps/api/865/devices/1389/on
where 865 is the instance of Maker API, including "/devices/1389/on" in debug logs would be reasonable.

1 Like