mikenemat / org.openhab.binding.plum

Plum Lightpad OpenHAB Binding
6 stars 1 forks source link

Error while executing background thread Plum #3

Closed robertjackson17 closed 7 years ago

robertjackson17 commented 8 years ago

Hi Mike,

Here's a new issue I haven't seen before. In the openhab.log file, I see:

2016-05-23 10:51:47.014 [ERROR] [.service.AbstractActiveService] - Error while executing background thread Plum org.json.JSONException: JSONObject["level"] not found. at org.json.JSONObject.get(JSONObject.java:473) ~[na:na] at org.json.JSONObject.getInt(JSONObject.java:535) ~[na:na] at org.openhab.binding.plum.PlumActiveBinding.execute(PlumActiveBinding.java:270) ~[na:na] at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na] at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[na:na]

Any thoughts as to what this means or how to proceed to solve it?

Thanks.

Rob

mikenemat commented 8 years ago

Hey Rob,

That sounds like a code issue. I won't have a chance to look at it until later today or tomorrow.

It could be caused by one of three things:

1) Bad code on my part 2) A recent firmware update on the Plum switches which renamed or restructured key pieces of data. 3) An invalid Plum Logical Load ID or House Token in your config, but the error handling didn't work and instead these errors are being manifested as generic nonsensical errors like the above.

I'll keep you in the loop! Should be a straightforward fix, but I might have to ask you for a bit of help with some more logging.

robertjackson17 commented 8 years ago

Hi Mike,

I've been able to eliminate the error. It seems a couple of things happened at my end: 1) my router assigned new IP addresses to a couple of my devices. This seemed to stop these physical devices from working through OpenHab. 2) I had the wrong Logical Load ID for a dimmer item, but not for the switch item (of the same physical device; the switch item would work correctly). I'm thinking this was just a copy-and-paste error on my part.

I guess part of the solution is assigning static IP addresses to all switches. Any thoughts on this?

Presumably the 'JSONObject["level"] not found' error could have come from either the wrong Logical Load ID on the dimmer item or the wrong IP address on a switch, dimmer, or powermeter items (or both).

Thanks again for your efforts to get piece this binding together.

mikenemat commented 8 years ago

Hey Rob,

1) DHCP and the Plum binding do not get along very well, not yet anyway. I could make it work, but it's a decent amount of code and I haven't got around to it yet. I strongly recommend making use of "Static DHCP" or "Static Leases" if your router offers that feature. Typically there's a page where you can enter the desired IP and MAC address of a device, and the router will always issue that device the same IP address. I find this to be safer and more user friendly than configuring static IP addresses on the devices themselves.

2) The logical load ID issue makes sense. I'm glad you figured it out. Though, you've highlighted an issue with the binding. You're right that the JSONobject error can be caused by this. But that shouldn't be the case. The binding should provide a somewhat useful error message, and it's not a lot of work to do that. I'll try to get that fixed in the next few days.

mikenemat commented 7 years ago

A useful error message will be provided instead of the JSONObject exception in the next build :)