Port JSR223 bundle to openHAB 2

Did you try just changing…

idMyRule = ruleRegistry.add(MyRule()).getUID()

to

idMyRule = automationManager.addRule(MyRule()).getUID()

From the source code, it appears that the automationManager does some adaptation to the registered rule for scripting purposes. Adding the rule directly to the ruleRegistry may have been the original issue. Grabbing the last registered rule will work most of the time but it also may fail nondeterministically since the registry could be updated from other threads and the most recent rule may not be the one you want.