Dear all, during migrating from OH2.5 to OH3 I had some issues to maintain the patterns via “Add items via textual definition”. After longer searching and playing and shouting and playing again, I found a solution, I’d like to share. Maybe it is helpful for someone else.
In short
I’d like to import all items from *.items-files OH2.5 to OH3.0 via “Add items from textual definition”. But patterns have been ignored.
What I tried and how I solved it
Keeping the *.item files under OH3 works fine. Items are available in UI but I can’t change via UI, which is correct. Changes must be done via *.items files. So far so good.
So, I tried to import the items via the developer function “Add items from textual definition”. Copy the content from item-files is working and I’ve got the items migrated into the database.
The only thing I recognized, the value pattern/format was not taken over. In the item files it was defined as part of item description (e.g. DateTime vOS_Astro_Sunrise_Start "Begin Sunrise **[%1$tH:%1$tM]**"
. But the pattern-information at the end of the description was not converted into a pattern in the database. The item label was imported as “Begin Sunrise [%1$tH:%1$tM]”.
Therefore I tried to find a possibility to add the pattern information somewhere else. In UI you can add the metadata category “State Description” and there you can easily add the pattern like [%1$tH:%1$tM].
But how to give this informatin via “Add items from textual definition”? After playing around almost a day, I found the right syntax, I’d like to share. Maybe someone else had similar obsticles or a better solution.
The trick is, to add the pattern as metadata in the textual definition. E.g. , stateDescription=" "[ pattern="%1$tR" ]
(Make sure you have a space or some other text in stateDescription=" " / Empty does not work)
Or here a full sample which works for OH3:
DateTime vOS_Astro_Sunrise_Start "Beginn Sonnenaufgang " <sunrise> (gOS_Astro) ["Point"] { channel="astro:sun:local:rise#start", stateDescription=" "[ pattern="%1$tR" ] }
Under /var/lib/openhab/jsondb/*metadata.json it looks like the following:
"stateDescription:vOS_Astro_Sunrise_Start": {
"class": "org.openhab.core.items.Metadata",
"value": {
"key": {
"segments": [
"stateDescription",
"vOS_Astro_Sunrise_Start"
],
"uid": "stateDescription:vOS_Astro_Sunrise_Start"
},
"value": "meta",
"configuration": {
"pattern": "%1$tR"
}
}
},
Developer tool “Add items from textual definition”
Item definition via UI and where to add metadata State Description for a different pattern/format.
Merry Christmas thefechner