Get group item state

Hello to everybody,
I’m trying to create a script for the items group in blockly. For example, all electrical outlets. If the consumption changes, write the triggering Item Name in the log. But contextual_info triggeringItemName writes the name of the group, not the name of the item where the change occurred. So how do I get to a specific item and its status?

Sounds like your trigger is not on the “member of group”, and instead you’re triggering on the group itself.

Yes, that’s right, I created the script for the group.
I thought that this way I could easily get to a specific item. So should I go through all the items in the group and test if a specific value has changed? I didn’t want to write a separate script for each item…


Can you show me your rule configurations? Screenshot or the yaml code. Maybe easier to explain from there.

configuration: {}

  • id: “1”
    itemName: power_consumption
    type: core.ItemStateChangeTrigger
    conditions: []

  • inputs: {}
    id: “2”
    blockSource: infotestinfoabcitemName
    type: application/javascript
    script: >
    var logger =
    Java.type(‘org.slf4j.LoggerFactory’).getLogger(‘org.openhab.rule.’ +

    type: script.ScriptAction

Try changing core.ItemStateChangeTriggercore.GroupStateChangeTrigger

I know it’s kind of misleading, but “ItemStateChangeTrigger” means you’re triggering on the Group as an item (because Group is a special type of an item).

Whereas “GroupStateChangeTrigger” means “trigger when a member of this group changed its state” and the event.itemName will contain the actual member, not the group itself.

On the UI, it looks like this:

can i buy you a coffee?
Thank you very much, I overlooked this and was only focusing on the script…

Ha thanks for the offer. I don’t drink coffee, and no need to buy me anything! :slight_smile: Just click my answer as the solution and tell my boss that I did a good job. You’ll be redirected to a short survey at the end of this call.