diff --git a/configuration/blockly/index.md b/configuration/blockly/index.md index cfe21e9cc..9a10b2969 100644 --- a/configuration/blockly/index.md +++ b/configuration/blockly/index.md @@ -204,6 +204,7 @@ This section explains only the blocks that have been added to the standard block [![openHAB Extensions to the standard](../images/blockly/blockly-text-overview-small.png "openHAB Extensions to the Standard") ](rules-blockly-standard-ext.html)[![openHAB Extensions to the standard](../images/blockly/blockly-colors-overview-small.png "openHAB Extensions to the Standard") ](rules-blockly-standard-ext.html)[![openHAB Extensions to the standard](../images/blockly/blockly-lists-dictionary-overview-small.png "openHAB Extensions to the Standard") +![lists-overview-concat](../images/blockly/blockly-lists-concatenate.png) ](rules-blockly-standard-ext.html) See [openHAB Extensions to the standard](rules-blockly-standard-ext.html) section. diff --git a/configuration/blockly/rules-blockly-date-handling.md b/configuration/blockly/rules-blockly-date-handling.md index 5f31f9dc4..b5cfb4c89 100644 --- a/configuration/blockly/rules-blockly-date-handling.md +++ b/configuration/blockly/rules-blockly-date-handling.md @@ -80,6 +80,8 @@ Type: _ZonedDateTime_ This block will return the date as _ZonedDateTime_ based on the given String. The String may be one of the following formats (since 3.3) the following formats are supported) +- HH:mm +- HH:mm:ss - yyyy-MM-dd - yyyy-MM-dd HH:mm - yyyy-MM-dd HH:mm:ss @@ -93,7 +95,11 @@ The String may be one of the following formats (since 3.3) the following formats The input String may also be provided via variable-block or a date from an item state. In case parts of the date are not provided due to shorter pattern, the others are set to 0 -Tip: if you want to create a datetime with your time zone use the "copy of"-block and overwrite its values +:::tip + +if you want to create a datetime with your time zone use the "copy of"-block and overwrite its values + +::: More about that topic can be viewed at ![youtube](../images/blockly/youtube-logo-small.png) [Creating Datetimes and other datetime blocks](https://youtu.be/KwhYKy1_qVk?t=2010) @@ -112,7 +118,11 @@ Creates a ZonedDateTime by providing all necessary six values - minute of time - second of time -Tip: if you want to create a datetime with your time zone use the "copy of"-block and overwrite its values +:::tip + +if you want to create a datetime with your time zone use the "copy of"-block and overwrite its values + +::: ### Create Datetime based on a specific date ("Copy Of") diff --git a/configuration/blockly/rules-blockly-items-things.md b/configuration/blockly/rules-blockly-items-things.md index f33eb9800..67865a57b 100644 --- a/configuration/blockly/rules-blockly-items-things.md +++ b/configuration/blockly/rules-blockly-items-things.md @@ -42,8 +42,13 @@ See a video introduction at ![youtube](../images/blockly/youtube-logo-small.png) Function: Retrieves a specific **Item** or **Group** for use in other item related functions. -- **Tip:** never use this block alone as it only returns the items name which alone does not make sense. +:::tip + +never use this block alone as it only returns the items name which alone does not make sense. Instead use the get-Item-Block below. + +::: + - Clicking 'MyItem' displays a list of **Items** to pick from - Technically this block returns the _name_ of the item as a String. - As a result, this block can be used wherever the item name is required as a String. @@ -76,7 +81,11 @@ Function: Get the current state of an **Item** or **Group** Note that most of the states can and will be directly **converted automatically to a String** but be careful that some of the **more complex states may instead return a complex object instead**. -**Tip:** it is recommended in this case to assign this to a variable and use the "String-Append-Text" with an empty "" to convert it into a String for further processing. +:::tip + +it is recommended in this case to assign this to a variable and use the "String-Append-Text" with an empty "" to convert it into a String for further processing. + +::: See the [Item-State documentation](https://www.openhab.org/docs/configuration/items.html#state) for more information @@ -102,6 +111,22 @@ The following example depicts the above possibilities: ![blockly-getMembersExample](../images/blockly/blockly-getMembersExample.png) +### Get Items with Tag + +![blockly-getMembers](../images/blockly/blockly-getitemswithtag.png) + +Function: Gets all items with the given tags which you can iterate over via a loop + +- returns a collection of items which have the given tags +- multiple tags can be provided which then need to be separared with a comma +- if multiple tags are given, the item must have all of the tags ("and"-condition) + +:::tip + +If you need an item that has one of multiple tags, then you need to use one block of each and then use the ["concatenate list block"](https://www.openhab.org/docs/configuration/blockly/rules-blockly-standard-ext.html#concatenate-list) to combine the results. + +::: + ### Get particular attributes of an item ![blockly-getItemAttributes](../images/blockly/blockly-getItemAttributes.png) diff --git a/configuration/blockly/rules-blockly-persistence.md b/configuration/blockly/rules-blockly-persistence.md index 7d2120b07..837585891 100644 --- a/configuration/blockly/rules-blockly-persistence.md +++ b/configuration/blockly/rules-blockly-persistence.md @@ -46,7 +46,22 @@ This method uses a time-weighted average calculation - maximum: gets the maximum value of the State of the given Item since a certain point in time - maximum: gets the sum of the State of the given Item since a certain point in time -Note: in case no or 0 values are retrieved, make sure that the item in question is actually persisted. +In the case of the following two functions the block changes its appearence by replacing the time with an option to chose if the equal value should be skipped or not: + +![previous-block](../images/blockly/blockly-persistence-get-previous.png) + +- previous state value: Gets the previous state with option to skip to different value as current +- previous state value time: Gets the time when previous state last occurred with option to skip to different value as current + +The skip option set to true allows to search for first state that is different from the current state. + +_Important:_ This option is not supported by all persistence databases and may throw an error in that case (for example the standard rrd4j does _not_ support it while influxdb does support it). + +Notes: in case no or 0 values are retrieved, make sure that the item in question is actually persisted. + +**Previous State Example** + +![previous-example](../images/blockly/blockly-persistence-get-previous-example.png) ### Check item change / update since a point in time diff --git a/configuration/blockly/rules-blockly-standard-ext.md b/configuration/blockly/rules-blockly-standard-ext.md index 5fae34ce2..28320204e 100644 --- a/configuration/blockly/rules-blockly-standard-ext.md +++ b/configuration/blockly/rules-blockly-standard-ext.md @@ -27,8 +27,6 @@ More about that topic can be viewed at ![youtube](../images/blockly/youtube-logo ### CRLF -Since OpenHAB 3.3.0M6 - CRLF stands for carriage-return / line-feed which is a technical term for adding a new line in a string ![crlf](../images/blockly/blockly-text-overview.png) @@ -39,6 +37,17 @@ _Function:_ return a newline character to be added to a string. ![crlf](../images/blockly/blockly-text-crlf-example.png) +### Text Replace + +![text-replace](../images/blockly/blockly-text-replace.png) + +_Function:_ Allows to replace something that is defined by the _pattern_ in the _origin_-text with what is provided in _replacement_. +Note that the pattern can be just a text or also regex expression. + +**Example:** + +![text-replace example](../images/blockly/blockly-text-replace-example.png) + ## Colors More about that topic can be viewed at ![youtube](../images/blockly/youtube-logo-small.png) [Using Color-Blocks and HSB-Conversion](https://youtu.be/EdllUlJ7p6k?t=1366) @@ -77,7 +86,11 @@ _Function:_ Returns a color by mixing the given values in a range from 0 - 255 f _Function:_ Blends two colors chosen via a color picker into one color by the given ratio. -Tip: this could be used for example with a loop that changes the ratio from 0 to 1 to blend the first color into a second +:::tip + +this could be used for example with a loop that changes the ratio from 0 to 1 to blend the first color into a second + +::: ### Create HSB-color from RGB color (openHAB) @@ -97,13 +110,14 @@ _Function:_ This a special openHAB block that converts a hexadecimal color code - use that block and connect one of the above blocks into that one to be able to retrieve the HSB value of that block. -**Example:** +Example ![get-hsb-of-example](../images/blockly/blockly-colors-hsbof-example.png) ## Lists ![lists-overview](../images/blockly/blockly-lists-dictionary-overview.png) +![lists-overview-concat](../images/blockly/blockly-lists-concatenate.png) ### Dictionary for managing key / value pairs @@ -115,7 +129,7 @@ Then drag the key block on the upper left into the key/value bracket on the righ Rename the keys as required and then add any value block type to the related key: -Example: +**Example:** ![dictionary-example](../images/blockly/blockly-lists-dictionary-example.png) @@ -125,10 +139,20 @@ Example: _Function:_ Retrieves the value of the key in the given directory -Example: +**Example:** ![dictionary-getkey-example](../images/blockly/blockly-lists-dictionary-getkey-example.png) +### Concatenate lists + +![lists-overview-concat](../images/blockly/blockly-lists-concatenate.png) + +_Function:_ adds the second list to the first list and returns a new list + +Example: + +![lists-overview-concat](../images/blockly/blockly-lists-concatenate-example.png) + ## Loops Even though there a no specialized openHAB blocks provided, loops are used rather often. diff --git a/configuration/images/blockly/blockly-date-get.png b/configuration/images/blockly/blockly-date-get.png index c1ca3f186..d8a661a8a 100644 Binary files a/configuration/images/blockly/blockly-date-get.png and b/configuration/images/blockly/blockly-date-get.png differ diff --git a/configuration/images/blockly/blockly-getitemswithtag.png b/configuration/images/blockly/blockly-getitemswithtag.png new file mode 100644 index 000000000..0de609cdc Binary files /dev/null and b/configuration/images/blockly/blockly-getitemswithtag.png differ diff --git a/configuration/images/blockly/blockly-items-and-things-small.png b/configuration/images/blockly/blockly-items-and-things-small.png index 6edbcc389..1b9b1eb9e 100644 Binary files a/configuration/images/blockly/blockly-items-and-things-small.png and b/configuration/images/blockly/blockly-items-and-things-small.png differ diff --git a/configuration/images/blockly/blockly-items-and-things.png b/configuration/images/blockly/blockly-items-and-things.png index cd5dba8eb..f638ec376 100644 Binary files a/configuration/images/blockly/blockly-items-and-things.png and b/configuration/images/blockly/blockly-items-and-things.png differ diff --git a/configuration/images/blockly/blockly-lists-concatenate-example.png b/configuration/images/blockly/blockly-lists-concatenate-example.png new file mode 100644 index 000000000..501916e79 Binary files /dev/null and b/configuration/images/blockly/blockly-lists-concatenate-example.png differ diff --git a/configuration/images/blockly/blockly-lists-concatenate.png b/configuration/images/blockly/blockly-lists-concatenate.png new file mode 100644 index 000000000..4f9103a33 Binary files /dev/null and b/configuration/images/blockly/blockly-lists-concatenate.png differ diff --git a/configuration/images/blockly/blockly-persistence-get-previous-example.png b/configuration/images/blockly/blockly-persistence-get-previous-example.png new file mode 100644 index 000000000..0a44685a1 Binary files /dev/null and b/configuration/images/blockly/blockly-persistence-get-previous-example.png differ diff --git a/configuration/images/blockly/blockly-persistence-get-previous.png b/configuration/images/blockly/blockly-persistence-get-previous.png new file mode 100644 index 000000000..3aa0d45bf Binary files /dev/null and b/configuration/images/blockly/blockly-persistence-get-previous.png differ diff --git a/configuration/images/blockly/blockly-persistence-get-previousValue.png b/configuration/images/blockly/blockly-persistence-get-previousValue.png new file mode 100644 index 000000000..63e86eb9f Binary files /dev/null and b/configuration/images/blockly/blockly-persistence-get-previousValue.png differ diff --git a/configuration/images/blockly/blockly-text-replace-example.png b/configuration/images/blockly/blockly-text-replace-example.png new file mode 100644 index 000000000..b9b240457 Binary files /dev/null and b/configuration/images/blockly/blockly-text-replace-example.png differ diff --git a/configuration/images/blockly/blockly-text-replace.png b/configuration/images/blockly/blockly-text-replace.png new file mode 100644 index 000000000..58594c79d Binary files /dev/null and b/configuration/images/blockly/blockly-text-replace.png differ