2016-05-14 19:23:24 +00:00
---
layout: documentation
2016-08-05 10:10:20 +00:00
title: Rules
2016-05-14 19:23:24 +00:00
---
{% include base.html %}
# Textual Rules
2016-06-08 22:56:14 +00:00
"Rules" are used for automating processes: Each rule can be triggered, which invokes a script that performs any kinds of tasks, e.g. turn on lights by modifying your items, do mathematical calculations, start timers etcetera.
openHAB has a highly integrated, lightweight but yet powerful rule engine included.
On this page you will learn how to leverage its functionality to do *real* home automation.
2016-10-20 13:58:03 +00:00
{::options toc_levels="2..4"/}
2017-07-20 16:47:28 +00:00
- TOC
2016-10-20 13:58:03 +00:00
{:toc}
2016-06-08 22:56:14 +00:00
## Defining Rules
### File Location
2018-10-01 15:19:56 +00:00
Rules are placed in the folder `$OPENHAB_CONF/rules` .
2020-12-21 09:13:16 +00:00
The [demo setup ](https://demo.openhab.org ) already comes with a demo file called [`demo.rules` ](https://github.com/openhab/openhab-distro/blob/master/features/distro-resources/src/main/resources/rules/demo.rules ), which has a couple of examples that can be a good starting point.
2016-06-08 22:56:14 +00:00
2017-07-20 16:47:28 +00:00
A rule file can contain multiple rules.
All rules of a file share a common execution context, i.e. they can access and exchange variables with each other.
It therefore makes sense to have different rule files for different use-cases or categories.
2016-06-08 22:56:14 +00:00
2020-12-20 09:42:34 +00:00
### UI based definition
Rules can be created and edited with in the UI.
You can find the editor browsing to `Settings` -> `Rules` .
Click on the `+` icon to add a rule and define a name and a trigger.

In our example we will catch the openHAB Startup to initialize our environment.

Click on `Add Action` and choose `Run Script` .

Choose `Rule DSL` and enter a rule like it is described below in this article.
2016-06-08 22:56:14 +00:00
### IDE Support
2018-07-08 21:04:27 +00:00
The [openHAB VS Code Extension ]({{base}}/configuration/editors.html#openhab-vs-code-extension ) offers support for rules building.
2017-07-20 16:47:28 +00:00
It includes syntax checks and coloring, validation with error markers, content assist (Ctrl+Space) incl. templates etc.
This makes the creation of rules very easy!
2020-12-20 09:42:34 +00:00
Check out the editors page for more information and additional editor possibilities.
2016-06-08 22:56:14 +00:00
### The Syntax
2019-12-27 15:18:48 +00:00
::: tip Note
2020-12-21 09:13:16 +00:00
The rule syntax is based on [Xbase ](https://www.eclipse.org/Xtext/#xbase ) and as a result it is sharing many details with [Xtend ](https://www.eclipse.org/xtend/ ), which is built on top of Xbase as well.
2017-07-20 16:47:28 +00:00
As a result, we will often point to the Xtend documentation for details.
2019-12-27 15:18:48 +00:00
:::
2016-06-08 22:56:14 +00:00
A rule file is a text file with the following structure:
2017-07-20 16:47:28 +00:00
- Imports
- Variable Declarations
- Rules
2016-08-05 10:10:20 +00:00
2017-07-20 16:47:28 +00:00
The **Imports** section contains import statement just like in Java.
As in Java, they make the imported types available without having to use the fully qualified name for them.
2020-12-21 09:13:16 +00:00
For further details, please see the [Xtend documentation for imports ](https://www.eclipse.org/xtend/documentation/202_xtend_classes_members.html#imports ).
2016-06-08 22:56:14 +00:00
Example:
2017-07-20 16:47:28 +00:00
```javascript
2016-06-08 22:56:14 +00:00
import java.net.URI
```
A few default imports are already done, so classes from these packages do not need to be explicitly imported:
2016-12-03 14:43:03 +00:00
```java
2020-11-28 22:11:36 +00:00
org.openhab.core.items
org.openhab.core.persistence
org.openhab.core.library.types
org.openhab.core.library.items
org.openhab.model.script.actions
2016-06-08 22:56:14 +00:00
```
2017-07-20 16:47:28 +00:00
The **Variable Declarations** section can be used to declare variables that should be accessible to all rules in this file.
You can declare variables with or without initial values and modifiable or read-only.
2020-12-21 09:13:16 +00:00
For further details, please see the [Xtend documentation for variable declarations ](https://www.eclipse.org/xtend/documentation/203_xtend_expressions.html#variable-declaration ).
2016-06-08 22:56:14 +00:00
2016-08-05 10:10:20 +00:00
Example:
2016-06-08 22:56:14 +00:00
```java
// a variable with an initial value. Note that the variable type is automatically inferred
2016-08-05 10:10:20 +00:00
var counter = 0
2016-06-08 22:56:14 +00:00
// a read-only value, again the type is automatically inferred
2016-08-05 10:10:20 +00:00
val msg = "This is a message"
2016-06-08 22:56:14 +00:00
// an uninitialized variable where we have to provide the type (as it cannot be inferred from an initial value)
2016-08-05 10:10:20 +00:00
var Number x
2016-06-08 22:56:14 +00:00
```
2017-07-20 16:47:28 +00:00
The **Rules** section contains a list of rules.
Each rule has the following syntax:
2016-06-08 22:56:14 +00:00
```java
2018-01-16 16:14:06 +00:00
rule "< RULE_NAME > "
2016-06-08 22:56:14 +00:00
when
2018-01-16 16:14:06 +00:00
< TRIGGER_CONDITION > [or < TRIGGER_CONDITION2 > [or ...]]
2016-06-08 22:56:14 +00:00
then
< SCRIPT _BLOCK >
2016-12-03 14:43:03 +00:00
end
2016-06-08 22:56:14 +00:00
```
2018-01-16 16:14:06 +00:00
- `<RULE_NAME>` - Each rule must have a unique name (given within quotes). It is recommended that you choose a name that has meaning when spoken.
- `<TRIGGER_CONDITION>` - The triggering event upon which the rule logic is executed. A rule is executed in reaction to one or more trigger conditions. Multiple conditions are separated by the keyword `or` . Please see below for different possible triggers.
- `<SCRIPT_BLOCK>` - Contains the logic that should be executed when a trigger condition is met, see the [script ](#scripts ) section for details on its syntax.
2016-06-08 22:56:14 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #rule -triggers}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Rule Triggers
Before a rule starts working, it has to be triggered.
There are different categories of rule triggers:
- **Item**(-Event)-based triggers: They react on events on the openHAB event bus, i.e. commands and status updates for items
2018-08-19 15:32:05 +00:00
- **Member of**(-Event)-based triggers: They react on events on the openHAB event bus for Items that are a member of the supplied Group
2016-06-08 22:56:14 +00:00
- **Time**-based triggers: They react at special times, e.g. at midnight, every hour, etc.
- **System**-based triggers: They react on certain system statuses.
2017-09-26 10:08:50 +00:00
- **Thing**-based triggers: They react on thing status, i.e. change from ONLINE to OFFLINE.
2016-06-08 22:56:14 +00:00
Here are the details for each category:
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #event -based-triggers}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Event-based Triggers
2017-07-20 16:47:28 +00:00
You can listen to commands for a specific item, on status updates or on status changes (an update might leave the status unchanged).
You can decide whether you want to catch only a specific command/status or any.
Here is the syntax for all these cases (parts in square brackets are optional):
2016-06-08 22:56:14 +00:00
```java
Item < item > received command [< command > ]
Item < item > received update [< state > ]
Item < item > changed [from < state > ] [to < state > ]
```
2018-07-13 20:14:47 +00:00
A simplistic explanation of the differences between `command` and `update` can be found in the article about [openHAB core actions ](/docs/configuration/actions.html#event-bus-actions ).
2016-06-08 22:56:14 +00:00
2020-11-28 22:11:36 +00:00
When using the `received command` trigger, the Rule might trigger **before** the Item's state is updated.
Therefore, if the Rule needs to know what the command was, use the [implicit variable ]({{base}}/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block ) `receivedCommand` instead of `<ItemName>.state` .
2018-08-19 15:32:05 +00:00
{: #member -of-triggers}
2021-01-10 12:50:59 +00:00
2018-08-19 15:32:05 +00:00
### Member of Triggers
As with Item based event-based triggers discussed above, you can listen for commands, status updates, or status changes on the members of a given Group.
You can also decide whether you want to catch only a specific command/status or any.
All of the [implicit variables ]({{base}}/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block ) get populated using the Item that caused the event.
2020-11-28 22:11:36 +00:00
The implicit variable `triggeringItem` is populated with the Item that caused the Rule to trigger.
2018-08-19 15:32:05 +00:00
```java
Member of < group > received command [< command > ]
Member of < group > received update [< state > ]
Member of < group > changed [from < state > ] [to < state > ]
```
2019-12-27 15:18:48 +00:00
The `Member of` trigger only works with Items that are a direct member of the Group.
2018-08-19 15:32:05 +00:00
It does not work with members of nested subgroups.
2020-11-28 22:11:36 +00:00
Also, as with Item event-based triggers, when using `received command` , the Rule might trigger before the Item's state is updated.
2018-08-19 15:32:05 +00:00
So in Rules where the Rule needs to know what the command was, use the `receivedCommand` implicit variable instead of `triggeringItem.state` .
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #time -based-triggers}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Time-based Triggers
2019-05-18 19:08:24 +00:00
You can either use some pre-defined expressions for timers or use a [cron expression ](https:////www.quartz-scheduler.org/documentation/quartz-2.2.2/tutorials/tutorial-lesson-06.html ) instead:
2016-06-08 22:56:14 +00:00
```java
Time is midnight
Time is noon
Time cron "< cron expression > "
```
A cron expression takes the form of six or optionally seven fields:
1. Seconds
2021-01-10 15:01:56 +00:00
1. Minutes
1. Hours
1. Day-of-Month
1. Month
1. Day-of-Week
1. Year (optional field)
2016-06-08 22:56:14 +00:00
2020-12-21 09:13:16 +00:00
You may use [CronMaker ](https://www.cronmaker.com/ ) or the generator at [FreeFormatter.com ](https://www.freeformatter.com/cron-expression-generator-quartz.html ) to generate cron expressions.
2016-06-08 22:56:14 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #system -based-triggers}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### System-based Triggers
2021-01-16 08:55:38 +00:00
One system-based trigger is provided as described in the table below:
2017-07-06 15:39:52 +00:00
2019-01-13 13:25:05 +00:00
| Trigger | Description |
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2021-01-16 08:55:38 +00:00
| System started | `System started` is triggered upon openHAB startup. In openHAB version 2, `System started` is also triggered after the rule file containing the System started trigger is modified, or after item(s) are modified in a .items file. |
2017-07-06 15:39:52 +00:00
You may wish to use the 'System started' trigger to initialize values at startup if they are not already set.
2017-07-20 16:47:28 +00:00
Example:
2016-06-08 22:56:14 +00:00
```java
2017-07-06 15:39:52 +00:00
rule "Speedtest init"
when
System started
then
2017-12-30 19:05:36 +00:00
createTimer(now.plusSeconds(30), [|
2017-07-06 15:39:52 +00:00
if (Speedtest_Summary.state == NULL || Speedtest_Summary.state == "") Speedtest_Summary.postUpdate("unknown")
2017-12-30 19:05:36 +00:00
])
2017-07-06 15:39:52 +00:00
end
2016-06-08 22:56:14 +00:00
```
2017-09-26 10:08:50 +00:00
{: #thing -based-triggers}
2021-01-10 12:50:59 +00:00
2017-09-26 10:08:50 +00:00
### Thing-based Triggers
2017-11-22 17:34:22 +00:00
Your rules can take actions based upon status updates or status changes generated by Things.
You can decide whether you want to catch only a specific or any status the Thing can get updated too.
2017-09-26 10:08:50 +00:00
Here is the syntax for all these cases (parts in square brackets are optional):
```java
Thing < thingUID > received update [< status > ]
Thing < thingUID > changed [from < status > ] [to < status > ]
```
The status used in the trigger and the script is a string (no quotes).
2018-07-13 20:14:47 +00:00
You can find all the possible values for status from [Thing Status ](/docs/concepts/things.html ).
2018-09-18 17:29:31 +00:00
And refer to [Thing Status Action ](/docs/configuration/actions.html#thing-status-action ) to find how to get thing status in the script.
2017-09-26 10:08:50 +00:00
The `thingUID` is the identifier assigned to the Thing, manually in your configuration or automatically during auto discovery.
You can find it from PaperUI or from Karaf remote console.
For example, one z-wave device can be "zwave:device:c5155aa4:node14".
2019-12-27 15:18:48 +00:00
::: tip Note
You need to use quotes around `thingUID` if it contains special characters such as ':'.
:::
2017-11-22 17:34:22 +00:00
{: #channel -based-triggers}
2021-01-10 12:50:59 +00:00
2017-11-22 17:34:22 +00:00
### Channel-based Triggers
Some add-ons provide trigger channels.
Compared with other types of channels, a trigger channel provides information about discrete events, but does not provide continuous state information.
Your rules can take actions based upon trigger events generated by these trigger channels.
You can decide whether you want to catch only a specific or any trigger the channel provides.
Here is the syntax for these cases (parts in square brackets are optional):
2019-12-27 15:18:48 +00:00
::: tip Note
You need to use quotes around `triggerChannel` if it contains special characters such as `:` .
:::
2017-11-22 17:34:22 +00:00
```java
Channel "< triggerChannel > " triggered [< triggerEvent > ]
```
`triggerChannel` is the identifier for a specific channel.
When a binding provides such channels, you can find the needed information in the corresponding binding documentation.
There is no generic list of possible values for `triggerEvent` ,
The `triggerEvent` (s) available depend upon the specific implementation details of the binding.
2019-07-14 12:18:28 +00:00
If the Rule needs to know what the received event was, use the [implicit variable ]({{base}}/configuration/rules-dsl.html#implicit-variables-inside-the-execution-block ) `receivedEvent` to access the information.
2017-11-22 17:34:22 +00:00
Example:
```java
rule "Start wake up light on sunrise"
when
Channel "astro:sun:home:rise#event" triggered START
then
...
end
```
2017-09-26 10:08:50 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #scripts }
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
## Scripts
2020-12-21 09:13:16 +00:00
The expression language used within scripts is the same that is used in the Xtend language - see the [documentation of expressions ](https://www.eclipse.org/xtend/documentation/203_xtend_expressions.html ) on the Xtend homepage.
2016-06-08 22:56:14 +00:00
2019-07-14 12:18:28 +00:00
The syntax is very similar to Java, but has many nice features that allow writing concise code.
2017-07-20 16:47:28 +00:00
It is especially powerful in handling collections.
What makes it a good match for openHAB from a technical perspective is the fact that there is no need to compile the scripts as they can be interpreted at runtime.
2016-06-08 22:56:14 +00:00
2016-08-05 10:10:20 +00:00
To be able to do something useful with the scripts, openHAB provides access to
2016-06-08 22:56:14 +00:00
- all defined items, so that you can easily access them by their name
- all enumerated states/commands, e.g. `ON, OFF, DOWN, INCREASE` etc.
- all [standard actions ](https://github.com/openhab/openhab/wiki/Actions ) to make something happen
2017-07-20 16:47:28 +00:00
Combining these features, you can easily write code like:
2016-06-08 22:56:14 +00:00
2017-07-20 16:47:28 +00:00
```java
2017-08-27 10:07:33 +00:00
if (Temperature.state < 20 ) {
Heating.sendCommand(ON)
}
```
{: #manipulating -item-states}
2021-01-10 12:50:59 +00:00
2017-08-27 10:07:33 +00:00
### Manipulating Item States
Rules are often used to manipulate the state of an Item, for example switching lights on and off under certain conditions.
Two commands can change the value or state of an Item within rules:
- `MyItem.postUpdate(<new_state>)` - Change the status of an Item without causing any implicit actions. Can be used to reflect changes that may be caused by other means.
- `MyItem.sendCommand(<new_state>)` - Change the status of an Item and trigger potential further actions, e.g. send a command to the linked device/binding.
In relation to [event-based rule triggers ]({{base}}/configuration/rules-dsl.html#event-based-triggers ) the manipulator commands `sendCommand` and `postUpdate` act differently.
The following table summarizes the impact of the two manipulator commands on the rule execution due to the used trigger:
| Command \ Rule Trigger | `received update` | `received command` | `changed` |
|--------------------------|-------------------|--------------------|-----------|
2019-01-13 13:25:05 +00:00
| postUpdate | ⚡ rule fires | ❌ | (depends) |
| sendCommand | (❌) see below | ⚡ rule fires | (depends) |
2017-08-27 10:07:33 +00:00
| *Change through Binding* | ⚡ rule fires | ⚡ rule fires | (depends) |
**Beware:**
2019-04-05 21:59:20 +00:00
In most cases, a rule with a trigger of `received update` will fire following the command `sendCommand` as:
2021-01-10 12:50:59 +00:00
2019-01-13 10:54:14 +00:00
- openHAB auto-updates the status of Items for which the item definition does not contain `autoupdate="false"`
2019-07-14 12:18:28 +00:00
- the Thing sends a status update to the Item.
2019-01-13 10:49:55 +00:00
2017-08-27 10:07:33 +00:00
Besides the specific manipulator command methods `MyItem.sendCommand(<new_state>)` and `MyItem.postUpdate(<new_state>)` , generic manipulators in the form of `sendCommand(MyItem, <new_state>)` and `postUpdate(MyItem, <new_state>)` are available. The specific versions is normally recommended.
{: #sendcommand -method-vs-action}
2021-01-10 12:50:59 +00:00
2017-08-27 10:07:33 +00:00
#### MyItem.sendCommand("new state") versus sendCommand(MyItem, "new state")
Using the methods `MyItem.sendCommand(<new_state>)` and `MyItem.postUpdate(<new_state>)` is often preferable.
These are methods of Objects that can accept a variety of types.
Contrary, the Actions `sendCommand(MyItem, "<new_state>")` and `postUpdate(MyItem, "<new_state>")` can only accept strings as arguments.
The reasons lie within Java, the object-oriented programming language on which openHAB is built.
Java and the Rules DSL have two basic types, primitives and Objects.
2017-09-22 19:20:58 +00:00
A lower case letter data type after a `var` or a `val` statement, for example `var int` , indicates a primitive type.
An upper case letter data type after a `val` and `var` statement, for example `var Number` indicates an Object.
2017-08-27 10:07:33 +00:00
Objects are more complex than primitives.
2017-09-22 19:20:58 +00:00
Objects have special methods that can perform many necessary type conversions automatically.
Using `Myitem.sendCommand(new_state)` or `Myitem.postUpdate(new_state)` will, in most cases, convert `new_state` into a type that Object `myItem` can apply.
2017-08-27 10:07:33 +00:00
2017-09-22 19:20:58 +00:00
The Action `sendCommand(MyItem, new_state)` does not provide the same flexibilty.
For example, if `new_state` is typed as a primitive (e.g., `var int new_state = 3` ) and myItem is of the Object type Dimmer:
2021-01-10 12:50:59 +00:00
2021-01-10 15:01:56 +00:00
- the following command ** *will fail***: ~~sendCommand(MyItem, new_state)~~ .
- However, the following command **will work** : `MyItem.sendCommand(new_state)` .
2017-08-27 10:07:33 +00:00
2017-09-22 19:20:58 +00:00
Using `MyItem.postUpdate(new_state)` or `MyItem.sendCommand(new_state)` will create the most stable code.
It provides by far the best option for avoiding most problems.
This syntax ensures that any conversion (typing) of the `new_state` is done in a way that is most suitable for `myItem` .
2017-08-27 10:07:33 +00:00
**Exception:**
2017-09-22 19:20:58 +00:00
Actions are useful when the name of the Item is only available as a String.
2017-08-27 10:07:33 +00:00
For example, if the name of the Item to receive an update or command was calculated in the Rule by building up a String:
```java
2017-09-22 19:20:58 +00:00
val index = 5
2017-08-27 10:07:33 +00:00
sendCommand("My_Lamp_" + index, ON)
2016-06-08 22:56:14 +00:00
```
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #using -state-of-items-in-rules}
2021-01-10 12:50:59 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
### Using the States of Items in Rules
2019-12-27 15:18:48 +00:00
Often it is desired to calculate other values from Item states or to compare Item states against other values
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
In openHAB, every item carries a state.
The state of an Item is an Object itself and can be accessed with `MyItem.state` .
2019-12-27 15:18:48 +00:00
A complete and up-to-date list of item types are currently allowed in OpenHAB and the command types each item can accept is given in the [openHab documentation for items ]({{base}}/concepts/items.html ).
To use the state of an Item in rules it is often necessary to know what type of state the Item is carrying and how to convert it into types that can be used in such operations.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Conversely, to use the result of a calculation to modify the state of an item may require its transformation into a suitable type.
2019-12-27 15:18:48 +00:00
This section differentiates between command type and state type.
For ease of reading, it is possible to simply add “type” to the end of a command type thereby obtaining the state type.
For example, a Color Item can receive an OnOffType, IncreaseDecreaseType, PercentType, or HSBType.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Therefore the following are all valid commands one can send to a Color Item:
2021-01-10 12:50:59 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
- `MyColorItem.sendCommand(ON)`
- `MyColorItem.sendCommand(INCREASE)`
- `MyColorItem.sendCommand(new PercentType(50))`
- `MyColorItem.sendCommand(new HSBType(new DecimalType(123), new PercentType(45), new PercentType(67)))`
2019-12-27 15:18:48 +00:00
An alternative way to command or update the state of an item is through the use of specially formatted strings.
The section in the [item documentation on formatting ]({{base}}/concepts/items.html#state-and-command-type-formatting ) details the requirements for the formatting.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2019-12-27 15:18:48 +00:00
Even though many Items accept commands and updates of various different types, each stores its state internally using only one type.
The Color Item from the example above will accept various command types, but will only return an HSBType.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2019-12-27 15:18:48 +00:00
Groups can be declared with any Item type and the internal state of the Group will match that type.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
For example, `Group:Switch` will return an OnOffType for its state.
2019-12-27 15:18:48 +00:00
Each State Type provides a number of convenience methods that will greatly aid in conversion and calculations.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
There are two ways to discover these methods:
2018-07-13 20:14:47 +00:00
- Use the [openHAB VS Code Extension ](/docs/configuration/editors.html#editors.html#openhab-vs-code-extension ) and the `<ctrl><space>` key combo to list all the available methods
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
- Look at the JavaDocs for the given type.
2021-01-10 19:22:40 +00:00
For example, the [JavaDoc for HSBType ](https://openhab.org/javadoc/latest/org/openhab/core/library/types/hsbtype ) shows `getRed` , `getBlue` , and `getGreen` methods.
These methods can be called in Rules-DSL without the `get` part in name as in `(MyColorItem.state as HSBType).red)` .
They retrieve the state of MyColorItem and then casts it as HSBType to be able to use the methods associated with the HSBType.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #conversions }
2021-01-10 12:50:59 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
#### Working with Item States: Conversions
*Reminder: For a complete and up-to-date list of what item types are currently allowed in openHAB and the command types each item can accept refer to the section on [items in the openHAB documentation ]({{base}}/concepts/items.html ).*
2019-12-27 15:18:48 +00:00
Below a **non-exhaustive** list of some more common conversions.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
The interested reader is encouraged to also visit the [forum ](https://community.openhab.org ) where many more examples can be found.
##### Conversion of Item.state to String
2019-12-27 15:18:48 +00:00
All Item states can be converted into a string by invoking `MyItem.state.toString` .
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
##### Color Item
A Color Item stores an **HSBType** .
2019-12-27 15:18:48 +00:00
The HSB stands for Hue, Saturation, and Brightness.
Often one has the desired color as an RGB value (Red, Green, Blue).
The following code can be used to send an RGB value to a Color Item.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```java
import java.awt.Color
// Create item
val newColor = new Color(red, blue, green) // where red, blue, and green are ints between 0 and 255
//Saving to an Item
MyColorItem.sendCommand(new HSBType(newColor))
```
2018-10-15 17:04:50 +00:00
When individual color values from a HSBType as a PercentType are retrieved, it will be necessary to divide the PercentType by 100 and multiply by 255 to obtain a standard 8-bit per color channel RGB.
Correspondingly, for the 16 or 32 bit representation, the PercentType needs to divided by 100 and multiplied by 65535 (2 ^ 16 - 1) or 4294967295 (2 ^ 32 - 1), respectively.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```java
//Example for conversion to 8-bit representation
// In rule body
2018-10-15 17:04:50 +00:00
val red = (MyColorItem.state as HSBType).red / 100 * 255
val green = (MyColorItem.state as HSBType).green / 100 * 255
val blue = (MyColorItem.state as HSBType).blue / 100 * 255
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```
##### Contact Item
A Contact Item carries a OpenClosedType.
2019-12-27 15:18:48 +00:00
OpenClosedType is an Enumeration.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
One can convert from Open and Closed to 1 and 0 with code similar to:
```java
val contactNum = if (MyContactItem.state == OPEN) 1 else 0
```
##### DateTime Item
2020-11-28 22:11:36 +00:00
A DateTime Item carries a **DateTimeType** , which internally holds a Java `ZonedDateTime` object.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```java
// Get epoch from DateTimeType
2020-11-28 22:11:36 +00:00
val Number epoch = (MyDateTimeItem.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2020-11-28 22:11:36 +00:00
// Get epoch from Java ZonedDateTime
val Number nowEpoch = now.toInstant.toEpochMilli
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2020-11-28 22:11:36 +00:00
// Convert DateTimeType to Java ZonedDateTime
val javaZonedDateTime = (MyDateTimeItem.state as DateTimeType).zonedDateTime
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2020-11-28 22:11:36 +00:00
// Convert Java ZonedDateTime to DateTimeType
val DateTimeType date = new DateTimeType(now)
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```
2019-12-27 15:18:48 +00:00
In certain cases it is needed to convert an epoch timestamp to a human readable and/or store it in a DateTimeType and a DateTime Item.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Here an option to do so utilizing SimpleDateFormat:
```java
2020-11-28 22:11:36 +00:00
import java.time.format.DateTimeFormatter
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
// Convert epoch to a human readable
2020-11-28 22:11:36 +00:00
val DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
val long epoch = now.toInstant.toEpochMilli
val ZonedDateTime zdt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(epoch), ZoneOffset.UTC);
val String dateTimeString = zdt.format(formatter)
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
// Convert human readable time stamp to DateTimeType
2020-11-28 22:11:36 +00:00
val DateTimeType dtt = DateTimeType.valueOf(dateTimeString)
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
//convert state from Item of DateTimeType into a string
val String datetime_string = DateTime_Item.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM"))
```
2020-11-28 22:11:36 +00:00
ZonedDateTimes provide a number of useful methods for comparing date times together and/or extracting parts of the date:
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```java
2020-11-28 22:11:36 +00:00
// See if DateTimeType is before now
if(now.isBefore((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2020-11-28 22:11:36 +00:00
// See if DateTimeType is after now
if(now.isAfter((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
// Get the hour in the day from a DateTimeType
2020-11-28 22:11:36 +00:00
val hour = (MyDateTimeItem.state as DateTimeType).zonedDateTime.hour
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```
##### Dimmer Item
A Dimmer Item carries a **PercentType** .
2019-12-27 15:18:48 +00:00
PercentType can be cast to and treated like a java.lang.Number, where Number represents any type of numerical value.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
The Rules language supports doing mathematical and logical operations with Numbers
The Number Object supports methods for getting primitive versions of that Number if needed.
```java
//Loading from an Item
val dimVal = MyDimmerItem.state as Number
//as integer
val int dimAsInt = dimVal.intValue
// as float
val float dimAsFloat = dimVal.floatValue
```
If the conversion from or into hexadecimal values is necessary, the following examples may be useful:
```java
2019-12-27 15:18:48 +00:00
// to convert a hex_code (a number expressed in hexadecimals) to a Number type
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
val dimVal = Integer.parseInt(hex_code, 16) as Number
//for very large_hex_codes use
val dimVal = Long.valueOf(large_hex_code, 16).longValue() as Number
// and here an additional example to convert an integer_value to hex_code string
var String hex = Long.toHexString(integer_value);
```
Additional conversions that might be useful are listed below under NumberItem
##### Location Item
A Location Items carries a **PointType** .
2019-12-27 15:18:48 +00:00
A PointType consist of two or three DecimalType numbers representing latitude and longitude in degrees, and an optional altitude in meters.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Here are a few examples:
```java
// Creation
val location = new PointType(new DecimalType(50.12345), new DecimalType(10.12345))
// Creation from String; ATTENTION: do not add space after comma
val PointType home = new PointType("12.121212,123.123123")
// Loading from an Item
val PointType location = Device_Coordinates.state as PointType
```
##### Number Item
2018-06-03 09:30:51 +00:00
A Number Items carries either a **DecimalType** or a **QuantityType** in case the Number Item has a dimension attached (e.g. `Number:Temperature` in the items file).
In rules, units are added to a number by a `|` , where the unit has to be put in quotes, if it contains non-alphabetic characters, e.g. `10|m` , but `20|"km/h"` .
A couple of commonly used units do not necessarily require quotes, these are `°C` , `°F` , `Ω` , `°` , `%` , `m²` and `m³` , so it is ok to write `20|"°C"` , but `20|°C` will also work.
2018-05-14 18:47:40 +00:00
DecimalType and QuantityType are also java.lang.Number so all the conversions listed above under Dimmer Item apply to Number Item as well.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Here some other commonly needed conversions:
2021-01-10 15:01:56 +00:00
- For DecimalType states:
2018-05-14 18:47:40 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```java
Merge 2.5.x into main (#1266)
* Update README (2.5.x) (#1153)
Change branch name.
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update items.md (#1156)
* Added var and VA units to UoM (#1146)
VA (Volt-Ampere - apparent power) and var (Volt-Ampere reactive) are used to measure power and energy consumption in AC circuits.
Signed-off-by: Nagy Attila Gabor <mrbig@sneaker.hu>
* Fix filepath to keystore (#1148)
Default openHAB userdata environment variable should be `$OPENHAB_USERDATA`, not `$USER_DATA` shouldn't it? At least, this is the default on my fresh openHABian and also the most popular variant to find in the docs.
* Slight language corrections (#1150)
I think it reads better this way
Signed-off-by: Richard Davies <rwdrich@gmail.com>
* additional example for non default persistence service (#1152)
For me it was confusing how to pass on the serviceId into methods that already had an argument. An extra example is always good.
Signed-off-by: jaco <jaco.waes@gmail.com>
* Adding 12 new logos for OH Add-Ons page on website (#1158)
Signed-off-by: bracklanna bracklanna@users.noreply.github.com
* Added missing preset variables (#1104)
* Added missing preset variables
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Cleaned up blank lines, fixed table, and added file name for SimpleRule
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Fix broken link (#1165)
* Added Hotlink from "label" section to "state presentation" (#1167)
* Added note about broken action (#1164)
* Added note about broken action
See https://github.com/openhab/openhab-core/issues/1374
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Update index.md (#1170)
Link appears to be wrong and does not work when I click on it in Edge. Loads the same page again instead of loading the correct new page from the hyperlink.
https://www.openhab.org/docs/developer/guidelines.html
* Added Airthings logo (#1171)
* typo in exambp (#1172)
`Temperature.averageSince(now.minusMinutes(5),"influxdb")`
* file.encoding=UTF-8 (#1173)
* Update demo URL and add demo.rules URL (#1174)
Based on: https://community.openhab.org/t/demo-setup-missing/94850
Old Link is broken leading to 404.
The link to the demo.rules on github is an extra :)
* Replace outdated zulu.org link. (#1177)
* Replace outdated zulu.org link.
As of 3/23/2020 zulu.org has an SSL cert that expired on 9/28/2019. Changed link to azul.com/downloads, since that appears to be the new official source.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Changed all http links to https for installation/index.md.
All changed links working, tested on 3/24/2020.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Minor language tweak (#1178)
* Ending an active scan/stopScan (#1179)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add files via upload (#1184)
* Update persistence.md (#1185)
Clarify return objects for max/min rules extensions.
Signed-off-by: Ross Kennedy rossko@culzean.clara.co.uk
* Update things.md (#1186)
Amended example code to include using label and location when defining a Thing with a bridge that is defined elsewhere.
* Correct typos (#1190)
* Correct usage of its/it's
"It's" is always a contraction of "it is" or "it has". "Its" is a
possessive. Correct a few places where they were used backwards.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct "Z-Wave" spelling
Per https://www.z-wave.com/, the canonical spelling appears to be "Z-Wave".
Most places use "Z-Wave" already; change the remaining references to match.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct typos and grammatical errors
Correct some typos and grammatical errors.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Update sitemap.md section charts (#1191)
I observed that the unique first word in the labels of items charted in a group isn't causing an empty chart anymore. I'm on openHAB 2.5.1.
Signed-off-by: Juergen Baginski opus42@gmx.de
* Add image for insteon binding (#1196)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* typo (#1198)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Installation details (#1197)
Added more details around the installation and configuration process.
Fixed that engine no longer logs "Activated scripting support..."
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update sitemaps.md (#1202)
Added full item definition for usage of visibility. See https://community.openhab.org/t/sitemap-visibility-basic-ui/97304/9
* Updated ecobee logo (https://brand.ecobee.com/) (#1203)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* tutorial: Fix description of sitemap 'type' (#1204)
In the tutorial, the generic sitemap description says that ItemType has
to be the same as the type defined in default.items.
Looking at
https://www.openhab.org/docs/configuration/items.html#type and
https://www.openhab.org/docs/configuration/sitemaps.html#element-types
this is incorrect as they take different values.
The example is even mislading as `Switch` is one of the only types which
is common between items and sitemaps. Might be better to describe
`Default` instead.
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
* Added information about DateTime Group functions LATEST/EARLIEST (#1206)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Add section for documentation contributions (#1205)
Hopefully this will lower the hurdle for people to submit documentation contributions. I know from myself that I didn't submit various documentation improvements, because I didn't know git and thought it would be a much more involved process.
Ideally there would be a separate documentation section, but submitting this under the development contribution page for now (as per discussion with @Confectrician in https://github.com/openhab/openhab-docs/pull/1179#issuecomment-605642091).
Note that I am addressing the issue of DCO failures wrt specifying the full name that I ran into myself in https://github.com/openhab/openhab-docs/pull/1197#issuecomment-615597308. I found a good discussion of the issue at https://github.com/probot/dco/issues/43.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* fix typo (#1209)
* add description of Ephemeris localization support (#1210)
Add a new section to describe the localization support and how-to steps
Signed-off-by: Michael Roßner Schrott.Micha@web.de
* Line 115 broken link - should be: (#1217)
* Line 115 broken link - should be:
({{base}}/docs/configuration/sitemaps.html#element-types)
was:
({{base}}/configuration/configuration/sitemaps.html#element-types)
* Removed diplicated docs breadcrumb
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* add missing space between words (#1212)
* Update configuration.md (#1215)
I'm a beginner myself. Though I liked this tutorial very much, it took me some time trying and erroring and finally reading forum posts to get behind this. I didn't even know there was something like a more modern ping. So maybe others are happy to learn this right from the beginning.
* Remove architecture from Docker tags (#1220)
Docker automatically detects the architecture and downloads the appropriate image (openhab/openhab-docker#213).
BuildKit will no longer generate new tags having the architecture (openhab/openhab-docker#293).
Signed-off-by: Wouter Born <github@maindrain.net>
* slight readability improvements (#1221)
* slight readability improvements
* Update introduction.md
* Update introduction.md
* minor wording update
* Update eclipse.md (#1225)
Clarifying that it's no longer possible to make changes in the Core Framework for 2.5.x.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* [fmiweather] logo for FMI Weather binding (#929)
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
* Update eclipse.md (#1226)
Added additional structure around install, run, debug and update steps. Provided more pointers to interactions with Eclipse, Maven and Git.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1227)
Need to escape \< and \> in the sign off message format so users see them explicitly in the Contributing to the Documentation section.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1228)
Small refinement on documentation change submission flow.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add doc folder to the binding directory structure (#1230)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Make Subheadings Use Proper Subheading Syntax (#1234)
This way they render out as proper markdown and don't look weird on the website
Signed-off-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
* Remove unnecessary isCancelled() from code example (#1235)
Cancelling an already canceled task has no effect. IMHO this check is not necesssary and removal would simplify the code. I came to this because I saw this pattern in many bindings during reviewing.
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Update thing-xml.md (#1236)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Fix broken ESH links (#1231)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update logging.md (#1238)
Add information on how to find out the symbolic names of the bundles
* Remove Apache Commons from Default Libraries (#1229)
See openhab/openhab-addons#7722
Signed-off-by: Fabian Wolter <git@fabian-wolter.de>
* Update introduction.md (#1239)
* Update introduction.md
Signed-off-by: Markus Storm markus.storm@gmx.net
* Update introduction.md
* Revise Java recommendations (#1240)
* Revise Java recommendations
* Delete pine.md
Do not recommend PINE, it's not supported any longer by openHABian.
* Removed sidebar link in config
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Update security.md (#1241)
Been using FreeDNS for many years (ever since all these companies got rid of their free tiers) and never an issue!
* Fix DecimalType hex conversion example (#1243)
See: https://github.com/openhab/openhab-core/issues/1526
Signed-off-by: Wouter Born <github@maindrain.net>
* Fix typo (#1244)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update persistence.md (#1246)
Fixes link to quartz docs page.
* Revision. (openhab#1187) (#1237)
* Revision. (openhab#1187)
- Update of screenshots, removal of old screenshots
- Chapters for better formatting
- Removal of ZWave chapter (one example of adding things should be enough IMHO)
- Adding items in simple mode and in "manual" mode
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
* Use one line per sentence
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Add notes for configuring Synology Diskstation (#1219)
* Add notes for configuring Synology Diskstation
I have a working set up for SSL enabled remote access on a Synology diskstation, taking advantage of the GUI as much as possible, to ensure automatic renewal of certs from Let's Encrypt, etc. It took me about 8 hours to suss it all out, but it could be achieved in about 30 mins if you knew exactly what to do... may not be widely useful, but since Synology is officially supported, I figured this might be a good addition.
There's also a minor error in the 'allow' masks - these should be 192.168.0.0/24 to allow access to anything in the 192.168.0.xxx range.
* Updated to use one line per sentence
Updated to use one line per sentence - sorry for the delay!
* Update security.md
* Updated for one line per sentence
Updated for one line per sentence
Signed-off-by: Andrew Mills mills@prettymachine.co.nz
* Bad subnet (#1245)
Nginx warns about low address bits of `192.168.0.1/24` because they are meaningless.
The correct subnet mask should be `192.168.0.0/24`
Signed-off-by: Olivier Béraud <olivierberaud@free.fr>
* Fixed broken images. (#1247)
* Fixed broken images.
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* Fix image path
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* [documentation] clarification of representation property (#1248)
* [documentation] clarification of representation property
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopt suggestions of reviewers
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] commas
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] addopted suggestions of @bobadair
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] example added back
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] simplified text
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopted reviewer comment
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* Add Alexa mapping along side a channel mapping (#1249)
* Add Alexa mapping along side a channel mapping
It took me a while to find this https://community.openhab.org/t/tagging-devices-for-alexa-support/98155/3 on the Forum and its not clearly documented in the openHAB Amazon Alexa Smart Home Skill or here in Item Metadata.
I originally suggested this as an update to the openHAB Amazon Alexa Smart Home Skill documentaion, but it fits better here, then other integrations using metadata (e.g. HomeKit or Google Assistant) could refer to it as well.
* Update items.md
* Mention defaults for element type setpoint. (#1250)
Mention defaults for min, max and step value for element type setpoint.
Signed-off-by: Thomas Weiler <toweosp@gmail.com>
* Update index.md (#1251)
I thought 'workl' was probably intended to be 'work'.
* Items - Bedroom_Light written as Light_Bedroom (#1252)
Fix small error which might mislead some readers.
* Added example for time-weighted averages (#1253)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Remove deprecated UIs, Eclipse Marketplace from sidebar
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update branch name in README
Signed-off-by: Yannick Schaus <github@schaus.net>
Co-authored-by: Markus Storm <markus.storm@gmx.net>
Co-authored-by: Nagy Attila Gábor <mrbig@sneaker.hu>
Co-authored-by: Christoph Thiede <38782922+LinqLover@users.noreply.github.com>
Co-authored-by: Richard Davies <rwdrich@gmail.com>
Co-authored-by: jwaes <50528773+jwaes@users.noreply.github.com>
Co-authored-by: bracklanna <16140600+bracklanna@users.noreply.github.com>
Co-authored-by: Scott Rushworth <openhab@5iver.com>
Co-authored-by: cpmeister <mistercpp2000@gmail.com>
Co-authored-by: Ross Kennedy <rossko@culzean.clara.co.uk>
Co-authored-by: Christoph Weitkamp <github@christophweitkamp.de>
Co-authored-by: Skinah <32607303+Skinah@users.noreply.github.com>
Co-authored-by: pali <pauli.anttila@gmail.com>
Co-authored-by: ljsquare <laurens-jan@merkx-ewals.nl>
Co-authored-by: PatrikG <40170469+PatrikG8@users.noreply.github.com>
Co-authored-by: Elias H <E.Hackradt@web.de>
Co-authored-by: Billy Stevens <contact@wasv.me>
Co-authored-by: theiding <mark.theiding@gmail.com>
Co-authored-by: jadcx <60408305+jadcx@users.noreply.github.com>
Co-authored-by: Bjorn Helgaas <bjorn@helgaas.com>
Co-authored-by: Jürgen Baginski <opus42@gmx.de>
Co-authored-by: robnielsen <rob.nielsen@yahoo.com>
Co-authored-by: GumbyMan82 <40233411+GumbyMan82@users.noreply.github.com>
Co-authored-by: Christophe Fergeau <teuf@gnome.org>
Co-authored-by: Paulo "JCranky" Siqueira <paulo.siqueira@gmail.com>
Co-authored-by: Michael Rossner <Schrott.Micha@web.de>
Co-authored-by: BugSmurF <52825547+bugsmurf@users.noreply.github.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: josefscript <64727123+josefscript@users.noreply.github.com>
Co-authored-by: Wouter Born <github@maindrain.net>
Co-authored-by: Sami Salonen <ssalonen@gmail.com>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
Co-authored-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
Co-authored-by: TRS-80 <25938297+TRSx80@users.noreply.github.com>
Co-authored-by: sihui <10405486+sihui62@users.noreply.github.com>
Co-authored-by: Andrew Mills <amil109@users.noreply.github.com>
Co-authored-by: Olivier Béraud <olivbd@users.noreply.github.com>
Co-authored-by: Andrew Fiddian-Green <software@whitebear.ch>
Co-authored-by: LeeC77 <LeeC77@users.noreply.github.com>
Co-authored-by: Thomas Weiler <18066810+toweosp@users.noreply.github.com>
Co-authored-by: garretcook <garretcook@gmail.com>
Co-authored-by: Michael Fielding <michael.fielding@gmail.com>
2020-09-21 11:29:39 +00:00
// convert integer_number to string containing hex_code
var String hex_code = Long.toHexString(integer_number)
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Merge 2.5.x into main (#1266)
* Update README (2.5.x) (#1153)
Change branch name.
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update items.md (#1156)
* Added var and VA units to UoM (#1146)
VA (Volt-Ampere - apparent power) and var (Volt-Ampere reactive) are used to measure power and energy consumption in AC circuits.
Signed-off-by: Nagy Attila Gabor <mrbig@sneaker.hu>
* Fix filepath to keystore (#1148)
Default openHAB userdata environment variable should be `$OPENHAB_USERDATA`, not `$USER_DATA` shouldn't it? At least, this is the default on my fresh openHABian and also the most popular variant to find in the docs.
* Slight language corrections (#1150)
I think it reads better this way
Signed-off-by: Richard Davies <rwdrich@gmail.com>
* additional example for non default persistence service (#1152)
For me it was confusing how to pass on the serviceId into methods that already had an argument. An extra example is always good.
Signed-off-by: jaco <jaco.waes@gmail.com>
* Adding 12 new logos for OH Add-Ons page on website (#1158)
Signed-off-by: bracklanna bracklanna@users.noreply.github.com
* Added missing preset variables (#1104)
* Added missing preset variables
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Cleaned up blank lines, fixed table, and added file name for SimpleRule
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Fix broken link (#1165)
* Added Hotlink from "label" section to "state presentation" (#1167)
* Added note about broken action (#1164)
* Added note about broken action
See https://github.com/openhab/openhab-core/issues/1374
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Update index.md (#1170)
Link appears to be wrong and does not work when I click on it in Edge. Loads the same page again instead of loading the correct new page from the hyperlink.
https://www.openhab.org/docs/developer/guidelines.html
* Added Airthings logo (#1171)
* typo in exambp (#1172)
`Temperature.averageSince(now.minusMinutes(5),"influxdb")`
* file.encoding=UTF-8 (#1173)
* Update demo URL and add demo.rules URL (#1174)
Based on: https://community.openhab.org/t/demo-setup-missing/94850
Old Link is broken leading to 404.
The link to the demo.rules on github is an extra :)
* Replace outdated zulu.org link. (#1177)
* Replace outdated zulu.org link.
As of 3/23/2020 zulu.org has an SSL cert that expired on 9/28/2019. Changed link to azul.com/downloads, since that appears to be the new official source.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Changed all http links to https for installation/index.md.
All changed links working, tested on 3/24/2020.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Minor language tweak (#1178)
* Ending an active scan/stopScan (#1179)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add files via upload (#1184)
* Update persistence.md (#1185)
Clarify return objects for max/min rules extensions.
Signed-off-by: Ross Kennedy rossko@culzean.clara.co.uk
* Update things.md (#1186)
Amended example code to include using label and location when defining a Thing with a bridge that is defined elsewhere.
* Correct typos (#1190)
* Correct usage of its/it's
"It's" is always a contraction of "it is" or "it has". "Its" is a
possessive. Correct a few places where they were used backwards.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct "Z-Wave" spelling
Per https://www.z-wave.com/, the canonical spelling appears to be "Z-Wave".
Most places use "Z-Wave" already; change the remaining references to match.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct typos and grammatical errors
Correct some typos and grammatical errors.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Update sitemap.md section charts (#1191)
I observed that the unique first word in the labels of items charted in a group isn't causing an empty chart anymore. I'm on openHAB 2.5.1.
Signed-off-by: Juergen Baginski opus42@gmx.de
* Add image for insteon binding (#1196)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* typo (#1198)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Installation details (#1197)
Added more details around the installation and configuration process.
Fixed that engine no longer logs "Activated scripting support..."
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update sitemaps.md (#1202)
Added full item definition for usage of visibility. See https://community.openhab.org/t/sitemap-visibility-basic-ui/97304/9
* Updated ecobee logo (https://brand.ecobee.com/) (#1203)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* tutorial: Fix description of sitemap 'type' (#1204)
In the tutorial, the generic sitemap description says that ItemType has
to be the same as the type defined in default.items.
Looking at
https://www.openhab.org/docs/configuration/items.html#type and
https://www.openhab.org/docs/configuration/sitemaps.html#element-types
this is incorrect as they take different values.
The example is even mislading as `Switch` is one of the only types which
is common between items and sitemaps. Might be better to describe
`Default` instead.
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
* Added information about DateTime Group functions LATEST/EARLIEST (#1206)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Add section for documentation contributions (#1205)
Hopefully this will lower the hurdle for people to submit documentation contributions. I know from myself that I didn't submit various documentation improvements, because I didn't know git and thought it would be a much more involved process.
Ideally there would be a separate documentation section, but submitting this under the development contribution page for now (as per discussion with @Confectrician in https://github.com/openhab/openhab-docs/pull/1179#issuecomment-605642091).
Note that I am addressing the issue of DCO failures wrt specifying the full name that I ran into myself in https://github.com/openhab/openhab-docs/pull/1197#issuecomment-615597308. I found a good discussion of the issue at https://github.com/probot/dco/issues/43.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* fix typo (#1209)
* add description of Ephemeris localization support (#1210)
Add a new section to describe the localization support and how-to steps
Signed-off-by: Michael Roßner Schrott.Micha@web.de
* Line 115 broken link - should be: (#1217)
* Line 115 broken link - should be:
({{base}}/docs/configuration/sitemaps.html#element-types)
was:
({{base}}/configuration/configuration/sitemaps.html#element-types)
* Removed diplicated docs breadcrumb
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* add missing space between words (#1212)
* Update configuration.md (#1215)
I'm a beginner myself. Though I liked this tutorial very much, it took me some time trying and erroring and finally reading forum posts to get behind this. I didn't even know there was something like a more modern ping. So maybe others are happy to learn this right from the beginning.
* Remove architecture from Docker tags (#1220)
Docker automatically detects the architecture and downloads the appropriate image (openhab/openhab-docker#213).
BuildKit will no longer generate new tags having the architecture (openhab/openhab-docker#293).
Signed-off-by: Wouter Born <github@maindrain.net>
* slight readability improvements (#1221)
* slight readability improvements
* Update introduction.md
* Update introduction.md
* minor wording update
* Update eclipse.md (#1225)
Clarifying that it's no longer possible to make changes in the Core Framework for 2.5.x.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* [fmiweather] logo for FMI Weather binding (#929)
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
* Update eclipse.md (#1226)
Added additional structure around install, run, debug and update steps. Provided more pointers to interactions with Eclipse, Maven and Git.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1227)
Need to escape \< and \> in the sign off message format so users see them explicitly in the Contributing to the Documentation section.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1228)
Small refinement on documentation change submission flow.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add doc folder to the binding directory structure (#1230)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Make Subheadings Use Proper Subheading Syntax (#1234)
This way they render out as proper markdown and don't look weird on the website
Signed-off-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
* Remove unnecessary isCancelled() from code example (#1235)
Cancelling an already canceled task has no effect. IMHO this check is not necesssary and removal would simplify the code. I came to this because I saw this pattern in many bindings during reviewing.
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Update thing-xml.md (#1236)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Fix broken ESH links (#1231)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update logging.md (#1238)
Add information on how to find out the symbolic names of the bundles
* Remove Apache Commons from Default Libraries (#1229)
See openhab/openhab-addons#7722
Signed-off-by: Fabian Wolter <git@fabian-wolter.de>
* Update introduction.md (#1239)
* Update introduction.md
Signed-off-by: Markus Storm markus.storm@gmx.net
* Update introduction.md
* Revise Java recommendations (#1240)
* Revise Java recommendations
* Delete pine.md
Do not recommend PINE, it's not supported any longer by openHABian.
* Removed sidebar link in config
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Update security.md (#1241)
Been using FreeDNS for many years (ever since all these companies got rid of their free tiers) and never an issue!
* Fix DecimalType hex conversion example (#1243)
See: https://github.com/openhab/openhab-core/issues/1526
Signed-off-by: Wouter Born <github@maindrain.net>
* Fix typo (#1244)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update persistence.md (#1246)
Fixes link to quartz docs page.
* Revision. (openhab#1187) (#1237)
* Revision. (openhab#1187)
- Update of screenshots, removal of old screenshots
- Chapters for better formatting
- Removal of ZWave chapter (one example of adding things should be enough IMHO)
- Adding items in simple mode and in "manual" mode
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
* Use one line per sentence
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Add notes for configuring Synology Diskstation (#1219)
* Add notes for configuring Synology Diskstation
I have a working set up for SSL enabled remote access on a Synology diskstation, taking advantage of the GUI as much as possible, to ensure automatic renewal of certs from Let's Encrypt, etc. It took me about 8 hours to suss it all out, but it could be achieved in about 30 mins if you knew exactly what to do... may not be widely useful, but since Synology is officially supported, I figured this might be a good addition.
There's also a minor error in the 'allow' masks - these should be 192.168.0.0/24 to allow access to anything in the 192.168.0.xxx range.
* Updated to use one line per sentence
Updated to use one line per sentence - sorry for the delay!
* Update security.md
* Updated for one line per sentence
Updated for one line per sentence
Signed-off-by: Andrew Mills mills@prettymachine.co.nz
* Bad subnet (#1245)
Nginx warns about low address bits of `192.168.0.1/24` because they are meaningless.
The correct subnet mask should be `192.168.0.0/24`
Signed-off-by: Olivier Béraud <olivierberaud@free.fr>
* Fixed broken images. (#1247)
* Fixed broken images.
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* Fix image path
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* [documentation] clarification of representation property (#1248)
* [documentation] clarification of representation property
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopt suggestions of reviewers
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] commas
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] addopted suggestions of @bobadair
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] example added back
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] simplified text
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopted reviewer comment
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* Add Alexa mapping along side a channel mapping (#1249)
* Add Alexa mapping along side a channel mapping
It took me a while to find this https://community.openhab.org/t/tagging-devices-for-alexa-support/98155/3 on the Forum and its not clearly documented in the openHAB Amazon Alexa Smart Home Skill or here in Item Metadata.
I originally suggested this as an update to the openHAB Amazon Alexa Smart Home Skill documentaion, but it fits better here, then other integrations using metadata (e.g. HomeKit or Google Assistant) could refer to it as well.
* Update items.md
* Mention defaults for element type setpoint. (#1250)
Mention defaults for min, max and step value for element type setpoint.
Signed-off-by: Thomas Weiler <toweosp@gmail.com>
* Update index.md (#1251)
I thought 'workl' was probably intended to be 'work'.
* Items - Bedroom_Light written as Light_Bedroom (#1252)
Fix small error which might mislead some readers.
* Added example for time-weighted averages (#1253)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Remove deprecated UIs, Eclipse Marketplace from sidebar
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update branch name in README
Signed-off-by: Yannick Schaus <github@schaus.net>
Co-authored-by: Markus Storm <markus.storm@gmx.net>
Co-authored-by: Nagy Attila Gábor <mrbig@sneaker.hu>
Co-authored-by: Christoph Thiede <38782922+LinqLover@users.noreply.github.com>
Co-authored-by: Richard Davies <rwdrich@gmail.com>
Co-authored-by: jwaes <50528773+jwaes@users.noreply.github.com>
Co-authored-by: bracklanna <16140600+bracklanna@users.noreply.github.com>
Co-authored-by: Scott Rushworth <openhab@5iver.com>
Co-authored-by: cpmeister <mistercpp2000@gmail.com>
Co-authored-by: Ross Kennedy <rossko@culzean.clara.co.uk>
Co-authored-by: Christoph Weitkamp <github@christophweitkamp.de>
Co-authored-by: Skinah <32607303+Skinah@users.noreply.github.com>
Co-authored-by: pali <pauli.anttila@gmail.com>
Co-authored-by: ljsquare <laurens-jan@merkx-ewals.nl>
Co-authored-by: PatrikG <40170469+PatrikG8@users.noreply.github.com>
Co-authored-by: Elias H <E.Hackradt@web.de>
Co-authored-by: Billy Stevens <contact@wasv.me>
Co-authored-by: theiding <mark.theiding@gmail.com>
Co-authored-by: jadcx <60408305+jadcx@users.noreply.github.com>
Co-authored-by: Bjorn Helgaas <bjorn@helgaas.com>
Co-authored-by: Jürgen Baginski <opus42@gmx.de>
Co-authored-by: robnielsen <rob.nielsen@yahoo.com>
Co-authored-by: GumbyMan82 <40233411+GumbyMan82@users.noreply.github.com>
Co-authored-by: Christophe Fergeau <teuf@gnome.org>
Co-authored-by: Paulo "JCranky" Siqueira <paulo.siqueira@gmail.com>
Co-authored-by: Michael Rossner <Schrott.Micha@web.de>
Co-authored-by: BugSmurF <52825547+bugsmurf@users.noreply.github.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: josefscript <64727123+josefscript@users.noreply.github.com>
Co-authored-by: Wouter Born <github@maindrain.net>
Co-authored-by: Sami Salonen <ssalonen@gmail.com>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
Co-authored-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
Co-authored-by: TRS-80 <25938297+TRSx80@users.noreply.github.com>
Co-authored-by: sihui <10405486+sihui62@users.noreply.github.com>
Co-authored-by: Andrew Mills <amil109@users.noreply.github.com>
Co-authored-by: Olivier Béraud <olivbd@users.noreply.github.com>
Co-authored-by: Andrew Fiddian-Green <software@whitebear.ch>
Co-authored-by: LeeC77 <LeeC77@users.noreply.github.com>
Co-authored-by: Thomas Weiler <18066810+toweosp@users.noreply.github.com>
Co-authored-by: garretcook <garretcook@gmail.com>
Co-authored-by: Michael Fielding <michael.fielding@gmail.com>
2020-09-21 11:29:39 +00:00
// convert hex_code to Number type
var myNumber = Integer.parseInt(hex_code, 16) as Number
// use the following for large_hex_code
var myNumber = Long.parseLong(hex, 16) as Number
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Merge 2.5.x into main (#1266)
* Update README (2.5.x) (#1153)
Change branch name.
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update items.md (#1156)
* Added var and VA units to UoM (#1146)
VA (Volt-Ampere - apparent power) and var (Volt-Ampere reactive) are used to measure power and energy consumption in AC circuits.
Signed-off-by: Nagy Attila Gabor <mrbig@sneaker.hu>
* Fix filepath to keystore (#1148)
Default openHAB userdata environment variable should be `$OPENHAB_USERDATA`, not `$USER_DATA` shouldn't it? At least, this is the default on my fresh openHABian and also the most popular variant to find in the docs.
* Slight language corrections (#1150)
I think it reads better this way
Signed-off-by: Richard Davies <rwdrich@gmail.com>
* additional example for non default persistence service (#1152)
For me it was confusing how to pass on the serviceId into methods that already had an argument. An extra example is always good.
Signed-off-by: jaco <jaco.waes@gmail.com>
* Adding 12 new logos for OH Add-Ons page on website (#1158)
Signed-off-by: bracklanna bracklanna@users.noreply.github.com
* Added missing preset variables (#1104)
* Added missing preset variables
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Cleaned up blank lines, fixed table, and added file name for SimpleRule
Signed-off-by: Scott Rushworth <openhab@5iver.com>
* Fix broken link (#1165)
* Added Hotlink from "label" section to "state presentation" (#1167)
* Added note about broken action (#1164)
* Added note about broken action
See https://github.com/openhab/openhab-core/issues/1374
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Incorporated changes from review
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Update index.md (#1170)
Link appears to be wrong and does not work when I click on it in Edge. Loads the same page again instead of loading the correct new page from the hyperlink.
https://www.openhab.org/docs/developer/guidelines.html
* Added Airthings logo (#1171)
* typo in exambp (#1172)
`Temperature.averageSince(now.minusMinutes(5),"influxdb")`
* file.encoding=UTF-8 (#1173)
* Update demo URL and add demo.rules URL (#1174)
Based on: https://community.openhab.org/t/demo-setup-missing/94850
Old Link is broken leading to 404.
The link to the demo.rules on github is an extra :)
* Replace outdated zulu.org link. (#1177)
* Replace outdated zulu.org link.
As of 3/23/2020 zulu.org has an SSL cert that expired on 9/28/2019. Changed link to azul.com/downloads, since that appears to be the new official source.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Changed all http links to https for installation/index.md.
All changed links working, tested on 3/24/2020.
Signed-off-by: Billy Stevens <contact@wasv.me>
* Minor language tweak (#1178)
* Ending an active scan/stopScan (#1179)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add files via upload (#1184)
* Update persistence.md (#1185)
Clarify return objects for max/min rules extensions.
Signed-off-by: Ross Kennedy rossko@culzean.clara.co.uk
* Update things.md (#1186)
Amended example code to include using label and location when defining a Thing with a bridge that is defined elsewhere.
* Correct typos (#1190)
* Correct usage of its/it's
"It's" is always a contraction of "it is" or "it has". "Its" is a
possessive. Correct a few places where they were used backwards.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct "Z-Wave" spelling
Per https://www.z-wave.com/, the canonical spelling appears to be "Z-Wave".
Most places use "Z-Wave" already; change the remaining references to match.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Correct typos and grammatical errors
Correct some typos and grammatical errors.
Signed-off-by: Bjorn Helgaas <bjorn@helgaas.com>
* Update sitemap.md section charts (#1191)
I observed that the unique first word in the labels of items charted in a group isn't causing an empty chart anymore. I'm on openHAB 2.5.1.
Signed-off-by: Juergen Baginski opus42@gmx.de
* Add image for insteon binding (#1196)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* typo (#1198)
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Installation details (#1197)
Added more details around the installation and configuration process.
Fixed that engine no longer logs "Activated scripting support..."
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update sitemaps.md (#1202)
Added full item definition for usage of visibility. See https://community.openhab.org/t/sitemap-visibility-basic-ui/97304/9
* Updated ecobee logo (https://brand.ecobee.com/) (#1203)
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
* tutorial: Fix description of sitemap 'type' (#1204)
In the tutorial, the generic sitemap description says that ItemType has
to be the same as the type defined in default.items.
Looking at
https://www.openhab.org/docs/configuration/items.html#type and
https://www.openhab.org/docs/configuration/sitemaps.html#element-types
this is incorrect as they take different values.
The example is even mislading as `Switch` is one of the only types which
is common between items and sitemaps. Might be better to describe
`Default` instead.
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
* Added information about DateTime Group functions LATEST/EARLIEST (#1206)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Add section for documentation contributions (#1205)
Hopefully this will lower the hurdle for people to submit documentation contributions. I know from myself that I didn't submit various documentation improvements, because I didn't know git and thought it would be a much more involved process.
Ideally there would be a separate documentation section, but submitting this under the development contribution page for now (as per discussion with @Confectrician in https://github.com/openhab/openhab-docs/pull/1179#issuecomment-605642091).
Note that I am addressing the issue of DCO failures wrt specifying the full name that I ran into myself in https://github.com/openhab/openhab-docs/pull/1197#issuecomment-615597308. I found a good discussion of the issue at https://github.com/probot/dco/issues/43.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* fix typo (#1209)
* add description of Ephemeris localization support (#1210)
Add a new section to describe the localization support and how-to steps
Signed-off-by: Michael Roßner Schrott.Micha@web.de
* Line 115 broken link - should be: (#1217)
* Line 115 broken link - should be:
({{base}}/docs/configuration/sitemaps.html#element-types)
was:
({{base}}/configuration/configuration/sitemaps.html#element-types)
* Removed diplicated docs breadcrumb
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* add missing space between words (#1212)
* Update configuration.md (#1215)
I'm a beginner myself. Though I liked this tutorial very much, it took me some time trying and erroring and finally reading forum posts to get behind this. I didn't even know there was something like a more modern ping. So maybe others are happy to learn this right from the beginning.
* Remove architecture from Docker tags (#1220)
Docker automatically detects the architecture and downloads the appropriate image (openhab/openhab-docker#213).
BuildKit will no longer generate new tags having the architecture (openhab/openhab-docker#293).
Signed-off-by: Wouter Born <github@maindrain.net>
* slight readability improvements (#1221)
* slight readability improvements
* Update introduction.md
* Update introduction.md
* minor wording update
* Update eclipse.md (#1225)
Clarifying that it's no longer possible to make changes in the Core Framework for 2.5.x.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* [fmiweather] logo for FMI Weather binding (#929)
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
* Update eclipse.md (#1226)
Added additional structure around install, run, debug and update steps. Provided more pointers to interactions with Eclipse, Maven and Git.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1227)
Need to escape \< and \> in the sign off message format so users see them explicitly in the Contributing to the Documentation section.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Update contributing.md (#1228)
Small refinement on documentation change submission flow.
Signed-off-by: Mark Theiding <mark.theiding@gmail.com>
* Add doc folder to the binding directory structure (#1230)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Make Subheadings Use Proper Subheading Syntax (#1234)
This way they render out as proper markdown and don't look weird on the website
Signed-off-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
* Remove unnecessary isCancelled() from code example (#1235)
Cancelling an already canceled task has no effect. IMHO this check is not necesssary and removal would simplify the code. I came to this because I saw this pattern in many bindings during reviewing.
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
* Update thing-xml.md (#1236)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Fix broken ESH links (#1231)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update logging.md (#1238)
Add information on how to find out the symbolic names of the bundles
* Remove Apache Commons from Default Libraries (#1229)
See openhab/openhab-addons#7722
Signed-off-by: Fabian Wolter <git@fabian-wolter.de>
* Update introduction.md (#1239)
* Update introduction.md
Signed-off-by: Markus Storm markus.storm@gmx.net
* Update introduction.md
* Revise Java recommendations (#1240)
* Revise Java recommendations
* Delete pine.md
Do not recommend PINE, it's not supported any longer by openHABian.
* Removed sidebar link in config
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Update security.md (#1241)
Been using FreeDNS for many years (ever since all these companies got rid of their free tiers) and never an issue!
* Fix DecimalType hex conversion example (#1243)
See: https://github.com/openhab/openhab-core/issues/1526
Signed-off-by: Wouter Born <github@maindrain.net>
* Fix typo (#1244)
Signed-off-by: Wouter Born <github@maindrain.net>
* Update persistence.md (#1246)
Fixes link to quartz docs page.
* Revision. (openhab#1187) (#1237)
* Revision. (openhab#1187)
- Update of screenshots, removal of old screenshots
- Chapters for better formatting
- Removal of ZWave chapter (one example of adding things should be enough IMHO)
- Adding items in simple mode and in "manual" mode
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
* Use one line per sentence
Signed-off-by: Sascha Billian <sascha.billian@googlemail.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
* Add notes for configuring Synology Diskstation (#1219)
* Add notes for configuring Synology Diskstation
I have a working set up for SSL enabled remote access on a Synology diskstation, taking advantage of the GUI as much as possible, to ensure automatic renewal of certs from Let's Encrypt, etc. It took me about 8 hours to suss it all out, but it could be achieved in about 30 mins if you knew exactly what to do... may not be widely useful, but since Synology is officially supported, I figured this might be a good addition.
There's also a minor error in the 'allow' masks - these should be 192.168.0.0/24 to allow access to anything in the 192.168.0.xxx range.
* Updated to use one line per sentence
Updated to use one line per sentence - sorry for the delay!
* Update security.md
* Updated for one line per sentence
Updated for one line per sentence
Signed-off-by: Andrew Mills mills@prettymachine.co.nz
* Bad subnet (#1245)
Nginx warns about low address bits of `192.168.0.1/24` because they are meaningless.
The correct subnet mask should be `192.168.0.0/24`
Signed-off-by: Olivier Béraud <olivierberaud@free.fr>
* Fixed broken images. (#1247)
* Fixed broken images.
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* Fix image path
Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
* [documentation] clarification of representation property (#1248)
* [documentation] clarification of representation property
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopt suggestions of reviewers
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] commas
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] addopted suggestions of @bobadair
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] example added back
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentaion] simplified text
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] typo
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* [documentation] adopted reviewer comment
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
* Add Alexa mapping along side a channel mapping (#1249)
* Add Alexa mapping along side a channel mapping
It took me a while to find this https://community.openhab.org/t/tagging-devices-for-alexa-support/98155/3 on the Forum and its not clearly documented in the openHAB Amazon Alexa Smart Home Skill or here in Item Metadata.
I originally suggested this as an update to the openHAB Amazon Alexa Smart Home Skill documentaion, but it fits better here, then other integrations using metadata (e.g. HomeKit or Google Assistant) could refer to it as well.
* Update items.md
* Mention defaults for element type setpoint. (#1250)
Mention defaults for min, max and step value for element type setpoint.
Signed-off-by: Thomas Weiler <toweosp@gmail.com>
* Update index.md (#1251)
I thought 'workl' was probably intended to be 'work'.
* Items - Bedroom_Light written as Light_Bedroom (#1252)
Fix small error which might mislead some readers.
* Added example for time-weighted averages (#1253)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
* Remove deprecated UIs, Eclipse Marketplace from sidebar
Signed-off-by: Yannick Schaus <github@schaus.net>
* Update branch name in README
Signed-off-by: Yannick Schaus <github@schaus.net>
Co-authored-by: Markus Storm <markus.storm@gmx.net>
Co-authored-by: Nagy Attila Gábor <mrbig@sneaker.hu>
Co-authored-by: Christoph Thiede <38782922+LinqLover@users.noreply.github.com>
Co-authored-by: Richard Davies <rwdrich@gmail.com>
Co-authored-by: jwaes <50528773+jwaes@users.noreply.github.com>
Co-authored-by: bracklanna <16140600+bracklanna@users.noreply.github.com>
Co-authored-by: Scott Rushworth <openhab@5iver.com>
Co-authored-by: cpmeister <mistercpp2000@gmail.com>
Co-authored-by: Ross Kennedy <rossko@culzean.clara.co.uk>
Co-authored-by: Christoph Weitkamp <github@christophweitkamp.de>
Co-authored-by: Skinah <32607303+Skinah@users.noreply.github.com>
Co-authored-by: pali <pauli.anttila@gmail.com>
Co-authored-by: ljsquare <laurens-jan@merkx-ewals.nl>
Co-authored-by: PatrikG <40170469+PatrikG8@users.noreply.github.com>
Co-authored-by: Elias H <E.Hackradt@web.de>
Co-authored-by: Billy Stevens <contact@wasv.me>
Co-authored-by: theiding <mark.theiding@gmail.com>
Co-authored-by: jadcx <60408305+jadcx@users.noreply.github.com>
Co-authored-by: Bjorn Helgaas <bjorn@helgaas.com>
Co-authored-by: Jürgen Baginski <opus42@gmx.de>
Co-authored-by: robnielsen <rob.nielsen@yahoo.com>
Co-authored-by: GumbyMan82 <40233411+GumbyMan82@users.noreply.github.com>
Co-authored-by: Christophe Fergeau <teuf@gnome.org>
Co-authored-by: Paulo "JCranky" Siqueira <paulo.siqueira@gmail.com>
Co-authored-by: Michael Rossner <Schrott.Micha@web.de>
Co-authored-by: BugSmurF <52825547+bugsmurf@users.noreply.github.com>
Co-authored-by: Jerome Luckenbach <github@luckenba.ch>
Co-authored-by: josefscript <64727123+josefscript@users.noreply.github.com>
Co-authored-by: Wouter Born <github@maindrain.net>
Co-authored-by: Sami Salonen <ssalonen@gmail.com>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
Co-authored-by: Stefan Zabka <zabkaste@informatik.hu-berlin.de>
Co-authored-by: TRS-80 <25938297+TRSx80@users.noreply.github.com>
Co-authored-by: sihui <10405486+sihui62@users.noreply.github.com>
Co-authored-by: Andrew Mills <amil109@users.noreply.github.com>
Co-authored-by: Olivier Béraud <olivbd@users.noreply.github.com>
Co-authored-by: Andrew Fiddian-Green <software@whitebear.ch>
Co-authored-by: LeeC77 <LeeC77@users.noreply.github.com>
Co-authored-by: Thomas Weiler <18066810+toweosp@users.noreply.github.com>
Co-authored-by: garretcook <garretcook@gmail.com>
Co-authored-by: Michael Fielding <michael.fielding@gmail.com>
2020-09-21 11:29:39 +00:00
// convert hex_code to DecimalType
var DecimalType parsedResult = new DecimalType(Long.parseLong(hex_code, 16))
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
```
2021-01-10 15:01:56 +00:00
- For QuantityType states:
2018-05-14 18:47:40 +00:00
```java
// define a QuantityType variable
2018-05-25 14:41:58 +00:00
var myTemperature = 20|°C
2018-05-14 18:47:40 +00:00
// convert a quantity state into a different unit:
var fahrenheit = myTemperature.toUnit("°F")
// convert scalar value to DecimalType
var myDecimal = new DecimalType(fahrenheit.doubleValue) // myDecimal == 68
// access scalar values as int, double, float
var myInt = fahrenheit.intValue
var mydouble = fahrenheit.doubleValue
var myfloat = fahrenheit.floatValue
// check if a number item state is a QuantityType
var isQuantity = myItem.state instanceof QuantityType
```
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
Other useful conversions can be found under Dimmer Item.
2019-12-27 15:18:48 +00:00
One warning comes with DecimalType (also holds true for QuantityType).
The full explanation is [beyond the scope of this introduction ](https://community.openhab.org/t/ambiguous-feature-call-whats-wrong-designer-user-or-bug/9477/4 ).
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
To avoid an error mentioning an "Ambiguous Method Call" always cast the state of a DecimalType to a Number, not DecimalType.
##### Player Item
The Player item allows to control players (e.g. audio players) with commands such as Play, Pause, Next, Previous, Rewind and Fastforward.
2019-12-27 15:18:48 +00:00
The Player Item carries three types with predefined commands
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2019-01-13 13:25:05 +00:00
| State Type | Commands |
|---------------------------|---------------------|
| **PlayPauseType** | PLAY, PAUSE |
| **RewindFastforwardType** | REWIND, FASTFORWARD |
| **NextPreviousType** | NEXT, PREVIOUS |
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
These types can be convert from Open and Closed to 1 and 0 with code similar to the Contact Item (OpenClosedType)
```java
//Loading from an Item
val int Playing = if (MyPlayerItem.state == PLAY) 1 else 0
```
##### PointType
See Location item
##### Rollershutter Item
See Dimmer
In addition to the command types of the item type Dimmer, the Rollershutter item accepts the StopMoveType with the commands STOP and MOVE
##### String Item
To convert the state of an Item that carries a StringType, the method toString can be invoked.
```java
//Loading from an Item
val stateAsString = MyStringItem.state.toString
```
In case an item returns a string containing a value as a hexadecimal number, it can be converted to an integer by using
2021-01-10 15:01:56 +00:00
```shell
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
//Loading hexvalue from string
val itemvalue = new java.math.BigDecimal(Integer::parseInt(myHexValue, 16))
```
##### Switch Item
A Switch Item carries a OnOffType.
2019-12-27 15:18:48 +00:00
OnOffType is an Enumeration.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
One can convert from ON and OFF to 1 and 0 with code similar to:
```java
val SwitchNum = if (MySwitchItem.state == ON) 1 else 0
```
#### Deeper Dive
2019-12-27 15:18:48 +00:00
While interacting with Item states, care must be taken to understand the difference between Objects and primitives.
As all object-oriented computer languages, Java and the Rules DSL have implemented the concept of inheritance.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
However, inheritance only applies to Objects and does **not** apply to primitives; examples for primitives are `integer` and `boolean` .
2019-12-27 15:18:48 +00:00
Inheritance allows to take an existing Object type, called a Class, and adding to it to make it into something different.
This “something different” becomes a Child of the original Class, the parent. The Child still can do everything the parent could do.
The top level base Class for all Objects in Java and the Rules DSL is called simply `Object` .
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
2019-12-27 15:18:48 +00:00
In addition to other useful things, the class `Object` implements a method called `toString` .
And since `Object` is the parent of all Objects, ALL Classes also implement a `toString` method.
_However primitives do not inherit from Object.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
They don't inherit from anything and they don't have any methods at all which includes the lack of a toString Method._
2019-12-27 15:18:48 +00:00
Objects are typically equipped with many more type conversion methods, while primitives do not support any type conversion.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
This distinction is very relevant when trying to use the result of a calculation and apply it to an Item state.
2019-12-27 15:18:48 +00:00
The `sendCommand` is a generic action and needs to be able to work with all Item types.
Actions only support two String arguments as all Objects will support the conversion `toString` .
`sendCommand (MyItem, new_state)` will automatically use the `MyItem.toString` method to convert MyItem into a String.
It will also attempt to do so with the second argument if `new_state` is not already a String.
However, if the second argument is a primitive, and not an Object, it does not carry a method `toString` .
Thus, Rules DSL will not be able to cast `new_state` as a String.
As a consequence, the use of `sendCommand(MyItem, primitive)` , using a primitive as the second argument, will almost always fail.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
The different syntax for the generic and the objective-specific differs and is given in the table below:
| Generic (Action) | Specific (Method) |
|----------------------------------|---------------------------------|
| `postUpdate(MyItem, new_state)` | `MyItem.postUpdate(new_state)` |
| `sendCommand(MyItem, new_state)` | `MyItem.sendCommand(new_state)` |
2019-12-27 15:18:48 +00:00
The benefit of using Objects over primitives is apparent through the following type conversions that are automatically invoked by Object as the context requires.
2018-07-15 10:25:25 +00:00
Using the method `MyItems.sendCommand()` that is owned by MyItem will use the `sendCommand` method that is suitable to make the necessary type conversions.
2019-12-27 15:18:48 +00:00
For example, the `NumberItem` class would have a `sendCommand(int)` , `sendCommand(long)` , `sendCommand(float)` , `sendCommand(double)` , `sendCommand(Number)` , `sendCommand(DecimalType)` , and `sendCommand(String)` method.
Each of these separate methods is individually written to handle all of these different types of Objects.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
MyItem will automatically apply the method that corresponds to the argument type.
2017-08-27 10:07:33 +00:00
{: #implicit -variables}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Implicit Variables inside the Execution Block
2016-06-12 13:24:36 +00:00
Besides the implicitly available variables for items and commands/states, rules can have additional pre-defined variables, depending on their triggers:
2016-06-08 22:56:14 +00:00
2020-11-28 22:11:36 +00:00
- `receivedCommand` - implicitly available in every rule that has at least one command event trigger.
- `previousState` - implicitly available in every rule that has at least one status change event trigger.
- `newState` - implicitly available in every rule that has at least one status update or status change event trigger.
- `triggeringItemName` - implicitly available in every rule that has at least one status update, status change or command event trigger.
- `triggeringItem` - implicitly available in every rule that has a "Member of" trigger.
- `receivedEvent` - implicitly available in every rule that has a channel-based trigger.
2016-06-08 22:56:14 +00:00
2017-08-27 10:07:33 +00:00
{: #return }
2021-01-10 12:50:59 +00:00
2017-07-27 11:01:43 +00:00
### Early returns
It is possible to return early from a rule, not executing the rest of the statements like this:
```java
if (Temperature.state > 20) {
2021-01-10 12:50:59 +00:00
return;
2017-07-27 11:01:43 +00:00
}
2017-08-27 10:07:33 +00:00
Heating.sendCommand(ON)
2017-07-27 11:01:43 +00:00
```
Caveat: Please note the semicolon after the return statement which terminates the command without an additional argument.
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #concurrency -guard}
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Concurrency Guard
2017-07-20 16:47:28 +00:00
2016-06-08 22:56:14 +00:00
If a rule triggers on UI events it may be necessary to guard against concurrency.
2017-07-20 16:47:28 +00:00
```javascript
2016-06-08 22:56:14 +00:00
import java.util.concurrent.locks.ReentrantLock
2017-10-16 16:33:02 +00:00
val ReentrantLock lock = new ReentrantLock()
2016-06-08 22:56:14 +00:00
rule ConcurrentCode
when
2017-07-20 16:47:28 +00:00
Item Dummy received update
2016-06-08 22:56:14 +00:00
then
2017-07-20 16:47:28 +00:00
lock.lock()
try {
// do stuff
} finally{
lock.unlock()
}
2016-06-08 22:56:14 +00:00
end
```
2017-09-22 19:20:58 +00:00
{: #transformations }
2021-01-10 12:50:59 +00:00
2017-09-22 19:20:58 +00:00
### Transformations
2018-07-13 20:14:47 +00:00
openHAB [Transformation services ](/addons/#transform ) can be used in rules to transform/translate/convert data.
2018-05-25 14:41:58 +00:00
2017-09-22 19:20:58 +00:00
The general syntax is as follows:
```java
transform("< transformation-identifier > ", "< transf. expression or transf . file name > ", < input-data or variable > )
```
- `<transformation-identifier>` - Shorthand identifier of the transformation service
- `<transf. expression or transf. file name>` - Transformation service specific
- `<input-data or variable>` - The data to transform, MUST be of data type *String*
Examples:
```java
var condition = transform("MAP", "window_esp.map", "CLOSED")
var temperature = transform("JSONPATH", "$.temperature", jsonstring)
var fahrenheit = transform("JS", "convert-C-to-F.js", temperature)
```
2018-05-25 14:41:58 +00:00
The `transform` method tries to transform the given value and if it does not succeed it returns the original unchanged value.
In contrast to the `transform` method, the `transformRaw` method does not catch any `TransformationException` s internally, but throws them, so that the caller can handle it.
```java
transformRaw("< transformation-identifier > ", "< transf. expression or transf . file name > ", < input-data or variable > )
```
Example:
```java
try {
2018-09-04 07:45:13 +00:00
var temperature = transformRaw("JSONPATH", "$.temperature", jsonstring)
2018-05-25 14:41:58 +00:00
}
catch(TransformationException e) {
logError("Error", "Some bad stuff happened in my rule: " + e.getMessage)
}
finally {
// always runs even if there was an error, good place for cleanup
}
```
2018-07-13 20:14:47 +00:00
For all available Transformation services please refer to the list of [Transformation Add-ons ](/addons/#transform ).
2017-09-22 19:20:58 +00:00
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
{: #logging }
2021-01-10 12:50:59 +00:00
2016-06-08 22:56:14 +00:00
### Logging
2017-07-20 16:47:28 +00:00
You can emit log messages from your rules to aid debugging.
There are a number of logging methods available from your rules, the java signatures are:
2016-06-08 22:56:14 +00:00
```java
logDebug(String loggerName, String format, Object... args)
logInfo(String loggerName, String format, Object... args)
logWarn(String loggerName, String format, Object... args)
logError(String loggerName, String format, Object... args)
```
2020-11-28 22:11:36 +00:00
In each case, the `loggerName` parameter is combined with the string `org.openhab.core.model.script.` to create the log4j logger name.
2017-07-20 16:47:28 +00:00
For example, if your rules file contained the following log message:
2016-06-08 22:56:14 +00:00
```java
logDebug("kitchen", "Kitchen light turned on")
```
then the logger you would have to configure to have your messages appearing in the console would be:
2017-07-20 16:47:28 +00:00
```text
2020-11-28 22:11:36 +00:00
log:set DEBUG org.openhab.core.model.script.kitchen
2016-06-08 22:56:14 +00:00
```
[Rules] Add section on type conversion, fixes #472 (#483)
* add section on type conversion
Addressing issue #472 and incorporating discussions from PR #469; work is based in contributions by @rkoshak https://community.openhab.org/t/type-conversions/32684
Fixed html anchors; changed text regarding example rules at the end to match new content
* added more webhooks, fixed URL
Added some more webhooks
Fixed URL to use {{base}}
* more text clean-up
Tightening of text, adherence to one line per sentence rule, etc
* moved text, adjusted heading levels, added example
Moved proposed text to immediately after "Manipulating item states", adjusted header levels to match new location, added example to PointType using strings
* improved formatting, common structure, switch text
Added blank lines around code blocks, added text to Switch Item to make it stand-alone, improved common structure; deleted all examples of use of postUpdate and sendCommand as they are already dealt with in section above.
Signed-off-by: Markus Lipp lipp.markus@gmail.com (github: LightIsLife)
2017-09-24 20:58:34 +00:00
## Rule Examples
2016-06-08 22:56:14 +00:00
2019-07-14 12:18:28 +00:00
Below some examples of common rules:
2016-06-08 22:56:14 +00:00
```java
var Number counter
2016-08-05 10:10:20 +00:00
2016-06-08 22:56:14 +00:00
// setting the counter to some initial value
// we could have done this in the variable declaration already
2018-01-16 16:14:06 +00:00
rule "Startup"
2016-08-05 10:10:20 +00:00
when
2017-07-20 16:47:28 +00:00
System started
2016-06-08 22:56:14 +00:00
then
2017-07-20 16:47:28 +00:00
counter = 0
2016-06-08 22:56:14 +00:00
end
2016-08-05 10:10:20 +00:00
2016-06-08 22:56:14 +00:00
// increase the counter at midnight
rule "Increase counter"
when
2017-07-20 16:47:28 +00:00
Time cron "0 0 0 * * ?"
2016-06-08 22:56:14 +00:00
then
2017-07-20 16:47:28 +00:00
counter = counter + 1
2016-06-08 22:56:14 +00:00
end
2016-08-05 10:10:20 +00:00
2016-06-08 22:56:14 +00:00
// tell the number of days either at noon or if a button is pressed
rule "Announce number of days up"
when
2017-07-20 16:47:28 +00:00
Time is noon or
Item AnnounceButton received command ON
2016-06-08 22:56:14 +00:00
then
2017-07-20 16:47:28 +00:00
say("The system is up since " + counter + " days")
2016-06-08 22:56:14 +00:00
end
2016-08-05 10:10:20 +00:00
2016-06-08 22:56:14 +00:00
// sets the counter to the value of a received command
rule "Set the counter"
when
2017-07-20 16:47:28 +00:00
Item SetCounterItem received command
2016-06-08 22:56:14 +00:00
then
2017-07-20 16:47:28 +00:00
counter = receivedCommand as DecimalType
2016-06-08 22:56:14 +00:00
end
2018-08-19 15:32:05 +00:00
// turns on a light when one of several motion sensors received command ON, turns it off when one of several received command OFF
rule "Motion sensor light"
when
Member of MotionSensors received command
then
if(receivedCommand == ON) Light.sendCommand(ON)
else Light.sendCommand(OFF)
end
2018-12-19 06:43:25 +00:00
rule "Start wake up light on sunrise"
when
Channel "astro:sun:home:rise#event" triggered
then
switch(receivedEvent.getEvent()) {
case "START": {
Light.sendCommand(ON)
}
}
end
2016-06-08 22:56:14 +00:00
```
2017-07-20 16:47:28 +00:00
## Further Examples
Many more examples can be found in the [Tutorials & Examples ](https://community.openhab.org/c/tutorials-examples ) category of the community forum.
They are community provided and new ones are added constantly.