Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rules Concepts page #3

Merged
merged 4 commits into from
Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

florian-h05 marked this conversation as resolved.
Show resolved Hide resolved
{::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__*,
florian-h05 marked this conversation as resolved.
Show resolved Hide resolved
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.

florian-h05 marked this conversation as resolved.
Show resolved Hide resolved
### 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