Skip to content

Commit

Permalink
Merge pull request #3 from florian-h05/rules-rework-1
Browse files Browse the repository at this point in the history
Add Rules Concepts page
  • Loading branch information
rkoshak authored Aug 8, 2022
2 parents ba98c7f + fbc57ac commit 6512d20
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions rules/concepts.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
# Cover generic rules concepts
# Rules Concepts

Pull stuff from the Getting Started Tutorial.
openHAB is about home automation, but to create home automation we need to define rules.

{::options toc_levels="2..4"/}

- TOC
{:toc}

## What Are Rules

You can think of rules as routines or behaviours for your smart home.

Many people have a routine when they wake up in the morning: make the bed, make coffee, make and eat breakfast, brush their teeth, etc.
Similarly your smart home can have a routine: when the sun rises raise the blinds and adjust the temperature.
Another routine could be to turn off all the lights and turn down the temperature when you leave home:
openHAB can do that for you.
There is no need to open your app and switch of the lights manually.
Do you want to hear your favorite music when you arrive back at home?
No problem, openHAB can do that for you too.
Rules can also remind you of things, for example, that you opened the window hours ago and forgot that it is open?
openHAB can send a notification to your phone.

## Parts of a Rule

### Triggers
These rules take the high level form of *When __t__ happens, if __c__ then do __a__*,
where __t__ are the _triggers_ that cause the rule run,
__c__ are the _conditions_ that must be true for the rule to run, and __a__ are _actions_ to perform when the rule is triggered and allowed to run.
Note that both __t__ and __c__ can be optional.

To work with the *When __t__ happens, if __c__ then do __a__* principle, openHAB rules consist of three parts:

| Name | Rule Part | Purpose |
|-------------|----------------------|----------------------------------------------------------|
| `Trigger` | *When __t__ happens* | Causes the rule run when the defined event happens. |
| `Condition` | *if __c__* | Which condition has to be met that the rule really runs? |
| `Action` | *then do __a__* | What should be done when the rule runs? |

### Conditions
Any single rule is not required to have all of these (although a rule without an action is not very sensible).
An individual rule can also have more than one of each.

### Script Actions
A rule that should always run when triggered will have zero conditions.
An individual rule can respond to several different triggers by having multiple different triggers set up.

### Available Values
Even though it might not seem sensible first, as the rule would never run on it's own, one can also have a rule with no triggers.
But why would somebody want such a rule?
In some cases, it is useful to have a rule that is only manually triggered.
Sometimes there is advantage in a rule that calls another rule.
In both cases, the rule has no triggers and no conditions.

formerly implicit variables

### Helper Libraries

### Templates
How to find and install.
How to write will be on a later page.

### Comprehensive Examples

0 comments on commit 6512d20

Please sign in to comment.