[blockly] Fix code generation for Thing object on Thing status block (#2688)

Fixes #2670.

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
pull/2689/head
stefan-hoehn 2024-07-26 13:16:32 +02:00 committed by GitHub
parent 0c03554e25
commit 2de240e5d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -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',