Eclipse IoT Eclipse Ditto

Digital Twins as part of an open IoT platform

The Things Network Virtual Conference

16.04.2020

agenda


  1. Digital Twins
  2. Eclipse Ditto
  3. Ditto + TTN
  4. Hands-on
  5. Wrap up

Digital Twins


  • digital representation of real physical devices
  • act as broker for communicating with assets
  • also: representation of processes or services
  • applicable for both industrial and consumer-centric IoT scenarios

Eclipse Ditto


… where IoT devices and their Digital Twins get together

in context

Ditto in action

Ditto as
Digital Twin
"middleware"

turn device data into APIs

{
  "thingId": "io.foo:car1",
  "policyId": "io.foo:car1",
  "attributes": {
    "manufacturer": "Foo corp",
    "productionData": {
      "serialNo": 4711
    }
  },
  "features": {
    "temperature": {
      "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/productionData
 /api/2/things/io.foo:car1/attributes/productionData/serialNo


 /api/2/things/io.foo:car1/features
 /api/2/things/io.foo:car1/features/temperature
 /api/2/things/io.foo:car1/features/temperature/properties
 /api/2/things/io.foo:car1/features/temperature/properties/value




→ docs

persistence of device state


  • devices are not always connected to the net
  • applications always need to be able to access their data
  • twin vs. live access on API level
Ditto twin channel Ditto live channel

authorization



  • Ditto contains a built-in authorization mechanism (Policies)
  • every API call is authorized
{
    "policyId": "io.foo:car1-policy",
    "entries": {
      "owner": {
        "subjects": {
          "nginx:admin": {
            "type": "nginx basic auth user"
          }
        },
        "resources": {
          "thing:/": {
            "grant": ["READ","WRITE"],
            "revoke": []
          },
          "thing:/features/firmware": {
            "grant": [],
            "revoke": ["WRITE"]
          },
          "policy:/": {
            "grant": ["READ","WRITE"],
            "revoke": []
          }
        }
      }
    }
  }
→ docs

search


Meme Dino
  • you must not
  • Ditto has you covered
GET /api/2/search/things
  ?filter=like(attributes/manufacturer,"Foo*")
GET /api/2/search/things
  ?filter=and(
    exists(attributes/manufacturer),
    gt(features/temperature/properties/value,23.0)
  )
  &namespaces=io.foo
  &option=sort(-_modified,-attributes/manufacturer)
  &fields=thingId,attributes/manufacturer,_modified
  • search for arbitrary data with RQL query
  • Ditto again ensures authorization
  • apply field projection over the results
  • don't worry about indexing
→ docs

get notified about changes


  • notification via various channels: WebSocket, SSE, MQTT, AMQP, Kafka, HTTP hook
  • server side filtering via RQL (same as in search)
var ws = new WebSocket("ws://ditto:ditto@localhost:80/ws/2");
ws.onopen = function(w) {
  w.send('START-SEND-EVENTS?filter=gt(features/temperature/properties/value,25)');
};
ws.onmessage = function(msg) {
  console.log('received: ' + msg.data);
};

example of WebSocket browser API

→ docs

payload normalization


  • devices send data in various formats
  • Ditto provides structured APIs of things (attributes, features)
  • devices don't need to be aware of Ditto
JavaScript logo
  • incoming and outgoing data can be transformed

nonfunctional


Ditto context overview
  • modular architecture of Ditto services
  • horizontal scalability of each Ditto service
  • runtime dependency to MongoDB
  • included monitoring (JVM metrics, roundtrips, MongoDB)
  • codebase written in: Java

Eclipse Ditto +

The Things Network logo

benefit from each other


  • TTN solving low cost, wide range connectivity of devices
  • Eclipse Ditto providing APIs for IoT (backend-, web-, mobile-) applications
  • both provide free/community variants
  • both provide commercial services

integration variants


using TTN's HTTP integration

TTN via Hono to Ditto

using TTN's MQTT broker

TTN via MQTT to Ditto

* used now for the hands-on part

hands-on time!


Step-by-step blogpost

Wrap up


  • Digital Twins as pattern for simplifying IoT solution development
  • Mission: provide Device-as-a-Service
  • Eclipse Ditto as OpenSource framework for Digital Twins

thanks to The Things Network for organising this virtual conference


Links: