Can a WoT Thing modify its own Thing Description?

Viewed 55

I have a use-case where the "href" of the forms in the Thing Description must contain the MAC address of the device (or some ID unique to that device). The form description would look as follows:

"forms": [
    {
      "op": [
        "readproperty"  
      ],
      "href": "/things/01-02-03-04-05-06/properties/temperature",
      "contentType": "application/json",
      "mqv:controlPacketValue": "SUBSCRIBE"
    }
  ]

I think it would make sense to use a placeholder for the MAC address like this

"href": "/things/[MAC]/properties/temperature"

The device would then replace the placeholder with its own MAC. This way, the Thing Description doesn't have to be adjusted when a different device is used.

Does the WoT specification consider the use of such placeholders in the Thing Description? Does anything speak against the Thing modifying its own Thing Description?

This idea might also be expanded to having the Thing setting other attributes in the TD, to the Thing completely generating its own TD (although the effort for this stand in no relation to the use, in my case).

1 Answers

Version 1.1 of the TD specification defines Thing Models (https://w3c.github.io/wot-thing-description/#thing-model) where such placeholders can be used. However, Thing Models are not exchanged with usual WoT Consumers since they would expect no out-of-band information other than security credentials. You can however think of a mechanism that sends a Thing Model and a placeholder map that can be used to generate a TD with concrete endpoints.

Regarding how a TD can be managed, especially updated, it is a bit tricky. You need to think that there are WoT Consumers that consume a TD and do not have a way of handling changes, i.e. being notified of updates and how to incorporate those updates into the Consumer application logic. You can also look at https://github.com/w3c/wot-thing-description/issues/1174 . The Discovery specification has started working on how TDs are managed though, you can look at https://w3c.github.io/wot-discovery/

Related