What I have:
I am using OpenHAB 3.2.0 on a QNAP NAS in the Container Station (i.e. docker), migrated more than a year ago from a 2.5.x instance. I have all my configuration in text files (.things, .items, .rules, etc.). For some Items defined in the text files, I have added Metadata in the UI. There are around 90 Things from various bindings (Gardena, Miele, Homematic, Modbus, Daikin, iCalendar, HTTP, etc.) and around 680 Items in around 13 different text files each (~13 for Things, ~14 for Items). I created the semantic model for locations in a separate .items file (i.e. my house, floors, rooms hierarchy) and added semantic tags to a lot of items in the .items file.
What I want to do:
Now I want to make the step from the text file based configuration to the UI based configuration. The first phase would be to migrate Things and Items into the UI. Once done, I’ll think about how to bring all my rules in (I have lots of them, and some are quite complex). So, first focus is on Items and Things. I’ve read a number of threads here but haven’t found an “universal guide to migrate text files to UI”.
I came up with the following plan on paper and would love to get your thoughts about it, and any issues that you would anticipate with it. Or any ideas for a much better plan.
Basic thinking behind my plan is that I have a not-so-small OH installation that I really want to seemlessly continue to work, and I do not have the bandwidth to spend 30 hours in 3 days in a row to brute-force re-install everything manually in the UI. So I need an approach where I can migrate the Things and Items step by step, if needed over weeks and months, without impacting the existing installation and data collection, until I completed the process and all .items / .things files are gone.
Here my plan:
1. First Migrate all Things
I would start with migrating Things step-by-step until I have all of them UI based. Once finished with all Things, I would then start migrating Items. Any concerns with this sequence?
How to migrate Things? Here an idea, not sure if it works:
I take the first Thing, open it in the UI, go to the “Code” tab, copy the code to a text editor. Then I go to the corresponding .things file and remove the Thing from the file. It will disappear from the list but should appear in the Inbox (right?). I add it from the Inbox with “Add as a Thing”. I open the new Thing in the list, go to the “Code” tab, and replace the code with what I copied before. Now the thing should be configured correctly and identical to the previous Thing from the text file and it is my first UI-configured Thing. Then, rinse and repeat with all other Things.
Does this make sense? Any concerns? Any more efficient way to do it? Again, it is important to me not to have any interruptions for my OpenHAB setup (besides the 2-3 minutes that it takes to re-discover and config each Thing again as described). Any impact for the Items related to the Thing Channels, etc (besided not receiving / sending any data for those 2-3 minutes)?
2. Build Semantic Model for House
Once all Things are in the UI, the next step would be to load the Semantic Model for locations (house, floors, rooms) that I have in a separate .items file. I would use the “Add Items from Textual Definition” functionality to copy the content of that .items file and load it. I would do this while the .items file still exists. Once it is added in the UI, I would rename the corresponding .items file to e.g. .old.
Why do I want to do it that way? Because I hope that this way OpenHAB never really loses the location semantics (I think the text file definition overrides any UI definition). I am not sure what happens to the 680 Items, that are often tied to a room, when the room definitions all disappear for a moment. I’m afraid OpenHAB then suddenly ignores all 680 Items because they use an invalid group (e.g. gLivingRoom tagged with [“LivingRoom”]). And some seconds later all location semantics comes back … and what happens to the Items? Are they reloaded? Or do I need to touch every singe .items file so it is reloaded? Will OpenHAB manage the shock of losing all 680 Items in case this happens or am I risking unstability or strange behaviour (often it’s funny things like these that start corrupting your setup)? Any experience with this? Any better way to do it?
3. Load Items File by File
Last step of “Phase 1” would be to transfer Items step by step via “Add Items from Textual Definition” feature. I would first start with single items, just to get the feel for it and to explore any issues. Then probably continue with groups of Items in a file, until the whole file has been loaded successfully. Then, repeat for the next .items file etc. until all are UI based and the .items files are empty.
Is it better to load the Items via “Add Items from Textual Definition” while the .items file still exists, and then rename the file to .old, or is it better to first remove the item from the file (or rename the whole file) and only then copy the definition into the “Add Items from Textual Definition” feature?
As far as I could read in a number of threads, the “Add Items from Textual Definition” has its own challenges.
- Does the issue with patterns still exist? If yes, I’d probably load the Items as they are and then manually correct in the UI where I used patterns
- Will I be able to keep the existing UI-defined Metadata of the Item when I remove it from the .items file (and thus it disappears shortly from the UI) and then load it via “Add Items from Textual Definition”? Will the UI-entered Metadata appear again for the “imported” Item?
- Are the Semantic Tags imported correctly through this functionality?
- Any other known limitations of this functionality?
Any feedback, ideas, concerns are very welcomed. Would be great if we could work out together a little “Guide to seamlessly migrate text file based Things and Items into the UI”.