This is a hands-on tutorial to teach simple Web of Things concepts. It involves interacting with different WoT Things over the Internet via different protocols.
- package.json with dependencies: This will install the dependencies needed. Please use
npm install
to install the dependencies. - index.js with boilerplate: You should fill this with your own code.
You can clone this repository or download only this folder via this service.
- Node.js 18: You can install via the official download page.
- Optional: HTTP, CoAP and MQTT clients if you want to debug or understand what happens behind node-wot. Some recommended ones:
You want to automate a small part of your home. The room setup can be seen in the illustration below.
Each morning, when you wake up and go towards the kitchen area, you want the coffee to be brewed automatically. Your task is to write a script that brews the coffee of your choice when you pass in front the presence sensor in the kitchen if it is earlier than 13:00 but later than 5:00.
We have three WoT Things that are hosted by the Eclipse Thingweb project. Their TDs are linked below:
You can interact with them over the Internet and send requests. You should read their Thing Description to understand how to interact with them. The Node.js based library, node-wot, simplifies this process and will be installed as a dependency. It is the reference implementation of the WoT Scripting API, which has an example code here.
Alternatively, you can send requests manually. You can refer to the WoT Binding Templates that explains how to read forms in a TD as a human.
A solution is available in this folder. You can build other solutions and expand on them for other scenarios.
If you want, you can also self-host the Things used in this tutorial. They are available in the Eclipse Thingweb project at https://github.com/eclipse-thingweb/node-wot/tree/master/examples/quickstart.