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.
-
Clone StormPythonDeviceSimulator.
-
Open a commandline terminal and navigate to the folder of the cloned project. Run
pip install -r requirements.txt -
In the projects folder, create a
secrets.pyand insert the details of your mqtt broker.BROKER_ADDRESS = "your_broker_address"
BROKER_PORT = your_broker_port
USERNAME = "your_username"
PASSWORD = "your_password" -
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 defaultdevices.jsonin the project folder for reference. -
In commandline run
python device_simulator.pyIt should look something like the picture below. The connection result 0 means success. It is a standard MQTT result code.:
