Replies: 7 comments 17 replies
-
Pinging/inviting @sebastiankb from WoT to also join on this discussion 😀 |
Beta Was this translation helpful? Give feedback.
-
Would this work include having a WoT payload mapper? |
Beta Was this translation helpful? Give feedback.
-
@sebastiankb good idea with the example, I'll add it to the "main" thread here. ExampleWe want to model a simple Ditto "Thing" with "Features" and add a WoT "Thing Model" (and I assume also a TD) for that afterwards. Ditto Thing{
"thingId": "org.eclipse.ditto.example:smart-motion-detector",
"policyId": "org.eclipse.ditto.example:smart-motion-detector-policy",
"definition": "https://ditto.eclipseprojects.io/example-models/MotionDetector.tm.jsonld",
"attributes": {
"manufacturer": "ACME Inc",
"serialNumber": "837499231"
},
"features": {
"motion-detection": {
"definition": [
"https://ditto.eclipseprojects.io/example-models/MotionDetection.tm.jsonld",
"https://ditto.eclipseprojects.io/example-models/Switch.tm.jsonld"
],
"properties": {
"on": true,
"detection-sensitivity": 44.3,
"last-detection-time": "2021-09-07T09:38:43Z"
}
},
"environment-sensor": {
"definition": [
"https://ditto.eclipseprojects.io/example-models/TemperatureWithHumidity.tm.jsonld"
],
"properties": {
"temperature": 23.4,
"humidity": 54
}
},
"status-led": {
"definition": [
"https://ditto.eclipseprojects.io/example-models/Light.tm.jsonld",
"https://ditto.eclipseprojects.io/example-models/Switch.tm.jsonld"
],
"properties": {
"on": true,
"color": {
"red": 255,
"green": 0,
"blue": 0
}
}
}
}
} Features and their supported messagesDitto features can receive and emit messages. Receiving messages can be defined using WoT "actions" and emitting events with WoT "events".
|
Beta Was this translation helpful? Give feedback.
-
From the documentation, Expand for JSON example"functions": [
{
"id": "getAuz",
"name": "Pull permissions",
"direction": 0,
"inputData": [
{
"id": "currDate",
"name": "current timestamp",
"dataType": "long",
"description": ""
},
{
"id": "pid",
"name": "batch",
"dataType": "long",
"description": ""
}
],
"outputData": [
{
"id": "clrLocal",
"name": " clear the local data",
"dataType": "bool",
"description": ""
},
{
"id": "pid",
"name": "pid",
"dataType": "long",
"description": ""
},
{
"id": "newTs",
"name": "new timestamp",
"dataType": "long",
"description": ""
},
{
"id": "auzData",
"name": "permission data",
"dataType": "array",
"description": ""
}
]
},
{
"id": "getDevLog",
"name": "get device log",
"direction": 1,
"inputData": [
{
"id": "startTs",
"name": "start time",
"dataType": "long",
"description": ""
},
{
"id": "endTs",
"name": "end time",
"dataType": "long",
"description": ""
}
],
"outputData": [
{
"id": "logUrl",
"name": "oss address",
"dataType": "String",
"description": ""
},
{
"id": "startTs",
"name": "start time",
"dataType": "long",
"description": ""
},
{
"id": "endTs",
"name": "end time",
"dataType": "long",
"description": ""
}
]
}
] |
Beta Was this translation helpful? Give feedback.
-
just for information: the composition section is ready for review https://pr-preview.s3.amazonaws.com/w3c/wot-thing-description/pull/1207.html#thing-model-composition |
Beta Was this translation helpful? Give feedback.
-
I did some first steps with the currently implemented support for WoT and it works well 👍. One question that came up: Wouldn't it make sense to have a similar support to create a single Ditto feature from a TM like it is already possible for creating a Ditto thing? So that I can add a new "aspect" or "capability" to an existing arbitrary thing? Or even more important: to use the feature TM independent of the "containing" thing. Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
Hi @thjaeckle, do you already have an idea how to model desiredProperties in WoT TM? I didn't found any examples including desiredProperties yet. Thanks! |
Beta Was this translation helpful? Give feedback.
-
We would like to start a discussion about how Web of Things and Ditto could play together / be integrated, etc.
The Ditto project is already in contact with W3C WoT, e.g. providing feedback regarding the use of composition in the new "Thing Model" here: w3c/wot-thing-description#1177
I'd like to copy a table already created in another Ditto issue #1034 as a starting point on how to map WoT to Ditto concepts:
Thing level
An idea is currently to allow in the definition of a Ditto thing - which is currently limited to the format
<namespace>:<name>:<version>
to also allow inserting an URL.This way an URL to a WoT Thing Model could be inserted.
Once w3c/wot-thing-description#1177 is added to the WoT TM specification, the TM can also include "subcomponents" which would map to Ditto features.
Feature level
The definition of a Ditto feature (belonging to a thing) is currently also limited to being an array of string in the format
<namespace>:<name>:<version>
.As one Ditto feature maps really good to a WoT Thing Model / Thing Description, we could also allow putting URLs in that array as well which would define:
This feature follows the WoT "contract" defined by all referenced links to "Thing Models".
Outlook: Creation of Thing Definitions
Ditto could use the links to "Thing Models" in the thing definition and feature definition in order to:
GET /api/2/things/my.namespace:my-thing-name/features/temperature/properties/value
)POST /api/2/things/my.namespace:my-thing-name/features/temperature/inbox/messages/resetMinMax
)application/td+json
in a request for retrieving a thing:GET /api/2/things/my.namespace:my-thing-name
with header:Accept: application/td+json
would return the WoT Thing Description of the complete thing (all properties / actions / events)So much for our current ideas about how to integrate WoT and Ditto.
Sharing of any ideas / requirements / feedback on that would be highly appreciated as we are still in a "brainstorming" phase.
Beta Was this translation helpful? Give feedback.
All reactions