Find specific equipment from location item

Hi,

after my problem with “Getting information of parent equipment” (Getting information of parent equipment - #2 by djal) has been solved, I’m trying to advance my rule.

The following idea:
A contact item triggers the rule to message me, that there is a window open which needs to be closed. I’m getting the equipment, where the contact item is located and the location item too.
Now I want to find the sensor item (or maybe an radiator control item) which measures the room temperature (and maybe the humidity) of the room, the contact item belongs to. Is there a way to achieve this?
My goal is to retain the message until the room temperature begins to drop a certain amount or maybe until the humidity is back to normal.
At the moment I’m using “semi fixed” delay values calculated from the outside temperature, which sometimes is anoying, because the message is being sent to early because it’s cold outside but the room climate hasn’t really changed.

Sure but I’m not sure there is enough information to tell you the best way.

Often the easiest is to construct the name of the equipment. When using “add equipment to model” from the Thing usually if the Equipment is named “Foo”, a humidity Item would be called “Foo_Humidity” and a temperature Item would be called “Foo_Temperature”. So it can be as simple as items[equipment.name+'_Temperature'].

If the sensors are in another Equipment, you can search through the members of the Location to find the one with “Temperature” in the name.

location.descendants.find( i => i.name.includes('Temperature'));

Note that descendants returns an array of all members of the Group and members of the Groups that are members of the Group so it will give you all the Point Items in that same Location. Then the find will return the first one with “Temperature” in it’s name.

If there is more than one Temperature Item include more details in what to search for in the find.

You might be able to use the tags on the Item. A temperature point Item might have “Measurement” and “Temperature” as tags so you can search through the Location for that.

location.descendants.find( i => i.tags.includes('Measurement') && i.tags.includes('Temperature'))

If you’ve more than one Item that matches that criteria in the location, you’ll have to come up with some sort of criteria to identify the one you care about.

You can create a non-semantic Group and put the contact and temperature/humidity Items into and then find the Item you care about from that Group instead of the semantic model.

You can tag the Item(s) you care about with metadata.

Lots of options, not enough details.

Thanks @rlkoshak for pointing me in the right direction.
I think one of

location.descendants.find( i => i.name.includes('Temperature'));
location.descendants.find( i => i.tags.includes('Measurement') && i.tags.includes('Temperature'))

is the way to go.
I will experiment on that.

For anyone who wants to use it in a similar way, one thing to mention, it is not

location.descendants

as this results in an error.
After some trial and error I found, it has to be

location.descendents