Skip to content

Commit a3c858b

Browse files
authored
Merge branch 'main' into stateDescription_read_write
2 parents cfb6cab + e9202e2 commit a3c858b

File tree

9 files changed

+110
-70
lines changed

9 files changed

+110
-70
lines changed

.vuepress/process_file.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ def process_file(indir, file, outdir, source)
116116
line = line.gsub(%r{]\((.*)/(.*)\)}, '](../thing.html?manufacturer=\1&file=\2)') if file == "zwave/doc/things.md"
117117

118118
# Misc replaces (relative links, remove placeholder interpreted as custom tags)
119-
line = line.gsub("http://docs.openhab.org/addons/uis/habpanel/readme.html", "/docs/configuration/habpanel.html")
120-
line = line.gsub("http://docs.openhab.org/addons/uis/basic/readme.html", "/addons/ui/basic/")
121-
line = line.gsub(%r{http://docs\.openhab\.org/addons/(.*)/(.*)/readme\.html}, '/addons/\1/\2/')
122-
line = line.gsub("http://docs.openhab.org/", "/docs/")
119+
line = line.gsub(%r{https?://docs\.openhab\.org/addons/uis/habpanel/readme\.html}, "/docs/configuration/habpanel.html")
120+
line = line.gsub(%r{https?://docs\.openhab\.org/addons/uis/basic/readme\.html}, "/addons/ui/basic/")
121+
line = line.gsub(%r{https?://docs\.openhab\.org/addons/(.*)/(.*)/readme\.html}, '/addons/\1/\2/')
122+
line = line.gsub(%r{https?://docs\.openhab\.org/}, "/docs/")
123+
line = line.gsub(%r{https?://openhab\.org/docs/}, "/docs/")
124+
line = line.gsub(%r{https?://www\.openhab\.org/docs/}, "/docs/")
123125
line = line.gsub("/addons/io/", "/addons/integrations/")
124126
line = line.gsub("{{base}}/", "./docs/")
125127
line = line.gsub("(images/", "(./images/")

configuration/items.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,22 +674,34 @@ This parameter allows to post an update or command to an item after a period of
674674

675675
The expiration timer is started or restarted every time an item receives an update or a command _other than_ the specified "expire" update/command.
676676
Any future expiring update or command is cancelled, if the item receives an update or command that matches the "expire" update/command.
677+
See `ignoreStateUpdate` and `ignoreCommands` [configurations](#configurations-for-expire) below.
677678

678-
The parameter accepts a duration of time that can be a combination of hours, minutes and seconds in the format
679+
The parameter accepts a duration of time that can be a combination of days, hours, minutes and seconds in the format `Xd Xh Xm Xs` where X is a _long_ integer.
680+
Every part is optional, but all parts present must be in the given order (days, hours, minutes, seconds).
681+
Whitespaces are allowed between the sections.
679682

680683
```shell
681684
expire="1h 30m 45s"
682685
expire="1h05s"
683686
expire="55h 59m 12s"
687+
expire="2d 7h 59m 12s"
684688
```
685689

686-
Every part is optional, but all parts present must be in the given order (hours, minutes, seconds).
687-
Whitespaces are allowed between the sections.
690+
A non-negative expiry value can be specified using the [ISO8601 Duration format](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)).
691+
Java's `Duration` class supports days, hours, minutes, and seconds.
692+
Note that while the ISO8601 format allows for fractional seconds, the openHAB `expire` feature only supports durations with a minimum granularity of one second.
693+
694+
```shell
695+
expire="PT1H30M45S"
696+
expire="PT1H5S"
697+
expire="PT55H59M12S"
698+
expire="P2DT7H59M12S"
699+
```
688700

689701
This duration can optionally be followed by a comma and the state or command to post, when the timer expires.
690702
If this optional section is not present, it defaults to the Undefined (`UnDefType.UNDEF`) state.
691703

692-
```shell
704+
```java
693705
Player MyPlayer { expire="1h,command=STOP" } // send STOP command after one hour
694706
Number MyChannel { channel="xxx", expire="5m,state=0" } // update state to 0 after five minutes
695707
String MyMessage { channel="xxx", expire="3m12s,Hello" } // update state to Hello after three minutes and 12 seconds
@@ -701,6 +713,28 @@ Note that the `state=` part is optional.
701713
In the special case of a String item, it is possible to define a state/command as the string "UNDEF" or "NULL" by putting it into single quotes (e.g. "1m,state='UNDEF'").
702714
Without the quotes, the state would be the system type `UNDEF`.
703715

716+
###### Configurations for `expire`
717+
718+
The `expire` parameter is stored as an item metadata which supports the following configurations:
719+
720+
| Configuration Parameter | Description |
721+
|:------------------------|:-----------------------------------------------------------------------------------------------------------------------------|
722+
| `duration` | The expire duration as described above. |
723+
| `command` | The command to send when the timer expires. |
724+
| `state` | The state to change the item to when the timer expires. This is mutually exclusive to the `command` parameter. |
725+
| `ignoreStateUpdate` | When set to true, do not reset or restart the expire timer when the item received a state update event. Defaults to `false`. |
726+
| `ignoreCommands` | When set to true, do not reset or restart the timer when the item received a command. Defaults to `false`. |
727+
728+
Examples:
729+
730+
```java
731+
// These four definitions are equivalent
732+
Number MyChannel { expire="5m,state=0" }
733+
Number MyChannel { expire="5m,0" }
734+
Number MyChannel { expire="5m" [state=0] }
735+
Number MyChannel { expire="" [duration="5m", state=0] }
736+
```
737+
704738
#### Profiles
705739

706740
With Profiles, you are able to change the behavior how Channels interact with your Items.

configuration/rules-dsl.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -765,21 +765,24 @@ MyItem will automatically apply the method that corresponds to the argument type
765765

766766
Besides the implicitly available variables for items and commands/states, rules can have additional pre-defined variables, depending on their triggers:
767767

768-
- `receivedCommand` - implicitly available in every rule that has at least one command event trigger.
769-
- `previousState` - implicitly available in every rule that has at least one status change event trigger.
770-
- `newState` - implicitly available in every rule that has at least one status update or status change event trigger.
771-
- `triggeringItemName` - implicitly available in every rule that has at least one status update, status change or command event trigger.
772-
- `triggeringItem` - implicitly available in every rule that has a "Member of" trigger.
773-
- `triggeringGroupName` - implicitly available in every rule that has a "Member of" trigger.
774-
- `triggeringGroup` - implicitly available in every rule that has a "Member of" trigger.
775-
- `receivedEvent` - implicitly available in every rule that has a channel-based trigger.
776-
- `triggeringChannel` - implicitly available in every rule that has a channel-based trigger.
777-
- `triggeringThing` - implicitly available in every rule that has a thing-based trigger.
778-
- `previousThingStatus` - implicitly available in every rule that has a thing-based trigger.
779-
- `newThingStatus` - implicitly available in every rule that has a thing-based trigger.
780-
781-
- `sharedCache` - a cache that is shared between all rules and all scripting languages
782-
- `privateCache` - a cache private to the script/rule that requests it
768+
| Variable | Description |
769+
| :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
770+
| `receivedCommand` | implicitly available in every rule that has at least one command event trigger. |
771+
| `previousState` | implicitly available in every rule that has at least one status change event trigger. |
772+
| `newState` | implicitly available in every rule that has at least one status update or status change event trigger. |
773+
| `lastStateUpdate` | implicitly available in every rule that has at least one status update or status change event trigger. This variable contains the time when the last state update occurred prior to the current one. |
774+
| `lastStateChange` | implicitly available in every rule that has at least one status change event trigger. This variable contains the time when the last state change occurred prior to the current one. |
775+
| `triggeringItemName` | implicitly available in every rule that has at least one status update, status change or command event trigger. |
776+
| `triggeringItem` | implicitly available in every rule that has a "Member of" trigger. |
777+
| `triggeringGroupName` | implicitly available in every rule that has a "Member of" trigger. |
778+
| `triggeringGroup` | implicitly available in every rule that has a "Member of" trigger. |
779+
| `receivedEvent` | implicitly available in every rule that has a channel-based trigger. |
780+
| `triggeringChannel` | implicitly available in every rule that has a channel-based trigger. |
781+
| `triggeringThing` | implicitly available in every rule that has a thing-based trigger. |
782+
| `previousThingStatus` | implicitly available in every rule that has a thing-based trigger. |
783+
| `newThingStatus` | implicitly available in every rule that has a thing-based trigger. |
784+
| `sharedCache` | a cache that is shared between all rules and all scripting languages |
785+
| `privateCache` | a cache private to the script/rule that requests it |
783786

784787
For further documentation on using the cache see [here](jsr223.html#cache-preset).
785788

configuration/things.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ These files are stored in `$OPENHAB_CONF/things`.
6464

6565
The syntax for `.things` files is defined as follows (parts in `<..>` are required):
6666

67-
```xtend
67+
```java
6868
Thing <binding_id>:<type_id>:<thing_id> "Label" @ "Location" [ <parameters> ]
6969
```
7070

@@ -80,7 +80,7 @@ The type of the configuration parameter is determined by the binding and must be
8080

8181
**Examples:**
8282

83-
```xtend
83+
```java
8484
Thing network:device:webcam "Webcam" @ "Living Room" [ hostname="192.168.0.2", timeout="5000", ... ]
8585
Thing astro:moon:home [ geolocation="50.12345,10.98765", interval=300 ]
8686
Thing ntp:ntp:local [ hostname="de.pool.ntp.org" ]
@@ -101,7 +101,7 @@ Please check each individual binding's [documentation](/addons/#binding) for det
101101

102102
Bridges can be defined together with contained things. The following configuration shows the definition of a Hue bridge with two Hue lamps:
103103

104-
```xtend
104+
```java
105105
Bridge hue:bridge:mybridge [ ipAddress="192.168.3.123" ] {
106106
Thing 0210 bulb1 [ lightId="1" ]
107107
Thing 0210 bulb2 [ lightId="2" ]
@@ -115,7 +115,7 @@ The resulting UID of the thing is `hue:0210:mybridge:bulb1`.
115115

116116
Bridges that are defined somewhere else can also be referenced in the DSL:
117117

118-
```xtend
118+
```java
119119
Thing hue:0210:mybridge:bulb "Label" (hue:bridge:mybridge) @ "Location" [lightId="3"]
120120
```
121121

@@ -125,7 +125,7 @@ For the contained notation of things the UID will be inherited and the bridge ID
125125

126126
**Example of a MQTT Bridge with Generic MQTT Things :**
127127

128-
```xtend
128+
```java
129129
Bridge mqtt:broker:MyMQTTBroker [ host="192.168.178.50", secure=false, username="MyUserName", password="MyPassword"] {
130130
Thing topic sonoff_Dual_Thing "Light_Dual" @ "Sonoff" {
131131
Channels:
@@ -151,7 +151,7 @@ It is also possible to add additional channels to existing things and for bindin
151151

152152
#### State channels
153153

154-
```xtend
154+
```java
155155
Thing yahooweather:weather:losangeles [ location=2442047, unit="us", refresh=120 ] {
156156
Channels:
157157
State String : customChannel1 "My Custom Channel" [
@@ -167,7 +167,7 @@ The framework will merge the list of channels coming from the binding and the us
167167

168168
As state channels are the default channels, you can omit the `State` keyword, the following example creates the same channels as the example above:
169169

170-
```xtend
170+
```java
171171
Thing yahooweather:weather:losangeles [ location=2442047, unit="us", refresh=120 ] {
172172
Channels:
173173
String : customChannel1 "My Custom Channel" [
@@ -181,7 +181,7 @@ You may optionally give the channel a proper label (like “My Custom Channel”
181181

182182
#### Trigger channels
183183

184-
```xtend
184+
```java
185185
Thing yahooweather:weather:losangeles [ location=2442047, unit="us", refresh=120 ] {
186186
Channels:
187187
Trigger String : customChannel1 -[
@@ -196,7 +196,7 @@ Trigger channels are defined with the keyword `Trigger` and only support the typ
196196

197197
Many bindings provide standalone channel type definitions like this:
198198

199-
```xtend
199+
```java
200200
<thing:thing-descriptions bindingId="yahooweather" [...]>
201201
<channel-type id="temperature">
202202
<item-type>Number</item-type>
@@ -213,7 +213,7 @@ Many bindings provide standalone channel type definitions like this:
213213
They can be referenced within a thing’s channel definition, so that they need to be defined only once and can be reused for many channels.
214214
You may do so in the DSL as well:
215215

216-
```xtend
216+
```java
217217
Thing yahooweather:weather:losangeles [ location=2442047, unit="us", refresh=120 ] {
218218
Channels:
219219
Type temperature : my_yesterday_temperature "Yesterday's Temperature"
@@ -236,12 +236,12 @@ In order to link a Thing to an Item in an `.items` file, open the Thing in UI un
236236
In the list of Thing Channels, look for the Channel you wish to link to an Item and copy the Channel's ID.
237237
For instance, a Z-Wave switch might have a Switch Channel that has an ID like this:
238238

239-
```xtend
239+
```java
240240
zwave:device:1a2b3c4d:node2:switch_binary
241241
```
242242

243243
To bind that Channel to an Item in an `.items` file, you can define an Item in the file like so:
244244

245-
```xtend
245+
```java
246246
Switch Kitchen_Light_Switch "Kitchen Light" (Indoor_Lights) { channel="zwave:device:1a2b3c4d:node2:switch_binary" }
247247
```

configuration/transformations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,19 @@ However, beware that `stateFromItemScript` _should_ be left blank, because norma
201201

202202
Example usage in an `.items` file:
203203

204-
```xtend
204+
```java
205205
Number <itemName> { channel="<channelUID>"[profile="transform:JS", toItemScript="decode_json.js", commandFromItemScript="encode_json.js" ] }
206206
```
207207

208208
Here, additional parameters can also be injected into the script using the URL style syntax, e.g.:
209209

210-
```xtend
210+
```java
211211
Number <itemName> { channel="<channelUID>"[profile="transform:RB", toItemScript="multiply.rb?factor=10", commandFromItemScript="multiply.rb?factor=0.1" ] }
212212
```
213213

214214
Inline script is also supported in the profile syntax.
215215

216-
```xtend
216+
```java
217217
Number <itemName> { channel="<channelUID>"[profile="transform:RB", toItemScript="| input.to_f * 10", commandFromItemScript="| input.to_f * 0.1" ] }
218218
```
219219

0 commit comments

Comments
 (0)