I want to have multiple item actions in a rule, and want to filter for the items triggering the script including their (new) value. I get the new (and depending on the action the old) state. But not the related item name…
Probably overlooking something: searches related to trigger item. But is a switch a trigger item, or what makes an item a trigger?
- Platform information:
- Hardware: Docker on Synology
- OS: DSM/Linux
- Java Runtime Environment: which java platform is used and what version
- openHAB version: openHAB 5.1.4
configuration: {}
triggers:
- id: "3"
configuration:
itemName: SunScreenUpSwitch
type: core.ItemCommandTrigger
- id: "4"
configuration:
itemName: SunScreenUpSwitch
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
considerConditions: true
ruleUIDs:
- SunScreenScript
type: core.RunRuleAction
console.warn(([ctx.ruleUID,':',true,':',event.eventName,':',(event.receivedState ?? event.newState),':',event.oldState,':',event.itemName,':',event.receivedCommand,':',event.channelUID,':',event.receivedEvent,':',items.getItem('SunScreenCommand').state].join('')));
console.warn((['SunScreenUpSwitch',':',items.getItem('SunScreenUpSwitch').name].join('')));
console.warn((['SunScreenUpSwitch',':',items.getItem(event.itemName).name].join('')));
This script prints 3 log lines for each call:
First was triggered manually (playbutton) of the script and rule.
Next the related item switch was turned on and off.
15:57:19.554 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:::::::0
15:57:19.556 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:57:19.558 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
15:57:27.823 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:::::::0
15:57:27.825 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:57:27.827 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
15:58:23.515 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SunScreenUpSwitch' changed from OFF to ON (source: org.openhab.core.thing$zwavejs:node:aabcb81d8a:SunScreenUp:binary-switch-value)
15:58:23.518 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:ON::::::0
15:58:23.520 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:58:23.522 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
15:58:23.526 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:ON:OFF:::::0
15:58:23.528 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:58:23.530 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
15:58:24.436 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'SunScreenUpSwitch' changed from ON to OFF (source: org.openhab.core.thing$zwavejs:node:aabcb81d8a:SunScreenUp:binary-switch-value)
15:58:24.438 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:OFF::::::0
15:58:24.439 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:58:24.441 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
15:58:24.444 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenScript:true:ExecutionEvent:OFF:ON:::::0
15:58:24.445 [WARN ] [tion.jsscripting.rule.SunScreenScript] - SunScreenUpSwitch:SunScreenUpSwitch
15:58:24.447 [ERROR] [l.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'SunScreenScript' failed: org.openhab.core.items.ItemNotFoundException: Item 'null' could not be found in the item registry
```
The ‘was updated’ in ‘When’ does not trigger the script.
The ‘changed’ showed the old state,
The ‘received a command’ only the new state.









