Getting information of parent equipment

Hi,

I need some more help.
How can I get information about the parent equipment of a triggering item in a javascript/blockly rule?
Most of my items are organised hierarchically in the openhab model.
So for example i have:

  • house
    • room1
      • contact equipment1
        • actually triggering state item
    • room2
      • contact equipment2
        • state item

Both items are aggregated into another group, e. g. “gContactSensors”
Now the rule is being triggered by group “gContactSensors” member item changed state.
In my rule I now need information in which room the triggering item is located.
How do I achieve this using information from the model?

Best regards
Sven

In JavaScript you can get the location item by this:

var locationItem = items.getItem("ContactItem").semantics.location;

or getting the item name directly from the event object:

var locationItem = items.getItem(event.itemName).semantics.location;

For more details take a look at the ItemSemantics object docs here.

1 Like

Thanks, this works great.

Can I use this syntax for expressions on ui pages too? - No I tried it, it didn’t work.
Or how can I achieve it on ui pages?
For example, I have a list of battery items which are displayed on an ui page. Now I want to show the location and the equipment the items belong to on the same page, how would I do this?

I’m sure you can’t use the same syntax in UI. On MainUI Page the syntax si different.

But I don’t know how exactly this could be done in UI.

I have done similar case with batteries in UI without semantic model, just using List card and adding manually the Label list items with custom title for each battery item.