Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug when null was specified for data type and when TD's Property does not have an observable #31

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions node-red-node-wot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node-red-node-wot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thingweb/node-red-node-wot",
"version": "1.2.3",
"version": "1.2.4",
"description": "Web of Things nodes for Node-RED using node-wot",
"author": "Eclipse Thingweb <[email protected]> (https://thingweb.io/)",
"license": "MIT",
Expand Down
9 changes: 5 additions & 4 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 @@ -88,7 +88,7 @@ export const createClientFlowUsingDashboard = (tdString: string, existedNodes: a
...commonParams,
propertyName,
propertyDescription: tdProperty.description,
propertyObserve: tdProperty.observable,
propertyObserve: tdProperty.observable || false,
inputMode: DATATYPES[tdProperty.type || "propertyTypeNull"].inputMode,
convert: DATATYPES[tdProperty.type || "propertyTypeNull"].typeConvert,
}
Expand All @@ -109,12 +109,13 @@ export const createClientFlowUsingDashboard = (tdString: string, existedNodes: a
actionGenIds.push(generateId())
}
const tdAction = td.actions[actionName]
let actionInputType = tdAction.input?.type || "actionInputTypeNull"
const actionParams = {
...commonParams,
actionName,
actionDescription: tdAction.description,
inputMode: DATATYPES[tdAction.input?.type || "actionInputTypeNull"].inputMode,
convert: DATATYPES[tdAction.input?.type || "actionInputTypeNull"].typeConvert,
inputMode: DATATYPES[actionInputType].inputMode,
convert: DATATYPES[actionInputType].typeConvert,
}
flowAndOffsetY = makeActionFlow(commonGenIds, actionGenIds, actionParams, tdAction, flowAndOffsetY.offsetY)
flow = flow.concat(flowAndOffsetY.flow)
Expand Down Expand Up @@ -264,7 +265,7 @@ const makeActionFlow = (commonGenIds, actionGenIds, params, tdAction, offsetY) =
offsetY
)
flow = flow.concat(flowAndOffsetY.flow)
if (tdAction.input?.type) {
if (params.inputMode) {
flowAndOffsetY = replaceParamsAndIds(
ACTION_ARGS_TEMP,
params,
Expand Down
1 change: 1 addition & 0 deletions node-red-node-wot/src/wot-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = function (RED) {
shape: "ring",
text: err.message,
})
console.error(err)
done(err)
})
})
Expand Down
2 changes: 2 additions & 0 deletions node-red-node-wot/src/wot-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module.exports = function (RED) {
shape: "ring",
text: "Response error",
})
console.error(err)
done(err)
})
})
Expand Down Expand Up @@ -189,6 +190,7 @@ module.exports = function (RED) {
shape: "ring",
text: err.message,
})
console.error(err)
done(err)
})
})
Expand Down
15 changes: 9 additions & 6 deletions node-red-node-wot/src/wot-server-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ module.exports = function (RED) {

// for wot-server-config
node.getProps = () => {
const input = config.actionInputDataType === "null" ? undefined : { type: config.actionInputDataType }
const output =
config.actionOutputDataType === "null"
? undefined
: {
type: config.actionOutputDataType,
}
return {
attrType: "actions",
name: config.actionName,
outputArgs: config.outParams1_actionArgsConstValue,
content: {
description: config.actionDescription,
input: {
type: config.actionInputDataType,
},
output: {
type: config.actionOutputDataType,
},
input,
output,
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion node-red-node-wot/src/wot-server-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ module.exports = function (RED) {

// for wot-server-config
node.getProps = () => {
const type = config.propertyDataType === "null" ? undefined : config.propertyDataType
return {
attrType: "properties",
name: config.propertyName,
outputAttr: config.outParams2_writingValueConstValue,
content: {
description: config.propertyDescription,
type: config.propertyDataType,
type,
readOnly: config.propertyReadOnlyFlag,
observable: config.propertyObservableFlag,
},
Expand Down
Loading