Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .github/markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,34 @@ default: true

# Expect dash usage for unorderd lists
MD004:
style: dash

# Multiple consecutive blank lines
MD012:
maximum: 2
style: dash

# Allow long line lengths
MD013: false

# Allow duplicate headers for different nesting
MD024:
allow_different_nesting: true
siblings_only: true

# Allow Multiple top level headers in the same document
MD025: false

# Allow trailing punctuation in headers
MD026: false
MD029:
style: one_or_ordered
style: one

# Allow inline HTML
MD033: false

# Code block style
MD046:
style: fenced
style: fenced

# Emphasiszis in underscore
MD049:
style: underscore

# Strong in asterisk
MD050:
style: asterisk
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone

Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone/19).


## 4.5.1

| Type | Namespace | Description | Reference | Breaking |
Expand Down Expand Up @@ -432,7 +431,6 @@ Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone
| Docs | | Update timer docs | [#161](https://github.com/openhab/openhab-js/pull/161) | No |
| Bugfix | `actions` | Fix `get()`, `thingActions()` & dynamic exports | [#165](https://github.com/openhab/openhab-js/pull/165) | No |


Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone/5).

## 2.0.3
Expand All @@ -443,7 +441,6 @@ Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone
| Enhancement | `items` | ItemHistory: Add missing methods & Enable type defs | [#158](https://github.com/openhab/openhab-js/pull/158) | No |
| Docs | `actions` | Update docs for naming timers | [#160](https://github.com/openhab/openhab-js/pull/160) | No |


Also see the [Release Milestone](https://github.com/openhab/openhab-js/milestone/4).

## 2.0.2
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If there's a problem with the implementation, hopefully you received feedback on
We're trying very hard to keep openHAB lean and focused.
We don't want it to do everything for everybody.
This means that we might decide against incorporating a new feature.
However, there might be a way to implement that feature *on top of* openHAB.
However, there might be a way to implement that feature _on top of_ openHAB.

### Discuss your design in the discussion forum

Expand Down
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This library is included by default in the openHAB [JavaScript Scripting add-on]
Install the openHAB [JavaScript Scripting add-on](https://www.openhab.org/addons/automation/jsscripting/), a version of this library will be automatically installed and available to ECMAScript 2024+ rules created using [File Based Rules](#file-based-rules) or [UI Based Rules](#ui-based-rules).

openHAB also provides the [JavaScript Scripting (Nashorn) add-on](https://www.openhab.org/addons/automation/jsscriptingnashorn/), which is based on the older Nashorn JavaScript engine. This is referred to as `ECMA - 262 Edition 5.1` or `application/javascript;version=ECMAScript-5.1` in the Main UI.
*This library is not compatible with this older runtime.*
_This library is not compatible with this older runtime._

### Custom Installation

Expand Down Expand Up @@ -297,7 +297,6 @@ myVar = 'Hello mutation!'; // When the timer runs, it will log "Hello mutation!"

If you need to pass some variables to the timer but avoid that they can get mutated, pass those variables as parameters to `setTimeout`/`setInterval` or `createTimer`:


```javascript
var myVar = 'Hello world!';

Expand Down Expand Up @@ -348,8 +347,8 @@ Use JavaScript Scripting as script transformation by:
})(input);
```

2. Using `JS(<scriptname>.js):%s` as Item state transformation.
3. Passing parameters is also possible by using a URL like syntax: `JS(<scriptname>.js?arg=value)`.
1. Using `JS(<scriptname>.js):%s` as Item state transformation.
1. Passing parameters is also possible by using a URL like syntax: `JS(<scriptname>.js?arg=value)`.
Parameters are injected into the script and can be referenced like variables.

Simple transformations can aso be given as an inline script: `JS(|...)`, e.g. `JS(|"String has " + input.length + "characters")`.
Expand Down Expand Up @@ -801,7 +800,6 @@ actions.ScriptExecution.createTimer(string identifier, time.ZonedDateTime zdt, f
- `hasTerminated()`: Whether the scheduled execution has already terminated. ⇒ `boolean`
- `reschedule(time.ZonedDateTime)`: Reschedules a timer to a new starting time. This can also be called after a timer has terminated, which will result in another execution of the same code. ⇒ `boolean`: true, if rescheduling was successful


```javascript
var now = time.ZonedDateTime.now();

Expand Down Expand Up @@ -947,14 +945,14 @@ See [openhab-js : cache](https://openhab.github.io/openhab-js/cache.html) for fu

The `defaultSupplier` provided function will return a default value if a specified key is not already associated with a value.

**Example** *(Get a previously set value with a default value (times = 0))*
**Example** _(Get a previously set value with a default value (times = 0))_

```js
var counter = cache.shared.get('counter', () => 0);
console.log('Counter: ' + counter);
```

**Example** *(Get a previously set value, modify and store it)*
**Example** _(Get a previously set value, modify and store it)_

```js
var counter = cache.private.get('counter');
Expand Down Expand Up @@ -995,7 +993,7 @@ Therefore, if you attempt to use the `DateTimeFormatter` and receive an error sa

[JS-Joda Locales](https://github.com/js-joda/js-joda/tree/master/packages/locale#use-prebuilt-locale-packages) includes a list of all the supported locales.
Each locale consists of a two letter language indicator followed by a "-" and a two letter dialect indicator: e.g. "EN-US".
Installing a locale can be done through the command `npm install @js-joda/locale_de-de` from the *$OPENHAB_CONF/automation/js* folder.
Installing a locale can be done through the command `npm install @js-joda/locale_de-de` from the _$OPENHAB_CONF/automation/js_ folder.

To import and use a local into your rule you need to require it and create a `DateTimeFormatter` that uses it:

Expand Down Expand Up @@ -1571,8 +1569,8 @@ When it is run, `npm` will remove everything from `node_modules` that has not be
Follow these steps to create your own library (it's called a CommonJS module):

1. Create a separate folder for your library outside of `automation/js`, you may also initialize a Git repository.
2. Run `npm init` from your newly created folder; at least provide responses for the `name`, `version` and `main` (e.g. `index.js`) fields.
3. Create the main file of your library (`index.js`) and add some exports:
1. Run `npm init` from your newly created folder; at least provide responses for the `name`, `version` and `main` (e.g. `index.js`) fields.
1. Create the main file of your library (`index.js`) and add some exports:

```javascript
var someProperty = 'Hello world!';
Expand All @@ -1586,9 +1584,9 @@ Follow these steps to create your own library (it's called a CommonJS module):
};
```

4. Tar it up by running `npm pack` from your library's folder.
5. Install it by running `npm install <path-to-library-folder>/<name>-<version>.tgz` from the `automation/js` folder.
6. After you've installed it with `npm`, you can continue development of the library inside `node_modules`.
1. Tar it up by running `npm pack` from your library's folder.
1. Install it by running `npm install <path-to-library-folder>/<name>-<version>.tgz` from the `automation/js` folder.
1. After you've installed it with `npm`, you can continue development of the library inside `node_modules`.

It is also possible to upload your library to [npm](https://npmjs.com) to share it with other users.

Expand Down