Rule Execution Sequence
-
Hi, @toggledbits!
I have a question about the execution behavior. See the code below, and I'll explain the situation.
This is a routine that, at a certain point, determines that the desktop on which the VM hosting the Reactor is located receives an instruction to perform a shutdown (Shell Command).
When this happens, the desktop is turned off, and then Hubitat detects by a "ping" that the VM has been down, waits 15 seconds, turns off the power to this desktop, and then 15 seconds later turns on the desktop with the Reactor VM again.
After restarting the desktop, the VM is loaded, and the Reactor is triggered. Still, the following problem occurs: I expected that when the rule was continued to be executed again, the next step would be executed, that of the 900-second delay after shutdown, but the Shell command is executed again, and then it goes into a loop, the rule does not advance.
To break the loop, I first have to make the VM not load, change the desktop password, and then start the VM. In this case, Reactor generates an error when trying to execute the Shell Command because of the invalid password and then finishes the routine following the 900 delay step.
Is my interpretation that when it returns, the routine should continue to the next step that has not yet been executed incorrectly? Or does Reactor, through the shutdown command, interpret that it hasn't finished this step and keep trying, which is the correct reaction?
Thanks for clarifying.
-
Hi, @toggledbits!
I have a question about the execution behavior. See the code below, and I'll explain the situation.
This is a routine that, at a certain point, determines that the desktop on which the VM hosting the Reactor is located receives an instruction to perform a shutdown (Shell Command).
When this happens, the desktop is turned off, and then Hubitat detects by a "ping" that the VM has been down, waits 15 seconds, turns off the power to this desktop, and then 15 seconds later turns on the desktop with the Reactor VM again.
After restarting the desktop, the VM is loaded, and the Reactor is triggered. Still, the following problem occurs: I expected that when the rule was continued to be executed again, the next step would be executed, that of the 900-second delay after shutdown, but the Shell command is executed again, and then it goes into a loop, the rule does not advance.
To break the loop, I first have to make the VM not load, change the desktop password, and then start the VM. In this case, Reactor generates an error when trying to execute the Shell Command because of the invalid password and then finishes the routine following the 900 delay step.
Is my interpretation that when it returns, the routine should continue to the next step that has not yet been executed incorrectly? Or does Reactor, through the shutdown command, interpret that it hasn't finished this step and keep trying, which is the correct reaction?
Thanks for clarifying.
@wmarcolin said in Rule Execution Sequence:
Is my interpretation that when it returns, the routine should continue to the next step that has not yet been executed incorrectly? Or does Reactor, through the shutdown command, interpret that it hasn't finished this step and keep trying, which is the correct reaction?
This depends on the shutdown shell command. If it doesn't return until its work is done, then it would seem that this command didn't complete, and Reactor would want to do it over on restart. If it was returning, then Reactor would know it was delayed until a certain time (the end time of the delay is determined when it starts and preserved across restarts) and continue to delay until that time (or not at all if it has then passed).
There should be a way to get Windows to launch that command in a subshell. You may have to have the command run in a script to do that and use the Shell Command action to run the script. The gist is, Reactor needs to start the delay before the shutdown occurs, or you'll get the behavior you're observing.
-
@wmarcolin said in Rule Execution Sequence:
Is my interpretation that when it returns, the routine should continue to the next step that has not yet been executed incorrectly? Or does Reactor, through the shutdown command, interpret that it hasn't finished this step and keep trying, which is the correct reaction?
This depends on the shutdown shell command. If it doesn't return until its work is done, then it would seem that this command didn't complete, and Reactor would want to do it over on restart. If it was returning, then Reactor would know it was delayed until a certain time (the end time of the delay is determined when it starts and preserved across restarts) and continue to delay until that time (or not at all if it has then passed).
There should be a way to get Windows to launch that command in a subshell. You may have to have the command run in a script to do that and use the Shell Command action to run the script. The gist is, Reactor needs to start the delay before the shutdown occurs, or you'll get the behavior you're observing.
@toggledbits I understood, and I really understand that since the shutdown command doesn't return anything, this scenario is invalid and will remain in a constant loop.
Breaking the action as @tunnus commented doesn't work either, the effect is the same.
Ok, I'll try something then, like triggering a script that gives a return to the Reactor so that it understands that it has completed the task to continue.
Is there any chance that the shell command triggered by the reactor might not wait for a return to proceed?
Thank you.
-
@toggledbits I understood, and I really understand that since the shutdown command doesn't return anything, this scenario is invalid and will remain in a constant loop.
Breaking the action as @tunnus commented doesn't work either, the effect is the same.
Ok, I'll try something then, like triggering a script that gives a return to the Reactor so that it understands that it has completed the task to continue.
Is there any chance that the shell command triggered by the reactor might not wait for a return to proceed?
Thank you.
@wmarcolin said in Rule Execution Sequence:
Is there any chance that the shell command triggered by the reactor might not wait for a return to proceed?
Yes, that's what I mean. This is something you can do yourself. You can start the
net
command in a subshell. The Windows command processor has a command to do that...start
I think...start net rpc ...etc..
-
@toggledbits I understood, and I really understand that since the shutdown command doesn't return anything, this scenario is invalid and will remain in a constant loop.
Breaking the action as @tunnus commented doesn't work either, the effect is the same.
Ok, I'll try something then, like triggering a script that gives a return to the Reactor so that it understands that it has completed the task to continue.
Is there any chance that the shell command triggered by the reactor might not wait for a return to proceed?
Thank you.
@wmarcolin what if you do this like below:
Rule 1: commands/reactions up to (and including) shutdown
Rule 2: triggers when rule 1 is true with a long delay reset value (or maybe latching), and commands/reactions start with 900 s delay and the rest of the reactions -
T toggledbits locked this topic on