- Platform information:
- OS: Ubuntu 22.04 LTS
- openHAB version: openHAB 3.4.4
Hallo everyone,
I try to create a series of items via RESTapi. However, I found that the metadata will not be accepted.
For example I try with:
import requests
import json
url = "137.226.248.161:8080/rest/items"
payload = json.dumps([
{
"type": "Number",
"name": "HP_building11",
"label": "HP_building11",
"stateDescription": {
"pattern": "%.2f",
"readOnly": False,
"options": []
},
"category": "",
"tags": [],
"groupNames": [],
"function": {}
}
])
headers = {
'Content-Type': 'application/json',
'Accept': '*/*',
'Authorization': 'Bearer oh.api1.p3OWdd71XnuM5mkU2758Jy1avG40Pw24qEFsLpcK8dq15INP2bfKuLB2qAuXzZgzzDwxU6t32aDPOeIiJ19w'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
But when I check the item, the meta data statedescription
just disappears:
{
"link": "http://137.226.248.161:8080/rest/items/HP_building11",
"state": "NULL",
"editable": true,
"type": "Number",
"name": "HP_building11",
"label": "HP_building11",
"category": "",
"tags": [],
"groupNames": []
}
How can I add meta data with RESTapi? Or is it even possible?