When I first created the rule, I included while-repeat. It didn’t work whatsoever, so I removed the code to include what I thought was causing the problem for posting. If the rule had been looping, I think it would have done so after working the first iteration.
“Cannot cast object” is probably a bounds or instance error.
Regardless, my goal is to create a rule that will turn a switch on/off ("flash") when HSM is armed and a contact sensor is open before or opened after the arming. This rule accomplishes that (maybe there’s a better method):

This throws the same error as above. Only difference is a method to aggregate the contact sensors into a virtual switch using another rule. It should work, but it doesn’t…
