Noob question: I can write a rule but how do I use it?

So I’ve built a working system, read the documentation, and written a working rule.
I see documentation on how to write them but not how to use them.
I can’t search for the answer since I have no idea how to express the question.

I wrote a rule that turns off a wifi outlet at bed time (“When the time is 23:00”).
As it stands will it ever execute? Does it need to be somehow “associated” with cron, an item, etc?
Does the system iterate through the rules periodically?
Perhaps when system events occur?

Thanks for any help

I assume you’ve read the Rules documentation, which says where to store text-based rules files or how to define them in Main UI. If you’ve done one of those things, then you have a working rule.

If you want to test that rule, then just add a switch that you can manually trigger to fire the rule immediately. Otherwise, wait for 23:00 and see if it goes off.

1 Like

I tested it.

I’m a programmer by profession. What causes rules to execute?
On linux I need to add a script like this to my crontab. On windows I need to double click on an icon.

I assume executions based on event transitions?
The condition is “When the time is 23:00.”
Is this going to hammer the switch with “off” commands for a full minute?

The rule engine is associated with an internal scheduler, and manages time-based triggers for you when a rule is parsed. The rule will run once (and then set itself up for the next 23:00:00.000 event next day).

All OH rules run once in response to some singular event.

1 Like

Thanks for helping me understand Rossko!

Since the rule is cron triggered instead of triggered by an Item, and therefore it doesn’t use event, you can just click the play icon for the rule to run it. That’s way easier than creating a Switch Item and adding that as a trigger just to kick off the rule.

1 Like

Ah, that’s good to know. I haven’t played with rules in Main UI yet. I just moved over my text files and haven’t come back to them.

Note that even if the rules are defined in files, they will appear in MainUI and you can trigger them by clicking the play button. You just can’t edit them.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.