'Web of Things' support for node-red-nodegen

Web of Things (WoT)’ is a W3C standard under development, to integrate across IoT protocols/platforms. One of central building blocks of WoT is a ’Thing Description’, which describes the metadata and interface of IoT devices.

Currently, node-red-nodegen supports swagger as an interface definition language(IDL) for generate nodes. I think it is useful to support WoT Thing Description as an IDL in node-red-nodegen to easily integrate IoT devices to Node-RED. And @kazuhitoyokoi also mentioned about this on the Wiki page of node-red-nodegen.

Although WoT Thing Description is not yet published as W3C Recommendation, it is almost stable and I’ve already started to add Thing Description support for node-red-nodegen on my forked nodegen repository.

I’d like to incorporate this feature to node-red-nodegen, and to spread the tool to WoT developers. Are there any suggestions/comments for this idea?

5 Likes

WoT node template in node-red-nodegen will be useful for edge use cases of Node-RED. I think that it will also contribute to expanding the Node-RED community because a lot of companies are using Node-RED when they try WoT. I also agree with adding it into node-red-nodegen as the third node template. :+1:

"The third" surely is the Subflow template as mentioned in the wiki ?:slight_smile: I'm really looking forward to that. What's the status of that part of the nodegen project ? Is there a branch to test it on ?

@bohtho Thank you for your comment. I think that the third will be Web of Things template because there is implementation on the forked project. The fourth will be Subflow template. Currently, it is under the ideation phase.

1 Like

That is reasonable and a very interesting template in its own right. I was half joking as I understand the complexity of a subflow template, but it would be very exciting as a visual way to “code” and share work. I expect the node world would blossom in creative ways, and not necessarily in lower quality nodes.

1 Like

Thank you @ktoumura for pointing this out and for extending the node-red-nodegen. There will be a Workshop on the WoT in a couple of weeks. I believe that the Thing Description will be one of the central topics they will discuss. I would like to try out your Thing node generator. I am able to obtain my custom node from a JSON LD TD file. Nevertheless, I am a bit confused with how to connect it in a flow. Do you have some example of a flow that uses a custom Thing? I will appreciate any link or ideas. Thanks

1 Like

@jdacoello Thank you for using my tool. Unfortunately, documentation of the extended part of tool is not yet prepared. Does following description help to develop a flow?

  • Property:
    • Read: Send any message to the node, then the node emits a result.
    • Write: Send a message contains properties to write as a msg.payload. For example, to write “on” property of the Thing shown in Example 16 in TD spec, send a message like ‘{“on”: true }’ .
    • Observe: The node start observe as soon as you deploy the node, and emit a property when it is changed.
  • Action:
    • Send a message contains input parameter as payload, then the node emits a message contains ‘output’ as a result. For example, to invoke a “fade” action shown in Example 17 in TD spec, send a message like‘{“from”: 10, “to”: 90, “duration”: 10 }’.
  • Event:
    • Same as observing a property.

As you might know, TD spec is finalized as Candidate Recommendation on last week. I’m currently revising implementation to fit the recent specification, and there might be bugs in the tool. If you have any problems on the tool, please let me know through this forum, or GitHub issues.

Thank you for your response. I think the pointers you gave me are clear. Nevertheless, now I am not able to generate the node from the TD anymore. I get the following error:

Schema validation succeeded.
Error: TypeError: forms.map(...).flat is not a function

UPDATE

  • The function required a recent version of node js. I upgraded the node js to version 11.8 and the error disappeared.
  • I did the upgrade for testing purposes only. As mentioned by @knolleary, I believe the package must comply with current LTS version of Node.

That will be a bug; all of the node-red project tools should support the current active Node versions; the current LTS version is Node 10.15.3.

Thanks for your valuable feedback.

Are there ways to use the tool together with any form of authentication (In the end we are exchanging HTTP requests)? I am asking this because the master repo of the node-red-nodegen says that "supports GET and POST methods using JSON format without authentication".

What I am trying to do is interacting with sensors of a Raspberry Pi through the custom node built from the TD. Of course without using neither the RaspberryPi custom nodes, nor the HTTP nodes.

You are right. I believe the author will address that dependency soon. Nevertheless, this package is under development and I did the upgrade for testing purposes only.

@knolleary That's right. This bug caused by Array.prototype.flat(), that is only available in node.js v11 or later.
I fixed this by using concat() and reduce(), instead of flat()

Current 'Web of Things' version of nodegen is on my private repository. Before merging this code to official node-red project repository, refactoring and test code are still needed.

@jdacoello HTTP basic/digest authentication is supported in Web of Things version.
If appropriate security is set in a form, security credential can be set in the configuration panel of each node.