Skip to content

Commit

Permalink
fix uom block output type (openhab#2036)
Browse files Browse the repository at this point in the history
fixes openhab#2008

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
  • Loading branch information
stefan-hoehn committed Sep 23, 2023
1 parent 15b98e0 commit 8acaa6e
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,28 @@ export default function defineOHBlocks_Scripts (f7, isGraalJs, scripts) {
this.updateShape()
}
},
mutationToDom: function () {
let container = Blockly.utils.xml.createElement('mutation')
container.setAttribute('asType', this.asType)
container.setAttribute('contextInfo', this.contextInfo)
return container
},
domToMutation: function (xmlElement) {
this.contextInfo = xmlElement.getAttribute('contextInfo')
if (this.contextInfo === 'itemName') {
this.setOutput(true, 'oh_item')
} else {
this.setOutput(true, 'String')
}
this.asType = xmlElement.getAttribute('asType')
if (this.asType === 'asNumber') {
this.setOutput(true, 'Number')
} else if (this.asType === 'asQuantity') {
this.setOutput(true, 'oh_quantity')
} else {
this.setOutput(true, 'String')
}
},
updateShape: function () {
if (this.methodName === 'itemState' || this.methodName === 'oldItemState' || this.methodName === 'itemCommand') {
if (!this.getInput('asTypeInput')) {
Expand Down

0 comments on commit 8acaa6e

Please sign in to comment.