Skip to main content

Device Simulator

This is a guide to get started with the python CLI Device Simulator.

You need to have a mqtt broker set up. The device simulator will connect to it.

  1. Clone StormPythonDeviceSimulator.

  2. Open a commandline terminal and navigate to the folder of the cloned project. Run

    pip install -r requirements.txt
  3. In the projects folder, create a secrets.py and insert the details of your mqtt broker.

    BROKER_ADDRESS = "your_broker_address"
    BROKER_PORT = your_broker_port
    USERNAME = "your_username"
    PASSWORD = "your_password"
  4. Edit devices.json. This is where you define your devices. Example:

    [
    {
    "name": "Temperature Sensor",
    "base_topic": "sensor/temperature",
    "unit": "°C",
    "datatype": "float",
    "min_value": 18,
    "max_value": 30,
    "publish_interval": 0.5,
    "parameters": {
    "setpoint": {
    "datatype": "float",
    "min": 0,
    "max": 100
    },
    "enabled": {
    "datatype": "bool"
    }
    }
    }
    ]

    You can add as many devices as you want, just separate each {...} with a comma. Look at the default devices.json in the project folder for reference.

  5. In commandline run

    python device_simulator.py

    It should look something like the picture below. The connection result 0 means success. It is a standard MQTT result code.:

Start device simulator terminal image