runtimeInfo:
version: 3.2.0
buildString: Release Build
locale: de-DE
systemInfo:
configFolder: /etc/openhab
userdataFolder: /var/lib/openhab
logFolder: /var/log/openhab
javaVersion: 11.0.13
javaVendor: Azul Systems, Inc.
javaVendorVersion: Zulu11.52+13-CA
osName: Linux
osVersion: 5.4.0-92-generic
osArchitecture: i386
availableProcessors: 2
freeMemory: 264820136
totalMemory: 536870912
I am transitioning from text-based config and Rules-DSL to mostly UI. I got a fairly simple rule for day/time management (based on Rich’s stuff):
All it does it trigger on an Astro-event, set two items (and log this using JSScripting:
configuration: {}
triggers:
- id: "1"
configuration:
thingUID: astro:sun:quellenweg
event: START
channelUID: astro:sun:quellenweg:rise#event
type: core.ChannelEventTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
itemName: dt_NightState
state: OFF
type: core.ItemStateUpdateAction
- inputs: {}
id: "3"
configuration:
itemName: dt_LateNightState
state: OFF
type: core.ItemStateUpdateAction
- inputs: {}
id: "4"
configuration:
type: application/javascript;version=ECMAScript-2021
script: >
console.log("NightState updated, --> NightState set to",
items.getItem("dt_NightState").state);
type: script.ScriptAction
- inputs: {}
id: "5"
configuration:
type: application/javascript;version=ECMAScript-2021
script: >
console.log("LateNightState updated, --> LateNightState set to",
items.getItem("dt_LateNightState").state);
type: script.ScriptAction
So I am manipulating item-states in UI-rule actions and then want to access these in the scripts.
What happens is that the item-states get updated (events.log):
2022-01-12 08:23:00.000 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:quellenweg:rise#event triggered START
2022-01-12 08:23:00.001 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:quellenweg:civilDawn#event triggered END
2022-01-12 08:23:00.004 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:rise#event triggered START
2022-01-12 08:23:00.004 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TimeOfDay' received command DAY
2022-01-12 08:23:00.007 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:civilDawn#event triggered END
2022-01-12 08:23:00.008 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'dt_NightState' changed from ON to OFF
2022-01-12 08:23:00.008 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'dt_LateNightState' changed from ON to OFF
2022-01-12 08:23:00.009 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TimeOfDay' changed from BED to DAY
(just look at the timestamps from the two dt* items).
My script log actions actually seem to execute a fraction of a second earlier and the first one logs (aka fetches) the old state:
2022-01-12 08:23:00.003 [INFO ] [model.script.rules_tools.Time of Day] - Transitioning to DAY
2022-01-12 08:23:00.005 [INFO ] [org.openhab.automation.script ] - NightState updated, --> NightState set to ON
2022-01-12 08:23:00.007 [INFO ] [org.openhab.automation.script ] - LateNightState updated, --> LateNightState set to OFF
My expectation was that each of the steps in the rule-body are executed in sequence. I also have not found anything in the docs that discourages mixing different rule-languages in a rule.
Of course I could put all the item-manipulations and logging in a single script but my point was to use UI as much as possible and leverage the power of the UI rules-actions.
So question: is this to be expected if mixing rule-engines and manipulating & accessing the same items within a rule multiple times ?
Or should that work and I’m having side effects of the other “Time of day” rules from marketplace/Rich (they do not touch/use the two dt* items) ?
Thanks
-Markus