I’m trying to do some nesting of groups so that I can split my place into Floor -> Room -> Item Type and so I’ve done it like so:
Group Apartment "Apartment"
Group GroundFloor "Ground Floor" (Apartment)
Group LivingRoom "Living Room" (GroundFloor)
Group Lights "Lights" (Apartment)
Group LivingRoom_Lights "Living Room Lights" (LivingRoom, Lights)
And then I have a light in the Living Room like this:
Most of the time, unless one explicitly adds the right calls, working with groups is not recursive. For example, in a rule is you call
Lights.members.forEach[| do something]
It will only iterate over Items that are directly members of Lights. Items that are members of subgroups are shipped. To get the subgroups you need to call
Lights.allMembers.forEach[| do something]
I suspect the Vscode extension (I assume that is the screenshot you are showing showing) only shows direct members, not members.
One thing I do not know is how commands sent to a group propagate. For example, of you define your Lights with
Group:Switch Lights
And you
Lights.sendCommand(OFF)
I don’t know if members of subgroups will receive the command or not.
Thanks Rich - that is the VSCode extension that I’m showing there.
However, it’s not showing up in the Basic UI either (if I put a group in the Sitemap it doesn’t show all the items that are in that group).
Is it best to not use recursive Groups then? And just make items part of the groups they should be in?
Sitemap:
Frame label="Default" {
Group item=Apartment
Group item=Lights
}
It depends on what you hope to accomplish with your Groups. I’m pretty certain that if you send a command to a Group all members and submembers of the Group will receive the command.
Generally, I do not recommend using the Group element to compose sitemaps anyway because you have no control over order and other aspects of how the page gets built.
Personally, I don’t use hierarchical Groups at all. I tend to think about my home automation more as sets of things than a hierarchy and I use Groups to tag Items as a member of a set.