Please help: triggeredItem & other variables are always null in rules

  • Platform information:

    • Hardware: MacBook, Raspberry Pi 4
    • OS: macOS 11, Raspbian 10.7
    • Java Runtime Environment: OpenJDK 8
    • openHAB version: 2.5.10
  • Issue of the topic: triggeredItem and other variables are always ‘null’

  • Please post configurations (if applicable):

    • items
      Group CAN
      Group node1 (CAN)
      Group node2 (CAN)
      // …
      Number CAN_N2_Analog1 “N2.A1 [%.1f l/h]” (node2) {channel=“mqtt:topic:hassio:home_bus_can_node2:a1”}
      Number CAN_N2_Analog2 “N2.A2 [%.1f W]” (node2) {channel=“mqtt:topic:hassio:home_bus_can_node2:a2”}
      Number CAN_N2_Analog3 “N2.A3 [%.1f W]” (node2) {channel=“mqtt:topic:hassio:home_bus_can_node2:a3”}
      Number CAN_N2_Analog4 “N2.A4 [%.1f W]” (node2) {channel=“mqtt:topic:hassio:home_bus_can_node2:a4”}
      // …

    • rules
      rule “Node2Changed”
      when
      Member of node2 changed
      then
      logInfo(“calc”, “Something happened”)
      logInfo(“calc”, triggeringItem)
      end

    • log:tail says
      22:30:59.332 [INFO ] [smarthome.event.ItemStateChangedEvent] - CAN_N2_Analog1 changed from 1343 to 1340
      22:30:59.333 [INFO ] [g.eclipse.smarthome.model.script.calc] - Something happened
      22:30:59.335 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘Node2Changed’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

What am I doing wrong?
I’ve invested ~30 hours in googling, trying with combinations of changed, received command, channel trigger… with the variables described at: https://www.openhab.org/docs/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block

So, I have no idea…
I just want to know what is the item that triggered the rule, AKA the item that changed its state.

Thanks in advanced
Gerrit

Have you tried with

triggeringItem.name
1 Like

Nope, is it possible to access

triggeringItem.name

when triggeringItem is null?

I answer by myself: it is.

triggeringItem.name

works like a charm.

Thank you very much.

Perfect! Here’s yet another documentation site for openHAB that might help you!

1 Like

Thanks for introducing me with the hidden secrets.
That is really helpful!