From 5bf98457f4b293b3c513b4292084f873df4886bd Mon Sep 17 00:00:00 2001 From: Yannick Schaus Date: Thu, 16 Feb 2023 22:25:26 +0100 Subject: [PATCH] Add a Scene settings menu entry and editor (#1662) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1528. The scene editor allows defining Item — command pairs that are applied when the scene is activated. While designing a scene, it is possible to sync the target state to the current Item state and test the target state command. Technologically scenes are just rules without triggers, so they can be activated using the „Run Rule, Script, Scene …“ action. Signed-off-by: Jan N. Klug Signed-off-by: Yannick Schaus --- .../doc/components/oh-aggregate-series.md | 10 +- .../doc/components/oh-button.md | 20 +- .../doc/components/oh-calendar-axis.md | 10 +- .../doc/components/oh-calendar-series.md | 10 +- .../org.openhab.ui/doc/components/oh-cell.md | 10 +- .../doc/components/oh-clock-card.md | 10 +- .../doc/components/oh-colorpicker-cell.md | 10 +- .../doc/components/oh-data-series.md | 10 +- .../doc/components/oh-gauge-card.md | 10 +- .../org.openhab.ui/doc/components/oh-icon.md | 10 +- .../doc/components/oh-image-card.md | 10 +- .../org.openhab.ui/doc/components/oh-image.md | 10 +- .../doc/components/oh-knob-cell.md | 10 +- .../doc/components/oh-label-card.md | 20 +- .../doc/components/oh-label-cell.md | 10 +- .../doc/components/oh-label-item.md | 10 +- .../org.openhab.ui/doc/components/oh-link.md | 10 +- .../doc/components/oh-list-item.md | 10 +- .../doc/components/oh-map-circle-marker.md | 10 +- .../doc/components/oh-map-marker.md | 10 +- .../doc/components/oh-plan-marker.md | 10 +- .../doc/components/oh-rollershutter-cell.md | 10 +- .../doc/components/oh-slider-cell.md | 10 +- .../doc/components/oh-time-series.md | 10 +- .../org.openhab.ui/doc/components/oh-video.md | 10 +- .../src/assets/definitions/widgets/actions.js | 6 +- .../web/src/assets/i18n/empty-states/en.json | 3 + .../org.openhab.ui/web/src/components/app.vue | 4 + .../config/controls/rule-picker.vue | 34 +- .../config/controls/thing-picker.vue | 2 +- .../components/config/editor/hint-rules.js | 18 +- .../components/config/editor/yaml-utils.js | 2 +- bundles/org.openhab.ui/web/src/js/routes.js | 12 + .../settings/rules/rule-module-popup.vue | 8 +- .../src/pages/settings/rules/rules-list.vue | 24 +- .../scene/scene-configure-item-popup.vue | 242 +++++++ .../pages/settings/rules/scene/scene-edit.vue | 608 ++++++++++++++++++ .../web/src/pages/settings/settings-menu.vue | 9 + 38 files changed, 1087 insertions(+), 155 deletions(-) create mode 100644 bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-configure-item-popup.vue create mode 100644 bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-edit.vue diff --git a/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md b/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md index 1bfbcf293..09c3f205d 100644 --- a/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-aggregate-series.md @@ -150,7 +150,7 @@ prev: /docs/ui/components/ - + @@ -191,14 +191,14 @@ prev: /docs/ui/components/ Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-button.md b/bundles/org.openhab.ui/doc/components/oh-button.md index 54ef73a5b..00fc267aa 100644 --- a/bundles/org.openhab.ui/doc/components/oh-button.md +++ b/bundles/org.openhab.ui/doc/components/oh-button.md @@ -130,7 +130,7 @@ Button performing an action - + @@ -171,14 +171,14 @@ Button performing an action Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. @@ -289,7 +289,7 @@ Button performing an action - + @@ -330,14 +330,14 @@ Button performing an action Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md b/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md index 99662d8eb..94e0ef0b6 100644 --- a/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md +++ b/bundles/org.openhab.ui/doc/components/oh-calendar-axis.md @@ -67,7 +67,7 @@ prev: /docs/ui/components/ - + @@ -108,14 +108,14 @@ prev: /docs/ui/components/ Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-calendar-series.md b/bundles/org.openhab.ui/doc/components/oh-calendar-series.md index fc47e1682..5c3eea24f 100644 --- a/bundles/org.openhab.ui/doc/components/oh-calendar-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-calendar-series.md @@ -112,7 +112,7 @@ prev: /docs/ui/components/ - + @@ -153,14 +153,14 @@ prev: /docs/ui/components/ Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-cell.md b/bundles/org.openhab.ui/doc/components/oh-cell.md index 1a3871af2..e900cacea 100644 --- a/bundles/org.openhab.ui/doc/components/oh-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-cell.md @@ -80,7 +80,7 @@ A regular or expandable cell - + @@ -121,14 +121,14 @@ A regular or expandable cell Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-clock-card.md b/bundles/org.openhab.ui/doc/components/oh-clock-card.md index 70fe482bf..8acbaa907 100644 --- a/bundles/org.openhab.ui/doc/components/oh-clock-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-clock-card.md @@ -135,7 +135,7 @@ Display a digital clock in a card - + @@ -176,14 +176,14 @@ Display a digital clock in a card Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md b/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md index 3f33d06d4..f1dd93d01 100644 --- a/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md @@ -109,7 +109,7 @@ A cell expanding to a color picker - + @@ -150,14 +150,14 @@ A cell expanding to a color picker Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-data-series.md b/bundles/org.openhab.ui/doc/components/oh-data-series.md index a7def5fd7..b2cc8433d 100644 --- a/bundles/org.openhab.ui/doc/components/oh-data-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-data-series.md @@ -53,7 +53,7 @@ prev: /docs/ui/components/ - + @@ -94,14 +94,14 @@ prev: /docs/ui/components/ Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-gauge-card.md b/bundles/org.openhab.ui/doc/components/oh-gauge-card.md index d523d379d..38ad0bc04 100644 --- a/bundles/org.openhab.ui/doc/components/oh-gauge-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-gauge-card.md @@ -171,7 +171,7 @@ Display a read-only gauge in a card to visualize a quantifiable item - + @@ -212,14 +212,14 @@ Display a read-only gauge in a card to visualize a quantifiable item Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-icon.md b/bundles/org.openhab.ui/doc/components/oh-icon.md index c23e4ecd1..e3f42aa4b 100644 --- a/bundles/org.openhab.ui/doc/components/oh-icon.md +++ b/bundles/org.openhab.ui/doc/components/oh-icon.md @@ -89,7 +89,7 @@ Display an openHAB icon - + @@ -130,14 +130,14 @@ Display an openHAB icon Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-image-card.md b/bundles/org.openhab.ui/doc/components/oh-image-card.md index ce6d5bfc5..e96b017db 100644 --- a/bundles/org.openhab.ui/doc/components/oh-image-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-image-card.md @@ -101,7 +101,7 @@ Display an image (URL or Image item ) in a card - + @@ -142,14 +142,14 @@ Display an image (URL or Image item ) in a card Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-image.md b/bundles/org.openhab.ui/doc/components/oh-image.md index 7a8fa46bd..bdc160507 100644 --- a/bundles/org.openhab.ui/doc/components/oh-image.md +++ b/bundles/org.openhab.ui/doc/components/oh-image.md @@ -69,7 +69,7 @@ Displays an image from a URL or an item - + @@ -110,14 +110,14 @@ Displays an image from a URL or an item Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-knob-cell.md b/bundles/org.openhab.ui/doc/components/oh-knob-cell.md index 251e2a8c2..39dd17166 100644 --- a/bundles/org.openhab.ui/doc/components/oh-knob-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-knob-cell.md @@ -194,7 +194,7 @@ A cell expanding to a knob control - + @@ -235,14 +235,14 @@ A cell expanding to a knob control Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-label-card.md b/bundles/org.openhab.ui/doc/components/oh-label-card.md index 3328ee537..8682bb3c8 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-card.md @@ -70,7 +70,7 @@ Display the state of an item in a card - + @@ -111,14 +111,14 @@ Display the state of an item in a card Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. @@ -229,7 +229,7 @@ Display the state of an item in a card - + @@ -270,14 +270,14 @@ Display the state of an item in a card Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-label-cell.md b/bundles/org.openhab.ui/doc/components/oh-label-cell.md index e8d69fecb..038624575 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-cell.md @@ -96,7 +96,7 @@ A cell with a big label to show a short item state value - + @@ -137,14 +137,14 @@ A cell with a big label to show a short item state value Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-label-item.md b/bundles/org.openhab.ui/doc/components/oh-label-item.md index 76b85b8b5..2ad96c4fe 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-item.md @@ -86,7 +86,7 @@ Display the state of an item in a list - + @@ -127,14 +127,14 @@ Display the state of an item in a list Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-link.md b/bundles/org.openhab.ui/doc/components/oh-link.md index 6ad0cd96c..0fdda700a 100644 --- a/bundles/org.openhab.ui/doc/components/oh-link.md +++ b/bundles/org.openhab.ui/doc/components/oh-link.md @@ -104,7 +104,7 @@ Link performing an action - + @@ -145,14 +145,14 @@ Link performing an action Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-list-item.md b/bundles/org.openhab.ui/doc/components/oh-list-item.md index 7fd39ed9c..be54b53d6 100644 --- a/bundles/org.openhab.ui/doc/components/oh-list-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-list-item.md @@ -75,7 +75,7 @@ A list item - + @@ -116,14 +116,14 @@ A list item Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md b/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md index edb7df1a8..c6b6cf7be 100644 --- a/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-map-circle-marker.md @@ -88,7 +88,7 @@ A circle on a map, to represent a radius - + @@ -129,14 +129,14 @@ A circle on a map, to represent a radius Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-map-marker.md b/bundles/org.openhab.ui/doc/components/oh-map-marker.md index 8c52a9744..6d3d34880 100644 --- a/bundles/org.openhab.ui/doc/components/oh-map-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-map-marker.md @@ -72,7 +72,7 @@ An icon on a map - + @@ -113,14 +113,14 @@ An icon on a map Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md index d77dfc621..440f9fc86 100644 --- a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md @@ -175,7 +175,7 @@ A marker on a floor plan - + @@ -216,14 +216,14 @@ A marker on a floor plan Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md b/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md index 03ef53388..1a676313a 100644 --- a/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-rollershutter-cell.md @@ -141,7 +141,7 @@ A cell expanding to rollershutter controls - + @@ -182,14 +182,14 @@ A cell expanding to rollershutter controls Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-slider-cell.md b/bundles/org.openhab.ui/doc/components/oh-slider-cell.md index 34f961c76..8455fe75f 100644 --- a/bundles/org.openhab.ui/doc/components/oh-slider-cell.md +++ b/bundles/org.openhab.ui/doc/components/oh-slider-cell.md @@ -151,7 +151,7 @@ A cell expanding to a big vertical slider - + @@ -192,14 +192,14 @@ A cell expanding to a big vertical slider Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-time-series.md b/bundles/org.openhab.ui/doc/components/oh-time-series.md index bfeafafa6..825f2558d 100644 --- a/bundles/org.openhab.ui/doc/components/oh-time-series.md +++ b/bundles/org.openhab.ui/doc/components/oh-time-series.md @@ -104,7 +104,7 @@ prev: /docs/ui/components/ - + @@ -145,14 +145,14 @@ prev: /docs/ui/components/ Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/doc/components/oh-video.md b/bundles/org.openhab.ui/doc/components/oh-video.md index fa02fd0d7..4b988d076 100644 --- a/bundles/org.openhab.ui/doc/components/oh-video.md +++ b/bundles/org.openhab.ui/doc/components/oh-video.md @@ -93,7 +93,7 @@ Displays a video player from a URL or an item - + @@ -134,14 +134,14 @@ Displays a video player from a URL or an item Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use value=label format to provide a label different than the option. - + - Rule to run + Scene, Script or Rule to run - + - Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. + Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }. diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js index feadc8822..e29cb6620 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/actions.js @@ -19,7 +19,7 @@ export const actionParams = (groupName, paramPrefix) => { { value: 'command', label: 'Send command' }, { value: 'toggle', label: 'Toggle Item' }, { value: 'options', label: 'Command options' }, - { value: 'rule', label: 'Run rule' }, + { value: 'rule', label: 'Run scene, script or rule' }, { value: 'popup', label: 'Open popup' }, { value: 'popover', label: 'Open popover' }, { value: 'sheet', label: 'Open sheet' }, @@ -53,11 +53,11 @@ export const actionParams = (groupName, paramPrefix) => { .v((value, configuration, configDescription, parameters) => { return ['options'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), - pt(paramPrefix + 'actionRule', 'Rule', 'Rule to run').c('rule') + pt(paramPrefix + 'actionRule', 'Scene, Script or Rule', 'Scene, Script or Rule to run').c('rule') .v((value, configuration, configDescription, parameters) => { return ['rule'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), - pt(paramPrefix + 'actionRuleContext', 'Rule Context', 'Object representing the optional context to pass to the rule. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }.').c('script') + pt(paramPrefix + 'actionRuleContext', 'Context', 'Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. { "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }.').c('script') .v((value, configuration, configDescription, parameters) => { return ['rule'].indexOf(configuration[paramPrefix + 'action']) >= 0 }), diff --git a/bundles/org.openhab.ui/web/src/assets/i18n/empty-states/en.json b/bundles/org.openhab.ui/web/src/assets/i18n/empty-states/en.json index deda076f5..10e625836 100644 --- a/bundles/org.openhab.ui/web/src/assets/i18n/empty-states/en.json +++ b/bundles/org.openhab.ui/web/src/assets/i18n/empty-states/en.json @@ -26,6 +26,9 @@ "rules.title": "No rules yet", "rules.text": "Rules are the basic building blocks to automate your home - they define which actions to perform when certain events occur.

Create your first rule with the button below; for more advanced scenarios, you can also write script files in your configuration folder.", + "scenes.title": "No scenes yet", + "scenes.text": "Scenes are rules sending commands to restore a set of items to a desired state.
You can run them on-demand or call them from other rules.

Create your first scene with the button below.", + "scripts.title": "No scripts yet", "scripts.text": "Scripts are a special kind of rules, with no triggers and a single action module to execute code.
You can run them on-demand or call them from other rules.

Create your first script with the button below.", diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index 979724771..e0a2418bf 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -58,6 +58,10 @@ :class="{ currentsection: currentUrl.indexOf('/settings/rules') >= 0 }"> + + + diff --git a/bundles/org.openhab.ui/web/src/components/config/controls/rule-picker.vue b/bundles/org.openhab.ui/web/src/components/config/controls/rule-picker.vue index 252d9dbd2..8dbfab337 100644 --- a/bundles/org.openhab.ui/web/src/components/config/controls/rule-picker.vue +++ b/bundles/org.openhab.ui/web/src/components/config/controls/rule-picker.vue @@ -3,9 +3,21 @@ @@ -19,6 +31,8 @@ export default { data () { return { ready: false, + scenes: [], + scripts: [], rules: [], icons: {}, smartSelectParams: { @@ -33,8 +47,18 @@ export default { created () { this.smartSelectParams.closeOnSelect = !(this.multiple) // TODO use a Vuex store - this.$oh.api.get('/rest/rules').then((data) => { - this.rules = data.sort((a, b) => { + this.$oh.api.get('/rest/rules?summary=true').then((data) => { + this.scenes = data.filter((r) => r.tags.indexOf('Scene') >= 0).sort((a, b) => { + const labelA = a.name + const labelB = b.name + return labelA.localeCompare(labelB) + }) + this.scripts = data.filter((r) => r.tags.indexOf('Script') >= 0).sort((a, b) => { + const labelA = a.name + const labelB = b.name + return labelA.localeCompare(labelB) + }) + this.rules = data.filter((r) => r.tags.indexOf('Scene') < 0 && r.tags.indexOf('Script') < 0).sort((a, b) => { const labelA = a.name const labelB = b.name return labelA.localeCompare(labelB) diff --git a/bundles/org.openhab.ui/web/src/components/config/controls/thing-picker.vue b/bundles/org.openhab.ui/web/src/components/config/controls/thing-picker.vue index d40e46491..9c35c2c96 100644 --- a/bundles/org.openhab.ui/web/src/components/config/controls/thing-picker.vue +++ b/bundles/org.openhab.ui/web/src/components/config/controls/thing-picker.vue @@ -34,7 +34,7 @@ export default { created () { this.smartSelectParams.closeOnSelect = !(this.multiple) // TODO use a Vuex store - this.$oh.api.get('/rest/things').then((data) => { + this.$oh.api.get('/rest/things?summary=true').then((data) => { this.things = data.sort((a, b) => { const labelA = a.label const labelB = b.label diff --git a/bundles/org.openhab.ui/web/src/components/config/editor/hint-rules.js b/bundles/org.openhab.ui/web/src/components/config/editor/hint-rules.js index 42d44cecc..411ae9071 100644 --- a/bundles/org.openhab.ui/web/src/components/config/editor/hint-rules.js +++ b/bundles/org.openhab.ui/web/src/components/config/editor/hint-rules.js @@ -11,7 +11,7 @@ function getModuleTypes (cm, section) { }) } -function hintItems (cm, line, replaceAfterColon, addStatePropertySuffix) { +function hintItems (cm, line, replaceAfterColon, replaceAfterLastSpace, addColonSuffix) { const cursor = cm.getCursor() if (!cm.state.$oh) return const promise = (itemsCache) ? Promise.resolve(itemsCache) : cm.state.$oh.api.get('/rest/items') @@ -20,7 +20,7 @@ function hintItems (cm, line, replaceAfterColon, addStatePropertySuffix) { let ret = { list: data.map((item) => { return { - text: item.name + ((addStatePropertySuffix ? '.state' : '')), + text: item.name + ((addColonSuffix ? ': ' : '')), displayText: item.name, description: `${(item.label) ? item.label + ' ' : ''}(${item.type})
${item.state}` } @@ -32,6 +32,11 @@ function hintItems (cm, line, replaceAfterColon, addStatePropertySuffix) { ret.from = { line: cursor.line, ch: colonPos + 2 } ret.to = { line: cursor.line, ch: line.length } } + if (replaceAfterLastSpace) { + const lastSpacePos = line.lastIndexOf(' ') + ret.from = { line: cursor.line, ch: lastSpacePos + 1 } + ret.to = { line: cursor.line, ch: line.length } + } addTooltipHandlers(cm, ret) return ret }) @@ -144,9 +149,18 @@ function buildModuleStructure (cm, moduleType) { return ret } +function hintSceneItems (cm, line, parentNr) { + console.info('hinting in the items section (scenes)') + return hintItems(cm, line, false, true, true) +} + function hintModuleStructure (cm, line, parentLineNr) { const cursor = cm.getCursor() const section = cm.getLine(parentLineNr).replace('s:', '').trim() + if (section === 'item') { + if (line.indexOf(':') < 0) return hintSceneItems(cm, line, parentLineNr) + return // todo: hint commands? + } return getModuleTypes(cm, section).then((moduleTypes) => { let completions = moduleTypes.map((m) => { return { diff --git a/bundles/org.openhab.ui/web/src/components/config/editor/yaml-utils.js b/bundles/org.openhab.ui/web/src/components/config/editor/yaml-utils.js index b4f2f451a..c528c9d56 100644 --- a/bundles/org.openhab.ui/web/src/components/config/editor/yaml-utils.js +++ b/bundles/org.openhab.ui/web/src/components/config/editor/yaml-utils.js @@ -47,7 +47,7 @@ export function isComponent (line) { export function isRuleSection (line) { if (!line) return false - return line.match(/^(triggers|conditions|actions):/) + return line.match(/^(triggers|conditions|actions|items):/) } export function isChannelsSection (line) { diff --git a/bundles/org.openhab.ui/web/src/js/routes.js b/bundles/org.openhab.ui/web/src/js/routes.js index 690c857ad..568f537dd 100644 --- a/bundles/org.openhab.ui/web/src/js/routes.js +++ b/bundles/org.openhab.ui/web/src/js/routes.js @@ -43,6 +43,7 @@ const PageEditors = { const RulesListPage = () => import(/* webpackChunkName: "admin-rules" */ '../pages/settings/rules/rules-list.vue') const RuleEditPage = () => import(/* webpackChunkName: "admin-rules" */ '../pages/settings/rules/rule-edit.vue') +const SceneEditPage = () => import(/* webpackChunkName: "admin-rules" */ '../pages/settings/rules/scene/scene-edit.vue') const ScriptEditPage = () => import(/* webpackChunkName: "admin-rules" */ '../pages/settings/rules/script/script-edit.vue') const SchedulePage = () => import(/* webpackChunkName: "admin-schedule" */ '../pages/settings/schedule/schedule.vue') @@ -212,6 +213,17 @@ export default [ } ] }, + { + path: 'scenes/', + async: loadAsync(RulesListPage, { showScenes: true }), + routes: [ + { + path: ':ruleId', + beforeLeave: checkDirtyBeforeLeave, + async: loadAsync(SceneEditPage, (routeTo) => (routeTo.params.ruleId === 'add') ? { createMode: true } : {}) + } + ] + }, { path: 'scripts/', async: loadAsync(RulesListPage, { showScripts: true }), diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/rule-module-popup.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/rule-module-popup.vue index b3d23aa06..93d7484eb 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/rules/rule-module-popup.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/rule-module-popup.vue @@ -18,7 +18,7 @@ - + @@ -46,7 +46,7 @@ - + - + Configuration @@ -90,7 +90,7 @@ export default { ActionModuleWizard, ConfigSheet }, - props: ['rule', 'ruleModule', 'ruleModuleType', 'moduleTypes', 'currentSection'], + props: ['rule', 'ruleModule', 'ruleModuleType', 'moduleTypes', 'currentSection', 'isSceneModule'], data () { return { currentRuleModuleType: this.ruleModuleType, diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/rules-list.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/rules-list.vue index cb80800ba..86c899f60 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/rules/rules-list.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/rules-list.vue @@ -74,9 +74,13 @@ {{ rules.length }} scripts + + {{ rules.length }} scenes + {{ rules.length }} rules +
- +
@@ -114,6 +118,7 @@
+ @@ -128,7 +133,7 @@ import RuleStatus from '@/components/rule/rule-status-mixin' export default { mixins: [RuleStatus], - props: ['showScripts'], + props: ['showScripts', 'showScenes'], components: { 'empty-state-placeholder': () => import('@/components/empty-state-placeholder.vue') }, @@ -166,7 +171,14 @@ export default { this.loading = true this.$set(this, 'selectedItems', []) this.showCheckboxes = false - this.$oh.api.get('/rest/rules?summary=true' + (this.showScripts ? '&tags=Script' : '')).then(data => { + let filter = '' + if (this.showScripts) { + filter = '&tags=Script' + } + if (this.showScenes) { + filter = '&tags=Scene' + } + this.$oh.api.get('/rest/rules?summary=true' + filter).then(data => { this.rules = data.sort((a, b) => { return a.name.localeCompare(b.name) }) @@ -175,6 +187,10 @@ export default { this.rules = this.rules.filter((r) => !r.tags || r.tags.indexOf('Script') < 0) } + if (!this.showScenes) { + this.rules = this.rules.filter((r) => !r.tags || r.tags.indexOf('Scene') < 0) + } + this.loading = false this.ready = true setTimeout(() => { diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-configure-item-popup.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-configure-item-popup.vue new file mode 100644 index 000000000..72e52e8c6 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-configure-item-popup.vue @@ -0,0 +1,242 @@ + + + + + diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-edit.vue new file mode 100644 index 000000000..e4c9a6deb --- /dev/null +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/scene/scene-edit.vue @@ -0,0 +1,608 @@ + + + + + diff --git a/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue b/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue index 6a9ce42f4..af5d5d0ac 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/settings-menu.vue @@ -73,6 +73,14 @@ :footer="objectsSubtitles.rules">
+ + +