Is it possible to access the thing and location for an item in a rule?

Hi folks,

I am new to OpenHab and I wonder if it is possible to access the thing and its location an item belongs to in a rule?

Regards

While a thing can be called in a rule, you typically call the items; as items are linked to the thing.

It may be helpful you can provide more detail on what you are trying to accomplish.

When my item (a contact of a window handle) changes its state I want to figure out the location of the window handle (thing) to send a command to other items (with the same location). An example of these other items is the mode of a thermostat.

This is what Groups can be used for.

Group Front_Room can contain two windows, a door, a thermostat, and three lights.

Figuring out which member you want to command is more the challenge …

I know the pattern, but I don’t want to write a rule for every room. Therefore I use a group for all window contacts and want to determine the location of the thing from the triggeringItem.

You can find out in a rule what Groups an Item is a member of.