Skip to content
Open
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
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,21 @@ For HTTP and CoAP Things, the base URL also contains the TD.
Also see [Mashup Things](./mashups/smart-home/README.md), which are useful when combined together and are not necessarily developed for protocol testing.
Their titles and base URIs are provided below for convenience.

| Thing Title | Base URI |
| ------------------------------------------- | ------------------------------------------------------------------------- |
| http-advanced-coffee-machine | `https://plugfest.thingweb.io/http-advanced-coffee-machine` |
| http-express-calculator-simple | `https://plugfest.thingweb.io/http-express-calculator-simple` |
| http-express-calculator-content-negotiation | `https://plugfest.thingweb.io/http-express-calculator-content-negotiation`|
| http-flask-calculator | `https://plugfest.thingweb.io/http-flask-calculator` |
| http-data-schema-thing | `https://plugfest.thingweb.io/http-data-schema-thing` |
| smart-home-simple-coffee-machine | `https://plugfest.thingweb.io/smart-home-simple-coffee-machine` |
| counter | `https://plugfest.thingweb.io/counter` |
| smart-home-smart-clock | `coap://plugfest.thingweb.io:5685/smart-home-smart-clock` |
| coap-calculator-simple | `coap://plugfest.thingweb.io:5683/coap-calculator-simple` |
| coap-calculator-content-negotiation | `coap://plugfest.thingweb.io:5684/coap-calculator-content-negotiation` |
| mqtt-calculator | `mqtt://plugfest.thingweb.io/mqtt-calculator` |
| smart-home-presence-sensor | `mqtt://plugfest.thingweb.io/smart-home-presence-sensor` |
| modbus-elevator | |

| Thing Title | Base URI |
| ------------------------------------------- | -------------------------------------------------------------------------- |
| http-advanced-coffee-machine | `https://plugfest.thingweb.io/http-advanced-coffee-machine` |
| http-express-calculator-simple | `https://plugfest.thingweb.io/http-express-calculator-simple` |
| http-express-calculator-content-negotiation | `https://plugfest.thingweb.io/http-express-calculator-content-negotiation` |
| http-flask-calculator | `https://plugfest.thingweb.io/http-flask-calculator` |
| http-data-schema-thing | `https://plugfest.thingweb.io/http-data-schema-thing` |
| smart-home-simple-coffee-machine | `https://plugfest.thingweb.io/smart-home-simple-coffee-machine` |
| counter | `https://plugfest.thingweb.io/counter` |
| smart-home-smart-clock | `coap://plugfest.thingweb.io:5685/smart-home-smart-clock` |
| coap-calculator-simple | `coap://plugfest.thingweb.io:5683/coap-calculator-simple` |
| coap-calculator-content-negotiation | `coap://plugfest.thingweb.io:5684/coap-calculator-content-negotiation` |
| mqtt-calculator | `mqtt://plugfest.thingweb.io/mqtt-calculator` |
| smart-home-presence-sensor | `mqtt://plugfest.thingweb.io/smart-home-presence-sensor` |
| modbus-elevator | |

### Advanced Coffee Machine

Expand Down
5 changes: 2 additions & 3 deletions docker-compose-things.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,9 @@ services:
- traefik.udp.routers.smart-home-smart-clock.entrypoints=smart-home-smart-clock
- traefik.udp.services.smart-home-smart-clock.loadbalancer.server.port=${SMART_HOME_SMART_CLOCK_PORT_OUT}
environment:
# Since mashup communicates inside the Docker network use of localhost in a TD result as
# the mashup container's its own localhost. Therefore hostname given as their docker service name.
# In production we will have a dedicated address and this issue won't be a problem.
# Bind internally while advertising the hostname reachable by external clients.
- SMART_CLOCK_HOSTNAME=smart-home-smart-clock
- SMART_CLOCK_PUBLIC_HOSTNAME=${STACK_HOSTNAME}
- SMART_CLOCK_PORT=${SMART_HOME_SMART_CLOCK_PORT_OUT}
restart: on-failure
deploy:
Expand Down
8 changes: 8 additions & 0 deletions mashups/smart-home/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ After Things start running, the main mashup logic can be run using the command `
## Running with Docker

Every Thing and the main logic have separate docker files.

## Smart Clock Addresses

`SMART_CLOCK_HOSTNAME` sets the clock's listening address and defaults to `localhost`.
Set `SMART_CLOCK_PUBLIC_HOSTNAME` to the hostname clients should use in the generated Thing Description forms.
When it is unset or empty, node-wot keeps its automatic address discovery.
The production Compose file sets it from `STACK_HOSTNAME`.
The local stack keeps automatic discovery so the mashup can use the clock's container address instead of its own `localhost`.
6 changes: 5 additions & 1 deletion mashups/smart-home/things/smart-clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// This is an example Thing which is a smart clock that runs 60 times faster than real time, where 1 hour happens in 1 minute.

import { Servient } from "@node-wot/core";
import { Servient, Helpers } from "@node-wot/core";
import { CoapServer } from "@node-wot/binding-coap";
import * as fs from "fs";
import dotenv from "dotenv";
Expand All @@ -26,6 +26,10 @@ const thingName = "smart-home-smart-clock";
const servient = new Servient();
const hostname = process.env.SMART_CLOCK_HOSTNAME ?? "localhost";
const port = process.env.SMART_CLOCK_PORT ?? "5686";
const publicHostname = process.env.SMART_CLOCK_PUBLIC_HOSTNAME;
if (publicHostname !== undefined && publicHostname !== "") {
Helpers.setStaticAddress(publicHostname);
}
servient.addServer(
new CoapServer({
address: hostname,
Expand Down
Loading