Get group by name

At first I thought that last one liner would do it but then realised it doesn’t handle nesting.

The reason my groups are hierarchical is so that I can, if necessary, send commands to a parent group to control all child group/items.

I’ve been tweaking my items file again:

Group all

Group house (all)
Group upstairs (house)
Group downstairs (house)
Group bedroom (upstairs)
Group bathroom (upstairs)
Group living_room (downstairs)
Group kitchen (downstairs)

Group devices (all)
Group lights (devices)
Group tvs (devices)

String bedroom_light (bedroom, lights)
String bedroom_tv (bedroom, tvs)

String living_room_light (living_room, lights)
String living_room_tv (living_room, tvs)

String bathroom_light (bathroom, lights)

The hierarchical structure should allow me to do things like “turn on the lights in the house” and then all the children of both house (e.g. everything upstairs and downstairs) and lights would turn on.

I’ll see if I can get the function working. I’ve noticed though that functions don’t seem to execute in the same environment as the rules.