Giter Club home page Giter Club logo

iot-pnp-simple-simulator's Introduction

About

Easily start IoT Hub simulators using DTDL / Azure IoT Plug & Play models.

This project generates a Docker Image from the excellent Azure IoT Device Simulator jonmikeli/azureiotdevicesimulator5-pnp. It provides a simple way to start the simulator with default settings. You are only required you to provide a Connection String and a DTDL model.

You can find official DTDL models here.

DTDL v2 is defined here.

If you need more advanced settings, please check out @jonmikeli's repo linked above.

Usage

docker run --rm -ti \
  -e IOT_HUB_CONNECTION_STRING="HostName=iothub-x.azure-devices.net;DeviceId=simulated-device;SharedAccessKey=y" \
  -e MODEL_URL="https://raw.githubusercontent.com/Azure/opendigitaltwins-dtdl/master/DTDL/v2/samples/Thermostat.json" \
  ghcr.io/stefan-hudelmaier/iot-pnp-simple-simulator:main

Environment Variables:

Variable Description
IOT_HUB_CONNECTION_STRING The connection string of the IoT Hub device to be simulated
MODEL_URL The URL to a IoT Plug & Play model in DTDL format. When using a model from GitHub, remember to use the 'raw' link.

As soon as you have started the container, you should see telemetry values being sent:

09/08/2021 16:46:29::logType:data::simulated-device::Sent message: [
  {
    "temperature": 0.014509523294172027
  }
].

The simulator can also handle direct methods defined in the DTDL. Invoking the getMaxMinReport direct method defined in Thermostat.json (that was used in the example above) results in the following output and response:

dbug: IoT.Simulator.Services.DeviceSimulationService[0]
      09/08/2021 13:56:07::logType:c2ddirectmethods.dtdlcommand.handler::DTDL Command called: getMaxMinReport with payload {}.
dbug: IoT.Simulator.Services.DeviceSimulationService[0]
      09/08/2021 13:56:07::logType:c2ddirectmethods.dtdlcommand.handler::DTDL Command response: {
        "request": {
          "since": "2021-09-13T17:53:02.6077651+00:00"
        },
        "response": {
          "tempReport": {
            "maxTemp": 0.9224262367572758,
            "minTemp": 0.05373290928720166,
            "avgTemp": 0.11802005680185745,
            "startTime": "2021-09-10T03:53:02.6546508+00:00",
            "endTime": "2021-09-08T15:53:02.6552922+00:00"
          }
        }
      } to request {}.

iot-pnp-simple-simulator's People

Contributors

stefan-hudelmaier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.