Skip to content

Commit

Permalink
fixed type conversion bug for action arguments and handling of cases …
Browse files Browse the repository at this point in the history
…with no return value
  • Loading branch information
hidetak committed May 23, 2024
1 parent 8d7e5ae commit af654ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DATATYPES = {
},
actionInputTypeNull: {
inputMode: null,
typeConvert: null,
typeConvert: "",
},
}
const COMMON_ID_COUNT = 7
Expand Down Expand Up @@ -1087,7 +1087,7 @@ const ACTION_BUTTON_TEMP = `[
"type": "function",
"z": "",
"name": "change data type",
"func": "msg.payload = String(msg.payload)\\nreturn msg",
"func": "msg.payload = <%convert%>(msg.payload)\\nreturn msg",
"outputs": 1,
"timeout": 0,
"noerr": 0,
Expand Down
8 changes: 6 additions & 2 deletions node-red-node-wot/src/wot-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ module.exports = function (RED) {
.then(async (resp) => {
let payload
try {
payload = await resp.value()
node.send({ payload: payload, topic: config.topic })
if (resp.schema) {
payload = await resp.value()
node.send({ payload: payload, topic: config.topic })
} else {
node.send({ payload: null, topic: config.topic })
}
node.status({
fill: "green",
shape: "dot",
Expand Down

0 comments on commit af654ac

Please sign in to comment.