Ditto as
Digital Twin
"middleware"
{
"thingId": "io.foo:car1",
"policyId": "io.foo:car1",
"attributes": {
"manufacturer": "Foo",
"data": {
"serialNo": 4711
}
},
"features": {
"temp": {
"properties": {
"value": 23.42
}
}
}
}
JSON repr. of a Thing
GET/PUT/DELETE /api/2/things/io.foo:car1
/api/2/things/io.foo:car1/thingId
/api/2/things/io.foo:car1/policyId
/api/2/things/io.foo:car1/attributes
/api/2/things/io.foo:car1/attributes/manufacturer
/api/2/things/io.foo:car1/attributes/data
/api/2/things/io.foo:car1/attributes/data/serialNo
/api/2/things/io.foo:car1/features
/api/2/things/io.foo:car1/features/temp
/api/2/things/io.foo:car1/features/temp/properties
/api/2/things/io.foo:car1/features/temp/properties/value
HTTP API of the Thing
→ docs{
"thingId": "io.foo:lamp-1",
"policyId": "io.foo:lamp-1",
"definition": "https://some.domain/floor-lamp-1.0.0.tm.jsonld",
"attributes": {
"Manufacturer": "Foo corp",
"serialNo": "4711"
},
"features": {
"Spot1": {
"definition": [
"https://some.domain/dimmable-colored-lamp-1.0.0.tm.jsonld",
"https://some.domain/colored-lamp-1.0.0.tm.jsonld",
"https://some.domain/switchable-1.0.0.tm.jsonld"
],
"properties": {
"on": true,
"color": {...
}
}
}
}
}
→ docs
GET /api/2/search/things
?filter=like(attributes/manufacturer,"Foo*")
GET /api/2/search/things
?filter=and(
eq(features/*/definition,"https://some.domain/switchable-1.0.0.tm.jsonld"),
like(attributes/manufacturer,"Foo*"),
not(gt(attributes/counter,42))
)
&fields=thingId,attributes/manufacturer,features/*/properties/on
Let Ditto provide WoT TDs via Digital Twin APIs
by referencing to WoT TMs in Ditto "things"
tm:extends
and imports via tm:ref
,
Thing level compositions via tm:submodel
and TM placeholderscurl -u ditto:ditto \
'https://ditto.eclipseprojects.io/api/2/things/io.eclipseprojects.ditto:floor-lamp-0815' \
-H 'Accept: application/td+json'
{
@context":["https://www.w3.org/2022/wot/td/v1.1", ...],
"title":"Floor Lamp",
"@type":"Thing",
"id":"urn:io.eclipseprojects.ditto:floor-lamp-0815",
"base":"https://ditto.eclipseprojects.io/api/2/things/io.eclipseprojects.ditto:floor-lamp-0815",
"version":{"model":"1.0.0","instance":"1.0.0"},
"links":[{
"rel":"type",
"href":"https://eclipse-ditto.github.io/ditto-examples/wot/models/floor-lamp-1.0.0.tm.jsonld",
"type":"application/tm+json"
},{
"rel":"item",
"type":"application/td+json",
"href":"/features/Spot1"
},...],
"security":"basic_sc",
"securityDefinitions":{"basic_sc":{"in":"header","scheme":"basic"}},
"forms":[{"op":"readallproperties","href":"/attributes{?channel,timeout}","htv:methodName":"GET","contentType":"application/json"
...
}
curl -X PUT -u ditto:ditto \
'https://ditto.eclipseprojects.io/api/2/things/io.eclipseprojects.ditto:floor-lamp-0815' \
-H 'Content-Type: application/json' \
--data-raw '{
"definition": "https://eclipse-ditto.github.io/ditto-examples/wot/models/floor-lamp-1.0.0.tm.jsonld"
}'
{
"thingId": "io.eclipseprojects.ditto:floor-lamp-0815",
"policyId": "io.eclipseprojects.ditto:floor-lamp-0815",
"definition": "https://eclipse-ditto.github.io/ditto-examples/wot/models/floor-lamp-1.0.0.tm.jsonld",
"attributes": {
"manufacturer": "",
"serialNo": "https://some.domain/switchable-1.0.0.tm.jsonld"
},
"features": {
"Spot1": {
"definition": [
"https://eclipse-ditto.github.io/ditto-examples/wot/models/dimmable-colored-lamp-1.0.0.tm.jsonld",
"https://eclipse-ditto.github.io/ditto-examples/wot/models/colored-lamp-1.0.0.tm.jsonld",
"https://eclipse-ditto.github.io/ditto-examples/wot/models/switchable-1.0.0.tm.jsonld"
],
"properties": {
"dimmer-level": 0.0,
"color": {
"r": 0,
"g": 0,
"b": 0
},
"on": false
}
...