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?