Skip to content

Commit

Permalink
sceneEngine: Update docs for latest changes
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed May 13, 2022
1 parent 0dfd645 commit 65c8336
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ Scene defintion works with an array of objects.
```javascript
const sceneDefinition = {
controller: 'scene call item name',
scenes: [ // For each numeric state of the sceneItem one object.
{ // Object for the value 1 of the sceneItem.
scenes: [ // For each numeric state of the controller Item one object.
{ // Object for the value 1 of the controller Item.
value: 1,
targets: [ // Target states of items in the scene. Parameters explained later.
{ item: 'Florian_Licht', value: 'ON', required: true },
{ item: 'Florian_Licht', value: 'ON', required: true, conditionFn: function() { return parseFloat(items.getItem('Helligkeit').state) >= 10000; } },
{ item: 'Florian_LED_Stripes', value: 'OFF', required: false }
]
},
{ // Object for the value 15 of the sceneItem.
{ // Object for the value 15 of the controller Item.
value: 15,
targets: [ // Target states of items in the scene. Parameters explained later.
{ item: 'Florian_LED_Stripes', value: 'ON', required: true }
Expand All @@ -71,21 +71,16 @@ const sceneDefinition = {
]
};
```
__sceneTargets__' parameters
Identifier | Purpose | Type | Required
-|-|-|-
`item` | Name of a scene member. | String | yes
`value` | Target state of that member. | String | yes
`required` | Whether that member must match the target state when the scene is checked. | Boolean | no, defaults to true

See [JSDoc: getSceneEngine()](https://florian-h05.github.io/openhab-js-tools/rulesx.html#.getSceneEngine) for documentation of parameters.

### Scene rule
```javascript
rulesx.getSceneEngine(scenes, engineId);
rulesx.getSceneEngine(sceneDefinition);
```
Parameter | Purpose | required
-|-|-
scenes | The scene definition array of objects. | yes
engineId | The id of the scene engine, used in description. | yes
| Parameter | Purpose | Required |
|-----------------|----------------------------------------|----------|
| sceneDefinition | The scene definition array of objects. | yes |

***
## Alarm Clock
Expand Down
2 changes: 1 addition & 1 deletion src/rules/sceneEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class SceneEngine {
* @param {String} sceneDefinition.scenes[].targets[].item name of Item
* @param {String} sceneDefinition.scenes[].targets[].value target state of Item
* @param {Boolean} [sceneDefinition.scenes[].targets[].required=true] whether the Item's state must match the target state when the engine gets the current scene on change of a member
* @param {Function} [sceneDefinition.scenes[].targets[].conditionFn] the Item is only commanded if the evaluation of this function returns true
* @param {Function} [sceneDefinition.scenes[].targets[].conditionFn] the Item is only commanded and required for scene checks if the evaluation of this function returns true
* @returns {HostRule} SceneEngine rule
*/
const getSceneEngine = (sceneDefinition) => {
Expand Down

0 comments on commit 65c8336

Please sign in to comment.