From 2de240e5d71b60ee2a99279440ddc57468cf223b Mon Sep 17 00:00:00 2001 From: stefan-hoehn Date: Fri, 26 Jul 2024 13:16:32 +0200 Subject: [PATCH] [blockly] Fix code generation for Thing object on Thing status block (#2688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2670. Signed-off-by: Stefan Höhn --- .../web/src/assets/definitions/blockly/blocks-things.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-things.js b/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-things.js index 6c84668ad7..56140f575b 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-things.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-things.js @@ -56,7 +56,7 @@ export default function defineOHBlocks (f7, isGraalJs) { init: function () { this.appendValueInput('thingUid') .appendField('get thing status') - .setCheck(['String', 'oh_thing']) + .setCheck(['String', 'oh_thing', 'oh_thingtype']) this.setInputsInline(false) this.setOutput(true, 'String') this.setColour(0) @@ -67,8 +67,10 @@ export default function defineOHBlocks (f7, isGraalJs) { javascriptGenerator.forBlock['oh_getthing_state'] = function (block) { const thingUid = javascriptGenerator.valueToCode(block, 'thingUid', javascriptGenerator.ORDER_ATOMIC) + const inputType = blockGetCheckedInputType(block, 'thingUid') if (isGraalJs) { - return [`things.getThing(${thingUid}).status`, 0] + let code = (inputType === 'oh_thingtype') ? `${thingUid}.status` : `things.getThing(${thingUid}).status` + return [code, 0] } else { const things = javascriptGenerator.provideFunction_( 'things',