I want to add my Xiaomi gateway device and an item using Openhab REST API. I read the documentation and found out that I must use POST /things endpoint for adding things and PUT /items for adding an item. The model schema for thing is:
You can’t do the mqtt section through the REST API and you can’t do it all in one REST call.
You need to create your Thing.
Then create the Item.
Then Link the Item to the desired Channel on the Thing. See the links endpoint of the REST API.
You cannot add or manage binding configs on Item for OH 1.x version bindings through the REST API. You can only use MQTT with Items defined in .items files, at least until the MQTT 2.4 is ready for general use.
Thank you. But getting back to my first question. Could you provide me with a working example (model schema) for adding my xiaomi gateway as a thing and the corresponding items?
Assuming your API doesn’t require special headers (e.g. access tokens in the header) the HTTP binding and sendHttp*Request Actions will work. If they do require special headers, you would be better off creating a new binding. Honestly, even if it doesn’t, a new binding will be less work and far easier for users to configure and set up.
I’m assuming that is a POST since it has the -d options. You can send a sendHttpPostRequest with content which I think lets you pass data, but I’m not sure exactly how to format that.
If not, you can use the Exec binding to call curl.