Migrating from text files to Paper UI for Things using REST API

The first place to start is to install the REST API Docs. It’s under the Misc tab in PaperUI.

They are docs so using it should be pretty self explanatory. If not please ask and we can try to answer.

You will scroll down to the Things section, click it and it will open up with all the Things API calls.

The two circled end points are the ones you care about. Look at the text to the right, it tells you what the endpoint does.

First get the Thing. Click on that row and a form will open out. Put in the Thing ID of the one you created in PaperUI already. Click “Try it out!” and it will fetch the Thing’s JSON. That will be in the “Response Body”.

Copy that JSON and paste it into the “body” field under the POST end point. You may want to use a text editor instead as the box is kind of small.

Go through the JSON and remove:

  "statusInfo": {
    "status": "ONLINE",
    "statusDetail": "NONE"
  },

and and “linkedItems” sections, e.g:

      "linkedItems": [
        "vMBR_Lights_Firmware"
      ],

Notice the commas.

If you don’t link your Items to your exemplar before pulling the JSON it will save you some work here. And I don’t think it matters if you keep the “statusInfo” section really. I think it get’s ignored.

Now go through the JSON line by line and change what needs to be changed for the new Thing. You will want to change at a minimum the label, UIDs (don’t forget the ones in the Channel definitions), and topics.

Once you’ve made your edits, copy and paste the edits into the “body” field under the POST end point and click “Try it out!” You should see a 200 response code. If there is an error, look in openhab.log to see what was the cause.

After you do one or two it becomes pretty routine and fast.

1 Like