Setup in multiple files

(Kim Skatun) #5

I have now started splitting the items in multiple files, will let you know how it goes.

(Kjetil Asdal) #6

Fair point! I did not think of that since I am not using groups in my setup at the moment.

I guess this could have been solved by some kind of “dependency resolver”, but it would likely be quite complex, so it is definitely easier to simply re-load all files.

(DG) #7

You are able to use Groups across multiple item files ? for me somehow group in one file is not recognized in another :frowning: … i created Group:Switch in separate item file and it didnt work.

( ) #8

I am also splitting up my items and rules for different parts of my system (heating, lighting, sonos, kodi, …).

Yes. that’s the case. I did not quite understand your problem.

On the other side I always stayed with only exactly one sitemap containing everything important to me cascaded. What are you using 20 sitemaps for? :open_mouth: What’s your use case? How do you browse them / switch between them?

(Kjetil Asdal) #9

I agree that using 20+ sitemaps may seem a bit execssive, :slight_smile:

I should point out that I very much subscribe to one of @rlkoshak’s mantras: Home automation should just work without any (or at least significant) user involvment.

From this it follows that I really only have one (very limited) sitemap that I use on a regular basis. This gives me a sort of condensed overview of the system - some information points that I find important and take a look at on a regular basis.

All the rest of the sitemaps are there solely for maintenance/debugging purposes and thus are focused on providing as much details as possible for given parts of the system.

I have also choosen to have some sitemaps that focus on systems (or rather bindings), e.g. one for Z-Wave devices, one for network devices, one for DYI devices (interfaced through MQTT), etc.

… and other sitemaps that are focused on functionalitites, e.g. ligthing, security, presence, appliances, etc.

When it comes to navigating between them, I really don’t. I have simply given them sensible names, and added them as favorites in my web browser, :slight_smile:

( ) #10

This describes a lot and actually sounds pretty similar to the idea behind my setup. I have one nurtured and condensed view on the important parts of my system but with more details in the background. One example is the speedtest integration I presented a few months ago. As you can see, there is a nested menu for it but only one summarized line on the main sitemap.

Besides providing a nice sitemap, which I still find pretty important, my home automation is also aimed at “automation”, without the need of user interaction.

Instead of additional sitemaps, I have this one last line in my one sitemap:

sitemap ... {
    Group item=Whg label="Alle Elemente" icon="house"

With “Whg” being my all containing group :wink:

(Jim) #11

That is correct. For all the groups I have for v1.9 bindings, they are in a single groups.items file. They group things horizontally if you think of the bindings as verticals.

As an example, I have denon.items, and insteon.items so that a binding has an items file for those things that the binding controls, but I have a group basement that comprises elements from both insteon and denon items files. This is then how I feed my sitemap. My sitemap is based almost entirely on groups so that the sitemap itself changes dynamically as devices in the group come and go.

I do the same with groups for 2.x inside of MapDB. Groups are functional areas that feed the sitemap.
Hope this helps.

(DG) #12

yes this helps, i am trying to implement almost the same structure … thanks

(Rasmus Balle) #13

I’ve tried to setup multiple Items files, and made one only for the Groups… But it seems like it doesn’t work.
I’ve made an item that takes the average of 4 sensors - this doesn’t work when the Group is put in another file than the Item is in…
If i put the group in the same item file where the items is it works…

Is there a workaround for this?

(Rich Koshak) #14

This should work but I’ve been seeing some inconsistent behavior with Groups in OH 2. Perhaps this is related. I don’t have a work around. All I can say is it appears to work for me right now but I couldn’t tell you why.

(Rasmus Balle) #15

Okay… then i must try again to move the group stuff around a bit… Would be smart to have Groups in a single file…

(Rich Koshak) #16

It depends. I have my groups spread all over my files. With just a couple of exceptions having to do with persistence and keeping track of the online status of my sensors, all my groups are specific to one function (e.g. lighting). Since I split my Items and Rules up by function the Groups and the Items that are members of that Group naturally fall into the same files anyway.

But like I said, there are exceptions where Items are members of Groups defined in other files. And for me those appear to work so it should be possible. I can’t say why it isn’t for you.

I’ve been an advocate for this sort of organization because I’ve found it solves a lot of problems. In addition to having Groups located in the same file as its members, I don’t have to worry about copying lambdas into multiple files because all the rules that need that lambda are already colocated. It also makes it easier to find opportunities for simplifying and merging rules because it is easier for me at least to notice patterns when the rules are in the same file. YMMV.

(DG) #17

@Rasmus7700 - how about ensuring your item file that contains all the groups loads before rest of Item files ?

(Rasmus Balle) #18

That could be something… But… how to ensure that, as i can read OH2 just loads them randomly?

(trumee) #19

I have this issue that a rule is being run before the Thing has become online. What file do ypu specify this 5 seconds in?

(Rich Koshak) #20

You would have to post your rule and Items.

The five seconds referred to is related to OH 1.x and not applicable to OH 2.

(lysol) #21

I just ran a test on my OpenHab 2.1 environment. For the test, I have 1 switch.

Item file 1:
Group test "Test"
Group test2 "Test2"
Switch Light_Power (test, test2, test3) {channel=“zwave:device:XXXXXXXX:node2:switch_binary”, autoupdate=“true”}

Item file 2:
Group test3 "Test3"
Group:Switch:AND(ON,OFF) test4

With this setup, groups test, test2, and surprisingly test4 work fine but I cannot trigger the switch via group test3 from within Basic UI as well as HabPanel.

What’s interesting though is that in HABpanel if I create a switch and type in the group name, typing in t-e-s-t shows 4 things:

If I type the 5th character so it reads test3, it still shows Light_Power which indicates that HABpanel can resolve the group test3, but I can’t select it.

(Rich Koshak) #22

All of this is useful information but none of it is relevant rules triggering when the Thing is offline.

But if you are triggering rules based on updates to a group, realize that only test4 can be used as defined above. The rest won’t trigger rules because they don’t have a state. Only Groups with a type get updated when their members update.

There have been some reports that changes to Groups are not being reflected until OH is restarted. Try a restart and see if that works.

(lysol) #23

Thanks. Regarding the restart, I should have added that there were many restarts in my process… close to 10…

(Rich Koshak) #24

Errors in the logs?