From d7976dc210c7d87ec9ee58cd3e07500ca0eef164 Mon Sep 17 00:00:00 2001 From: Yannick Schaus Date: Sun, 20 Dec 2020 14:51:54 +0100 Subject: [PATCH] Rules: add item state update to action module wizard (#675) Depends on https://github.com/openhab/openhab-core/pull/1970. Also: - Add abiilty to create a Blockly script directly. - Only update statuses that changed in the rules list (might help with #673 and similar to #466/#439). Signed-off-by: Yannick Schaus --- .../components/rule/action-module-wizard.vue | 34 ++++++++++++++----- .../rules/module-description-suggestions.js | 3 ++ .../src/pages/settings/rules/rules-list.vue | 6 ++-- .../settings/rules/script/script-edit.vue | 20 +++++++---- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/rule/action-module-wizard.vue b/bundles/org.openhab.ui/web/src/components/rule/action-module-wizard.vue index ccc0c6b52..574cd0389 100644 --- a/bundles/org.openhab.ui/web/src/components/rule/action-module-wizard.vue +++ b/bundles/org.openhab.ui/web/src/components/rule/action-module-wizard.vue @@ -33,30 +33,43 @@ + + + + + - + - - + { - console.log(event) const topicParts = event.topic.split('/') switch (topicParts[3]) { case 'added': @@ -191,8 +190,11 @@ export default { break case 'state': const rule = this.rules.find((r) => r.uid === topicParts[2]) + const newStatus = JSON.parse(event.payload) if (!rule) break - this.$set(rule, 'status', JSON.parse(event.payload)) + if (rule.status.status !== newStatus.status) rule.status.status = newStatus.status + if (rule.status.statusDetail !== newStatus.statusDetail) rule.status.statusDetail = newStatus.statusDetail + if (rule.status.description !== newStatus.description) rule.status.description = newStatus.description } }) }, diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue index 2535ad453..120dcafdd 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue @@ -31,15 +31,22 @@ - Script Language + + Scripting Method + + + + + or choose the scripting language: - @@ -169,7 +176,7 @@ export default { actions: [], tags: ['Script'] } - this.mode = 'application/javascript' + this.mode = 'application/javascript+blockly' this.$oh.api.get('/rest/module-types/script.ScriptAction').then((data) => { this.$set(this, 'scriptModuleType', data) this.$set(this, 'languages', @@ -203,7 +210,7 @@ export default { script: '' } } - if (this.mode === 'application/vnd.openhab.blockly.rule') { + if (this.mode === 'application/javascript+blockly') { actionModule.configuration.type = 'application/javascript' actionModule.configuration.blockSource = '' } @@ -348,7 +355,6 @@ export default { }, startEventSource () { this.eventSource = this.$oh.sse.connect('/rest/events?topics=openhab/rules/' + this.ruleId + '/*', null, (event) => { - console.log(event) const topicParts = event.topic.split('/') switch (topicParts[3]) { case 'state':