Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

develop serverside nodes #26

Merged
merged 25 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f2e051d
try to make server side property node
hidetak Jan 6, 2024
46c4155
add emit property change feature for property node
hidetak Jan 8, 2024
5bec95d
improve launch processing and add action node(WIP)
hidetak Jan 10, 2024
32f6f0f
implements server-property, server-action, server-event nodes
hidetak Jan 11, 2024
af05c30
add observe feature to read-property node
hidetak Jan 13, 2024
8cf62d1
add binding setting feature and format codes
hidetak Jan 16, 2024
55f8612
remove unnecessary comment outs and modified showing status feature
hidetak Jan 18, 2024
4f3d8e7
allow the server to contain multiple things
hidetak Jan 19, 2024
4162ba0
add fearute of getting thing descriptions from global context
hidetak Jan 20, 2024
773bf34
modified error handling
hidetak Jan 22, 2024
c2f71f9
modified for perform binding-mqtt
hidetak Jan 25, 2024
540fd1d
modified feature of wot-property node for reading property by node input
hidetak Jan 26, 2024
5189480
add help for node and modified README
hidetak Jan 31, 2024
1e65c81
review logs and comments
hidetak Jan 31, 2024
77530fa
modified help and README little
hidetak Jan 31, 2024
4c2f04d
modified README little, change package version and add npm publish sc…
hidetak Feb 1, 2024
4c5436a
Merge pull request #1 from hidetak/develop-serverside-nodes
hidetak Feb 1, 2024
bdf0901
modified for publishing to npmjs
hidetak Feb 1, 2024
52feb64
little changes for publish
hidetak Feb 6, 2024
94e0a91
Merge pull request #2 from hidetak/develop-serverside-nodes
hidetak Feb 6, 2024
5333c73
modified for making PR
hidetak Feb 6, 2024
004bd4f
add description in td
hidetak Feb 14, 2024
b82fa2d
modified node-wot version to 0.8.12
hidetak Feb 16, 2024
3eac142
modified repository and homepage url in package.json
hidetak Feb 16, 2024
cb53a83
fix thing title and minor english issues
egekorkan Feb 16, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
.idea/
.vscode/settings.json
.DS_Store
/dist
/memo

5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules
.idea/
.vscode/settings.json
.DS_Store
/memo
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.md
*.json
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"semi": false,
"endOfLine": "lf"
}
92 changes: 76 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,38 @@
A [Node-RED](https://nodered.org/) package of nodes for the [Web of Things](https://www.w3.org/WoT/).

Can be installed from the Node-RED palette manager directly or via npm (see [the npm package](https://www.npmjs.com/package/node-red-contrib-web-of-things)).
The package provides nodes that can communicate with any HTTP/HTTPS, WebSocket, CoAP/CoAPS, MQTT, OPC UA and Modbus device based on its [W3C WoT Thing Description](https://www.w3.org/TR/wot-thing-description/).

The package is build upon [node-wot](https://github.com/eclipse/thingweb.node-wot) runtime environment.
The package provides nodes that can communicate with any HTTP/HTTPS, WebSocket, CoAP/CoAPS, MQTT, OPC UA, and Modbus device based on its [W3C WoT Thing Description](https://www.w3.org/TR/wot-thing-description/).
The package is built upon [node-wot](https://github.com/eclipse-thingweb/node-wot) runtime environment.

## Provided Nodes

After installation the package adds 4 different nodes at the Node-RED palette, all together scoped under "Web of Things" title.
After installation, the package adds 8 different nodes at the Node-RED palette, all together scoped under the __Web of Things__ title.
Those nodes are as follows and needed to interact with different interaction affordances of a Thing:

1) Read Property node;
2) Write Property node;
3) Invoke Action node;
4) Subscribe Event node.
4) Subscribe Event node;
5) Server-End node;
6) Server-property node;
7) Server-Action node;
8) Server-Event node.

![WoT nodes](./screenshots/nodes.png)
![WoT nodes](screenshots/nodes.png)

## Getting Started

### Consume Things

In order to consume a Thing and interact with it, drag and drop one of the interaction nodes to a flow.
Then double click on that node.
Inside the opened window click the pencil icon next to "Add new consumed-thing..." dropdown.
Inside the opened window click the pencil icon next to _Add new consumed-thing_ dropdown.

![Add new consumed Thing](./screenshots/add-thing.png)
![Add new consumed Thing](screenshots/add-thing.png)

A new window will appear.

![Add Thing Description](./screenshots/add-td.png)
![Add Thing Description](screenshots/add-td.png)

Now either copy-paste/type in a Thing Description inside the TD JSON box or fetch a Thing Description from a URL.
**Tip:** In case you choose the first option, click on the three dots to expand the JSON editor.
Expand All @@ -42,21 +45,20 @@ Or you can leave them all as they are.
Anyway, this can be changed at any time.

If a Thing needs basic authentication (i.e. using username and password) for any of its interaction affordances, you can enable that in the respective checkbox.
**Note:** Only basic type of authentication is currently supported by this package.
**Note:** Only basic authentication is currently supported by this package.
If you enable security, the nodes will automatically infer whether to use authentication for this particular affordance or not based on the provided Thing Description.

Finally, click on the red "Add" button on the top right corner.

Now, for all WoT nodes you add to a flow, you will see all the respective interaction affordances populated from the Thing Description.

You can also add more Things and choose a particular one for any node you add.

In order to see a fetched property value you can wire it with the "debug" node of Node-RED, and see all the values inside the "Debug messages" tab of Node-RED.
In order to write to a property, wire an "inject" node with the "Write Property" node.
To see a fetched property value you can wire it with the "debug" node of Node-RED, and see all the values inside the "Debug messages" tab of Node-RED.
To write to a property, wire an "inject" node with the "Write Property" node.
In the "inject" node, select JSON format as payload and plug in your value.

To send an input for an action you can also wire it with the "inject" node as explained above.
**Tip:** In order to invoke an action that does not require any input, wire it with an empty "inject" node.
**Tip:** To invoke an action that does not require any input, wire it with an empty "inject" node.

Properties and Actions also support uriVariables.
They can be specified inside "Read Property"/"Write Property"/"Invoke Action" node properties.
Expand All @@ -65,7 +67,65 @@ Subscribing to an event is pretty much the same as reading a property.

Overall, a basic flow may look like this.

![Flow Example](./screenshots/flow-example.png)
![Flow Example](screenshots/flow-example.png)

### Expose Things
Exposing Things is currently not available within this package but might be added later.

To expose a Thing, firstly, drag & drop one of the nodes belonging to the Thing, either Property(Server-Property), Action(Server-Action), or Event(Server-Event) to the canvas.

When you double-click on that node, a property screen appears.

![Property Screen](screenshots/server-property-settings.png)

On the properties screen, the `Server config` and `Thing config` must be configured. The roles of each config are as follows:

* Server config: Set up the communication method between the client and the Thing.
* Thing config: Set the attributes of the Thing such as the Thing title.

By performing `Server config` and `Thing config` in the Server-Property, Server-Action, and Server-Event nodes, you determine how to publish properties, actions, and events.

If you create a new server config on the properties screen, the following screen will appear.

![Server Config Screen](screenshots/server-config-settings.png)

Perform the following settings:

* Server name: Specify the server name.
* Binding type: Specify the communication method between the server and the client.
* Binding config: Perform settings according to the type of binding.

If you create a new thing config on the properties screen, the following screen will appear.

![Thing Config Screen](screenshots/thing-config-settings.png)

Specify the Thing title. The Thing title will be included in the Thing Description.

Server config and Thing config can be shared across multiple Server-Property, Server-Action, and Server-Event nodes. By sharing configs, you can publish one or more properties, actions, and events to the client as a single Thing.

In addition to server config and Thing config, there are necessary settings for each Server-Property, Server-Action, and Server-Event node. For the settings of each node, refer to the node help. Help can be viewed on the Node-RED editor's Help tab.

The Server-End node represents the end of a flow executed by a client request.
Flows connected to the two output terminals of the Server-Property node (read/write requests) and the output terminal of the Server-Action node must end with the Server-End node.

Here's an example of a flow:

![Server Flow Example](screenshots/server-flow-example.png)

The Thing Description required when the client uses a Thing is set in the thingDescriptions object of the global context. The member name is `<server name>::<Thing title>`.
If you want to check the Thing Description, open the Context Data tab of the Node-RED editor and press the refresh icon of the Global context to display it.

![Reference TD](screenshots/reference-td.png)

Currently, the supported binding types are HTTP, CoAP, and MQTT. As shown in the table below, each of these types of bindings has its own available/unavailable functions. Available functions are denoted by `✓` and unavailable functions are denoted by `-`.

| |http|coap|mqtt|
| :---: | :--- | :--- | :--- |
|read property|✓|✓|-|
|observe property|✓ *1|-|✓|
|write property|✓|✓|✓|
|invoke action|✓|✓|-|
|subscribe event|✓ *1|-|✓|

*1: After the connection with the server times out after 1 hour, it is not reconnected

Also, it is unclear how to define the flow when the data type is null.
Loading