---
# System prepended metadata

title: Ditto
tags: [DT]

---

###### tags: `DT`
# Ditto

https://github.com/eclipse-ditto/ditto

Document
https://www.eclipse.org/ditto/intro-overview.html
    
##  Docker
    https://docs.docker.com/engine/install/ubuntu/
    
## Docker-compose
    sudo apt install docker-compose
    
## Build up with docker
    cd deployment/docker/
    sudo docker-compose up -d

## Ditto UI
    http://localhost:8080/ui/

## Create DT 
Tutorial:
https://www.eclipse.org/ditto/intro-hello-world.html

### Create new DT

    curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' -d '{
       "definition": "digitaltwin:DigitaltwinExample:1.0.0",
       "attributes": {
     "Module": "123456"
       },
       "features": {
     "transmission": {
       "properties": {
         "rotational_speed": 100, 
         "mode": "eco"
       }
     },
     "environment": {
       "properties": {
         "temperature": 20.8,
         "humidity": 73,
         "barometricPressure": 970.7,
         "location": {
           "longitude": 47.682170,
           "latitude": 9.386372
         },
         "altitude": 399
       }
     }
       }
     }' 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine'
     
     
### Querying an existing Thing
    curl -u ditto:ditto -X GET 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine'
    
### Querying one specific state value
Get value of rotational_speed
    
    curl -u ditto:ditto -X GET 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine/features/transmission/properties/rotational_speed'
    
Get value of temperature

    curl -u ditto:ditto -X GET 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine/features/environment/properties/temperature'

    
### Updating one specific state value
Change rotational_speed to 200

    curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' -d '200' 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine/features/transmission/properties/rotational_speed'
    
Change temperature to 30

    curl -u ditto:ditto -X PUT -H 'Content-Type: application/json' -d '30' 'http://localhost:8080/api/2/things/org.eclipse.ditto:wind_turbine/features/environment/properties/temperature'

    