Skip to content

Commit

Permalink
[blockly] Fix code generation for Thing object on Thing status block (o…
Browse files Browse the repository at this point in the history
…penhab#2688)

Fixes openhab#2670.

Signed-off-by: Stefan Höhn <[email protected]>
  • Loading branch information
stefan-hoehn authored Jul 26, 2024
1 parent 0c03554 commit 2de240e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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',
Expand Down

0 comments on commit 2de240e

Please sign in to comment.