Textual Configuration: Find and watch subdirectories

OpenHAB registers inotifies or polls the configuration files at a regular interval. Having a lot of files and splitting many of them for a better overview and faster updates (of rules) works great for me.

I now would like to organize these many rules into subdirectories. Here is an exaggregated example:

Before:

openhab2/rules/work.lights.modes.automatic.rules
openhab2/rules/work.lights.modes.manual.rules
openhab2/rules/work.lights.modes.override.rules
openhab2/rules/work.lights.presence.rules
openhab2/rules/work.notifications.rules
openhab2/rules/work.audio.rules

(flat hierarchy. Looks OK when listed as text, but is overwhelming when looking at it in an IDE or browser)

After (what I am trying to sell here):

openhab2/rules/work/lights/modes/automatic.rules
openhab2/rules/work/lights/modes/manual.rules
openhab2/rules/work/lights/modes/override.rules
openhab2/rules/work/lights/presence.rules
openhab2/rules/work/notifications.rules
openhab2/rules/work/audio.rules

(usual file system hierarchy. Very easy to focus on specific files/rooms/groupings.)

When folding all folders, we have a great overview:

openhab2/rules/work
openhab2/rules/living
openhab2/rules/garden
openhab2/rules/kids

or even folder per-purpose or mixed up:

openhab2/rules/per-room/work
openhab2/rules/per-room/kitchen
openhab2/rules/per-purpose/automation
openhab2/rules/per-purpose/sensors
openhab2/rules/per-floor/ground
openhab2/rules/per-floor/first

You get the hang of it.

It would be awesome to be able to let openHAB poll the subdirectories as well. As we are polling already, I assume it’s a small change in the regexp or globbing pattern that matches those configuration files.

What do you think?

2 Likes

It sounds like a good idea except:

  • there are some really really big problems with the way OH loads config files right now and those problems need to be fixed before something like this can be addressed. For example, the order of loading and processing of these files is a major problem for some users (Rules start running before they are ready to run) and the loading can take minutes to hours in some cases on an RPi.

  • these config files as they exist now are approaching end of life. Before you get worried we are probably at least a year before there will be any sort of need to transition but the writing is on the wall. The Xtext based config files cannot remain as they are and have OH continue to grow and advance. I’m told that one of the libraries we use to parse these files is one of the reasons we are still stuck on Java 8, for instance.

So I’m not sure how much effort it is really worth putting into them right now in terms of adding enhancements like this. That’s just my own personal opinion though. However, were I a maintainer, I’m not sure I would accept a PR like this until the above two issues were fixed.

1 Like