openhab-core: NPE in REST API when updating thing with channels that have no ChannelTypeUID

Prerequisite: You have a thing that has at least one channel that has no ChannelTypeUID

When editing the location of a managed thing using Paper UI, you get a 500 Internal Server Error. Looking at the response from openHAB, it appears something in OHC is throwing a NPE. Unfortunately, I don’t see the full stack trace in the log file.

{"error":{"http-code":500,"exception":{"class":"java.lang.NullPointerException"}}}

I notice that when performing the update from Paper UI, Paper UI sends the entire thing object in the thing update request (including the dynamically created channels).

Performing the same operation using the rest API works if you send just this payload.

{ "location": "somewhere" }

It must be happening somewhere from this line down, since the errors above this line are not returned. https://github.com/openhab/openhab-core/blob/d4b0ecb122b2c7414572f61475780b712bf4cf22/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/thing/ThingResource.java#L375

I don’t know whether the new 3.0 admin UI will work the same way as Paper UI (i.e. does it send the entire thing object, or just what is changed).

@ghys how will this work in the new admin UI? Should I try to track down the root cause of the above issue, or is it moot for 3.0?

For completeness, here’s the payload sent by Paper UI.

{"statusInfo":{"status":"ONLINE","statusDetail":"NONE"},"editable":true,"label":"Ecobee Sensor Family Room","bridgeUID":"ecobee:thermostat:server:xxxxx","configuration":{"sensorId":"rs:100"},"properties":{},"UID":"ecobee:sensor:server:xxxxx:rs-100","thingTypeUID":"ecobee:sensor","channels":[{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:id","id":"id","channelTypeUID":"ecobee:sensorId","itemType":"String","kind":"STATE","label":"Sensor Id","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:name","id":"name","channelTypeUID":"ecobee:sensorName","itemType":"String","kind":"STATE","label":"Sensor Name","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:type","id":"type","channelTypeUID":"ecobee:sensorType","itemType":"String","kind":"STATE","label":"Sensor Type","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:code","id":"code","channelTypeUID":"ecobee:sensorCode","itemType":"String","kind":"STATE","label":"Sensor Code","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:inUse","id":"inUse","channelTypeUID":"ecobee:sensorInUse","itemType":"Switch","kind":"STATE","label":"Sensor In Use","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:temperature","id":"temperature","itemType":"Number:Temperature","kind":"STATE","label":"Sensor Temperature","defaultTags":[],"properties":{},"configuration":{}},{"linkedItems":[],"uid":"ecobee:sensor:server:xxxxx:rs-100:occupancy","id":"occupancy","itemType":"Switch","kind":"STATE","label":"Sensor Occupancy","defaultTags":[],"properties":{},"configuration":{}}],"location":"somewhere"}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (20 by maintainers)

Most upvoted comments

That’s quite an abridged quote.

Sorry - it wasn’t meant to be. I simply meant it’s a shame that the data will always all be sent since this concept has been shown to cause problems where devices have a lot of configuration parameters.

Convenience is irrelevant - it’s just how the cut and paste went and wasn’t meant to imply anything in itself.