Fetch another Item state, derived from a similar triggeringItem name

  • openHAB version: 2.5.6
  • Issue of the topic:

Trying to ‘get’ the State of an Item who’s name is derived from the Name of a triggeringItem in a different group.

I’m aiming for a rule that does the following

Item of a group triggers a rule

The triggeringItem name is captured, split so that the .get(0) part can added to a different suffix.

IE.

Alarm1Minute becomes Alarm1Hour

In an IF statement that checkes to see if the Alarm1Minute is >59, the corresponding Hour value needs to be fetched & increased by 1.

I can compile the new Item name, but I don’t know how to use that to poll / get the State of the corresponding Hour Item.

var newHour = Alarm1Hour.state.toInt +1

works, but

var Hour = triggeringItem.spilt("Min").get(0)
var newHour = Hour.state.toInt +1

Results in an error saying that .state is not a member of the String function

Is what I’m trying to do possible? Or am I barking at the moon?

Thanks @rossko57

Node red rules TriggeringItem

I’ll check this out.


With a little poking around, I have what I want working.

Thanks @rossko57

I’ve also documented this appraoch in a design pattern: Design Pattern: Associated Items. Scroll down to the “Item Registry” approach.

1 Like