From a15992dbeda47c44051f30411e6deb22e2f43989 Mon Sep 17 00:00:00 2001 From: Huzaifa Abdul Rehman Date: Sun, 25 Oct 2026 15:51:25 +0500 Subject: [PATCH 1/2] Advertise the smart clock's public hostname Signed-off-by: Huzaifa Abdul Rehman --- docker-compose-things.yml | 5 ++--- mashups/smart-home/README.md | 8 ++++++++ mashups/smart-home/things/smart-clock.ts | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docker-compose-things.yml b/docker-compose-things.yml index 6c17838..b39c6b0 100644 --- a/docker-compose-things.yml +++ b/docker-compose-things.yml @@ -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: diff --git a/mashups/smart-home/README.md b/mashups/smart-home/README.md index 7bfcc99..e5469a6 100644 --- a/mashups/smart-home/README.md +++ b/mashups/smart-home/README.md @@ -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`. diff --git a/mashups/smart-home/things/smart-clock.ts b/mashups/smart-home/things/smart-clock.ts index 639e81c..5182e9f 100644 --- a/mashups/smart-home/things/smart-clock.ts +++ b/mashups/smart-home/things/smart-clock.ts @@ -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"; @@ -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, From 7892f3b5fd5947ff8b8bede5939bb0ebc77fbf9c Mon Sep 17 00:00:00 2001 From: Huzaifa Abdul Rehman Date: Sun, 25 Oct 2026 15:56:44 +0500 Subject: [PATCH 2/2] Format public device endpoint table Signed-off-by: Huzaifa Abdul Rehman --- README.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6789d79..f95265d 100644 --- a/README.md +++ b/README.md @@ -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