I gave the tool a quick try and there is one area that is a little disappointing.
Unfortunately, it appears that setting the channel information as metadata is not sufficient to cause OH to reestablish the Links between the Items and the Thing Channels.
For example, I copied the following Items into the tool:
Group:String PubItems
Switch vDad_LR_Motion (PubItems) { channel="zwave:device:dongle:node2:sensor_binary" }
Number vDad_LR_Lum (PubItems) { channel="zwave:device:dongle:node2:sensor_luminance" }
Switch vDad_LR_Alarm (PubItems) { channel="zwave:device:dongle:node2:alarm_burglar" }
Number vDad_LR_Sensor_Battery (PubItems) { channel="zwave:device:dongle:node2:battery-level" }
Switch vDad_Heartbeat (PubItems)
NOTE: These Items are on a remote OH instance so there is no need for categories or labels on these Items.
The generated JSON is as follows:
[
{
"type": "Group",
"groupType": "String",
"name": "PubItems"
},
{
"type": "Switch",
"name": "vDad_LR_Motion",
"groupNames": [
"PubItems"
],
"metadata": [
{
"key": "channel",
"value": "zwave:device:dongle:node2:sensor_binary"
}
]
},
{
"type": "Number",
"name": "vDad_LR_Lum",
"groupNames": [
"PubItems"
],
"metadata": [
{
"key": "channel",
"value": "zwave:device:dongle:node2:sensor_luminance"
}
]
},
{
"type": "Switch",
"name": "vDad_LR_Alarm",
"groupNames": [
"PubItems"
],
"metadata": [
{
"key": "channel",
"value": "zwave:device:dongle:node2:alarm_burglar"
}
]
},
{
"type": "Number",
"name": "vDad_LR_Sensor_Battery",
"groupNames": [
"PubItems"
],
"metadata": [
{
"key": "channel",
"value": "zwave:device:dongle:node2:battery-level"
}
]
},
{
"type": "Switch",
"name": "vDad_Heartbeat",
"groupNames": [
"PubItems"
]
}
]
The channel links from the .items file is being picked up and added to the Item as metadata.
I PUT this to the rest/items end point and got a good response saying that all the Items were created. So far so good.
But when I look in PaperUI, the Items are no longer Linked to Channels. When I look in jsondb, the org.eclipse.smarthome.core.thing.link.ItemChannelLink.json is empty
{}
So this is already really far along in making it easy to move .items files to JSONDB. But it would be complete if it also were able to reestablish the Links, or generate some JSON I can put to the rest/links/{itemName}/{channelUID} end point.
Unfortunately, it looks like that end point doesnât support a JSON array so we are still stuck updating the Items one-by-one.
As the tool matures, it would be awesome if there were a button at the bottom to âmake it soâ and the tool makes the REST calls for you to:
- create the Items
- recreate the Links
- does any other endpoint stuff needed like resetting up the Profiles if necessary
This raises another question. How are Profiles handled? I donât actually use any Profiles but I wonder if posting them as metadata will work or if that getâs handled differently like the channel does.
Finally, one gotcha that may crop up happens when people create Items in .items files but establish the Links in PaperUI. In this case deleting the .items file removes the Item but doesnât remove the Link so OH ends up in this confused state where it thinks the Item still exists. This may break the ability to create/update the Things using the REST API for those Items until the Links are removed. So it is important to remove the Links first before removing the Items in .items files and then recreate the Items using the generated JSON. And for now, recreate the Links.