I am trying to run a rule from within a rule using this:
if event.itemName == 'TestTimeField':
rule_registry = get_service("org.openhab.core.automation.RuleRegistry") or get_service("org.eclipse.smarthome.automation.RuleRegistry")
for rule in [rule for rule in rules.getAll() if rule.name == 'Test']:
but I get an error:
AttributeError: 'org.openhab.core.automation.internal.RuleRegistryI' object has no attribute 'runNow'
Does anyone know what I’m doing wrong?
First, what is the name of the function defined for the rule? If the rule was created with the decorators, then the UID was added as an attribute, so no need to search for it if in the same script… my_rule_function.UID.
Once you have the UID, you’ll need to use RuleManager (not RuleRegistry) to execute it…
I was using this as my guide
I must admit to not fully understanding what I’m doing. Just copy pasting…
To answer your question, yes, the rule was created using decorators, but it is in another file, so I think I still have to search.
Using RuleManager made it work. Thank you.
That example is not right! Thank you… fixed (after I merge the commit ).
If you have any other questions, just shout!