Dinosaur needs to migrate

I admit it, I am a dinosaur.

I have been with OH since the very beginning so all of my Things, Items, Sitemaps, and Rules are file based. But I am beginning to think that I need to leave the Jurassic era and migrate to the JSON database model.

The primary reason why I have not done this so far is that my system is huge, and I want to avoid all the work of recreating everything from scratch. So I am looking for an “automagic” solution to convert the files based stuff into JSON database stuff. I know there is the “Add Items from Textual Definition” but I miss the analog tools for Things and Sitemaps files (and maybe even Rules files although that is less critical).

Firstly I wonder if I have simply overlooked the “Add Things from Textual Definition” and “Add Sitemap from Textual Definition” tools? Are they hiding somewhere?

And if such tools really do not exist, then it seems I have two options – a) manually create new Things and Sitemaps from scratch via the UI, or b) I spend that time to actually create the missing tools. I have a suspicion that option b) might take more time to develop, but it would probably be more fun.

=> Any thoughts?


EDIT: and probably also Transforms and Persistence too…

No, ‘Things from text’ doesn’t exist. ‘Sitemaps from text’ then again does not make sense because there are no UI-configurable sitemaps, plus there’s no mapping of sitemaps to Main UI widgets. Main UI widgets then again can only be configured via UI, they cannot be created via files.

Use option a). Use Thing discovery in UI wherever offered to speed things up.

What does this supposed to mean, honestly? Things from textual definitions do exist, so do textually defined sitemaps. And I really do hope they stay in any 4.x openHAB revisions and in openHAB 5 and onwards - at least until any things auto-discovery is working flawlessly, and hopefully even after that, for anyone preferring texual definitions.

Out of curiosity, what is your expectation and goal of this move?

Personally I’m very happy with text, only need to move my rules away from DSL.

1 Like

No, it does not, you misunderstood the meaning. Meant was to import Things/Sitemaps from textfiles into MainUI.

Defining Things/Sitemaps through textfiles is NOT going to be removed.

Create a new sitemap from the pages page in the settings, this new Sitemap will have a code tab where you should be able to paste your existing Sitemap code. Just look out with the Sitemap ID.

For transformations the difference between UI and file based is minimal, for file based you edit a file, for UI-based you edit some code inside the UI …
For persistence, you can view the YAML representation of the existing file config, delete the file config, create a new UI config and paste to the code tab.
The same should even work for things.

I hope and obviously did, but reading the unclear definition of

very much sounded like it. :wink:

I beleive there are a few scripts that can push .things definitions to the REST API based on a .things file. I’d recommend, where possible, to just scan for and rediscover the Things that you can. That should be nearly as easy to handle as doing a bulk import and it should reduce the number you need to handle some other way. Be sure to “add thing wuth custom id” and set the ID to be the same as what you used in your .things file and then all your Links will still be valid.

If you do end up going down a manual thing creation route, there are ways to make that a little easier than clicking through to create each and everyone. Even copying the code tab, deleting the thing from the file, and recreating the Thing and pasting in the code tab can be a bit tedious.

Items are already handled using the Add Items from Things.

@florian-h05 answered for persistence.

Transformations would need to be imported one-by-one but you ought to be able to just copy the contents of the file straight into the new transform field in the UI.

@florian-h05 answered about sitemaps. Happily the code tab matches the .sitemap syntax.

Rules are hard. You’ll probably have to move them individually (if you move them at all). Managed rules have a number of fundamental difference (e.g. there is no “outside the rule” to define global variables so you have to use the cache instead, you can’t import classes for Rules DSL so have to use the fully qualified class name, etc).

MainUI has supported creating sitemaps through the UI almost from the beginning.

image

They are going nowhere. They will remain supported.

Indeed. Notwithstanding what @mstormi says. And it provides a very nice graphical UI for editing them. It would be nice if I could use that graphical editing UI for future editing of my current file based sitemap.

Slipped me. Ok I stand corrected.

There is an issue and PR open which might open some avenues for this sort of thing for OH 5.

2 Likes

Hmmm,

I am doing the complete opposite.
I move away from the database back to the file based definitiin as they are much easier to manage and easier to create.
Especially for things with 50 items like the awattar binding.

When you move from one pi to the next one, the setup is way faster, just copy the config folder over and you are ready to go.

Backup/restore I tried several times, never worked without errors.
So I am a bit surprised that you want to make this move.
I do not see any advantage in moving to db based definitions.

4 Likes

I’m also more in the mood of Thomas.
Keeping everything in files makes it manageable at the granularity of the character with any configuration version system (like git) and I like it (I’m a pure linuxian boy, “everything is a file”)
My problem is more that I have the half of my stuff in files and the rest in json but if someone can push me (confirm it will still be all right) to migrate all in text files, I’ll do :smiley:

The topic is about how to migrate as easily as possible, not about managed vs files, it is also hard not to go into that discussion.

Still have my question about the expectation and goal by migrating. Managed configuration is a newer feature, but that in itself is not a feature :grinning:

Did you report these errors? I exercise the backup and restore of my 100% UI configured OH at least once a month. I’ve never encountered errors. But if there are errors, they need to be reported and addressed.