Thanks, I see it happens very quickly. However the log and timestamps show that the events follow the order of how the rule is written, and previously the rule was working properly.
Here are the applicable entries (bottom to top):
Log
app:463 2023-10-30 05:40:36.652 PMinfoAction: IF (VSWITCH2, VSWITCH3 (on, off) any is on TRUE) THEN
app:465 2023-10-30 05:40:36.517 PMinfoTriggered: VSWITCH2 switch on
app:465 2023-10-30 05:40:36.514 PMinfoEvent: VSWITCH2 switch on
app:481 2023-10-30 05:40:36.322 PMinfoAction: IF (VSWITCH2(off) is off(T) [TRUE]) THEN
dev:339 2023-10-30 05:40:35.737 PMinfoVSWITCH2 was turned on
dev:582 2023-10-30 05:40:35.692 PMinfoVSWITCH1 was turned on
app:481 2023-10-30 05:40:35.685 PMinfoAction: On: VSWITCH1, VSWITCH2
App commands 2 virtual switches on at time 35.685, switches both report on at time 35.692 and 35.737.
Time 36.322, VSWITCH2 is polled (IF/THEN) still showing OFF
Time 36.514, external app is triggered by VSWITCH2 turning ON
Time 36.652, VSWITCH2 is polled correctly (another IF/THEN) showing ON (EDIT: It's in a child rule triggered by the switch change)
So .585 secs after the virtual switch changes, it is still showing as off.
When I add a wait event and re-run the routine, the switch is already showing ON when the wait event is triggered. The WAIT is immediately following the command to change the switch.
LOG 2
app:481 2023-10-30 08:16:46.764 PMinfoAction: Wait for event: VSWITCH2 (on) turns on
app:465 2023-10-30 08:16:46.747 PMinfoTriggered: VSWITCH2 switch on
app:465 2023-10-30 08:16:46.745 PMinfoEvent: VSWITCH2 switch on
app:477 2023-10-30 08:16:46.724 PMinfoTriggered: VSWITCH1 switch on
dev:339 2023-10-30 08:16:46.701 PMinfoVSWITCH2 was turned on
dev:582 2023-10-30 08:16:46.687 PMinfoVSWITCH1 was turned on
app:481 2023-10-30 08:16:46.680 PMinfoAction: On: VSWITCH1, VSWITCH2
In this case, since the switch is already ON, the wait event doesn't register the change and the rule effectively stops. Of note, the wait event is logged .019 seconds after the switch changes, and it properly registers the switch as ON.
I realize I can add a time-out on the wait event, or just put in a 1 second WAIT.
It appears that an IF / THEN query isn't properly recording the switch position until after it is polled. Somewhere the polling (or external event trigger) updates the condition, and subsequent queries are accurate. WAIT doesn't have this issue and the switch is polled as it should be.