HowTo: Move ALL items to JSON dB for easy editing in PaperUI and tagging for Google Home (and Alexa)

Hi @PeterR
I think I stumbled upon a bug with Openhab2 which breaks your script. I have this group item in my .item file:

Group:Switch:AND(ON,OFF)            AlarmArmed     "Alarm uzbrojony" <alarm>           (Home)   ["Alarm"]

It got serialized to:

{"name":"AlarmArmed",
    "tags":["Alarm"],
    "type":"Group",
    "members":[],"groupType":"Switch","function":{"params":["ON","OFF"]},"link":"https://dom.tjach.pl/rest/items/AlarmArmed","state":"OFF","editable":false,"label":"Alarm uzbrojony","category":"alarm","groupNames":["Home"]}

Putting that via CURL lead to:

< HTTP/1.1 500 Internal Server Error
< Server: nginx/1.18.0 (Ubuntu)
< Date: Sun, 03 Jan 2021 11:20:17 GMT
< Content-Type: application/json
< Content-Length: 82
< Connection: keep-alive
< Content-Encoding: UTF-8

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

After a little bit of research, I’ve noticed that the serialized group item does not contain the function part (Items | openHAB ).

The correct serialized item is like this:

	{"name":"AlarmArmed",
    "tags":["Alarm"],
    "type":"Group",
    "members":[],"groupType":"Switch","function":{"name": "AND","params":["ON","OFF"]},"link":"https://dom.tjach.pl/rest/items/AlarmArmed","state":"OFF","editable":false,"label":"Alarm uzbrojony","category":"alarm","groupNames":["Home"]}

So is it a bug in Openhab REST or I’m doing something wrong?

Hey,
in case someone still reads this: I had the same Issue. I found a fork on GitHub that works:

If solves for me the issues
Links fetch error:’ ReferenceError: generateLinks is not defined ’
Items fetch error:’ ReferenceError: generateItems is not defined ’
Things fetch error:’ ReferenceError: generateThings is not defined ’

Cheers

FWIW, OH 3.1 and up has an UI option to import .items file contents