{"id":20448948,"url":"https://github.com/damascenorafael/mqtt-simulator","last_synced_at":"2025-04-02T06:09:33.738Z","repository":{"id":71854665,"uuid":"290316331","full_name":"DamascenoRafael/mqtt-simulator","owner":"DamascenoRafael","description":"Easy-to-configure MQTT simulator written in Python to simulate the sending of JSON objects from sensors or devices to a broker.","archived":false,"fork":false,"pushed_at":"2024-10-01T01:53:22.000Z","size":5304,"stargazers_count":62,"open_issues_count":3,"forks_count":20,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T17:15:42.964Z","etag":null,"topics":["iot","iot-simulator","mqtt","mqtt-client","mqtt-simulator","simulation","simulator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DamascenoRafael.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-25T20:27:01.000Z","updated_at":"2025-02-17T13:35:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0064747-e330-43ec-9733-e8b00337ab26","html_url":"https://github.com/DamascenoRafael/mqtt-simulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DamascenoRafael%2Fmqtt-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DamascenoRafael%2Fmqtt-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DamascenoRafael%2Fmqtt-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DamascenoRafael%2Fmqtt-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DamascenoRafael","download_url":"https://codeload.github.com/DamascenoRafael/mqtt-simulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763939,"owners_count":20829799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iot","iot-simulator","mqtt","mqtt-client","mqtt-simulator","simulation","simulator"],"created_at":"2024-11-15T10:37:50.222Z","updated_at":"2025-04-02T06:09:33.711Z","avatar_url":"https://github.com/DamascenoRafael.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT Simulator\n\nEasy-to-configure MQTT simulator written in [Python 3](https://www.python.org/) to simulate the sending of JSON objects from sensors or devices to a broker.\n\n[Features](#features) •\n[Getting Started](#getting-started) •\n[Configuration](#configuration) •\n[Main contributors](#main-contributors)\n\n![Simulator Running](images/simulator-running.gif)\n\n## Features\n\n* Small and easy-to-configure simulator for publishing data to a broker  \n* Configuration from a single JSON file  \n* Connection on pre-defined fixed topics  \n* Connection on multiple topics that have a variable id or items at the end  \n* Random variation of data generated according to configuration parameters  \n\n## Getting Started\n\n### Prerequisites\n\n* [Python 3](https://www.python.org/) (with pip)\n\n### Installing Dependencies\n\nTo install all dependencies with a virtual environment:\n\n```shell\npython3 -m venv venv\nsource venv/bin/activate\npip3 install -r requirements.txt\n```\n\n### Running\n\nThe default simulator settings can be changed in the `config/settings.json` file.\n\n```shell\npython3 mqtt-simulator/main.py\n```\n\nRuns the simulator according to the settings file.  \nThe terminal will show the simulator event log.\n\nOptionally, you can pass a flag with the path to settings file:\n\n```shell\npython3 mqtt-simulator/main.py -f \u003cpath/settings.json\u003e\n```\n\n### Running using Docker\n\nAdditionally, you can run via [Docker](https://docs.docker.com/get-docker/) with the included `Dockerfile`.\n\nBuild the image:\n\n```shell\ndocker build -t mqtt-simulator .\n```\n\nRun the container:\n\n```shell\ndocker run mqtt-simulator -f \u003cpath/settings.json\u003e\n```\n\n## Configuration\n\n* The `config/settings.json` file has the following main configuration parameters:\n\n    ```json\n    {\n        \"BROKER_URL\": \"mqtt.eclipse.org\",\n        \"BROKER_PORT\": 1883,\n        \"TOPICS\": [\n            ...\n        ]\n    }\n    ```\n\n    | Key | Type |  Default | Description |\n    | --- | --- | --- | --- |\n    | `BROKER_URL` | string | localhost | The broker URL where the data will be published |\n    | `BROKER_PORT` | number | 1883 | The port used by the broker |\n    | `PROTOCOL_VERSION` | number | 4 | Sets the [paho.mqtt.client] `protocol` param which is the version of the MQTT protocol to use for this client. Can be either `3` (MQTTv31), `4` (MQTTv311) or `5` (MQTTv5) |\n    | `CLEAN_SESSION` | bool | True | Sets the [paho.mqtt.client] `clean_session` param which is a boolean that determines the client type. This property is ignored if `PROTOCOL_VERSION` is `5`. |\n    | `RETAIN` | bool | False | Sets the [paho.mqtt.publish] `retain` param which sets the “last known good”/retained message for the topic |\n    | `QOS` | number | 2 | Sets the [paho.mqtt.publish] `qos` param which is the quality of service level to use |\n    | `TIME_INTERVAL` | number | 10 | Time interval in seconds between submissions towards the topic |\n    | `TOPICS` | array\\\u003cobject\u003e | None | Specification of topics and how they will be published |\n\n[paho.mqtt.client]:https://pypi.org/project/paho-mqtt/#constructor-reinitialise\n[paho.mqtt.publish]:https://pypi.org/project/paho-mqtt/#publishing\n\n* The key **TOPICS** has a array of objects where each one has the format:\n\n    ```json\n    {\n        \"TYPE\": \"multiple\",\n        \"PREFIX\": \"temperature\",\n        \"RANGE_START\": 1,\n        \"RANGE_END\": 2,\n        \"TIME_INTERVAL\": 25,\n        \"DATA\": [\n            ...\n        ]\n    }\n    ```\n\n    | Key | Type | Description | Required |\n    | --- | --- | --- | --- |\n    | `TYPE` | string | It can be `\"single\"`, `\"multiple\"` or `\"list\"` | yes |\n    | `PREFIX` | string | Prefix of the topic URL, depending on the `TYPE` it can be concatenated to `/\u003cid\u003e` or `/\u003citem\u003e` | yes |\n    | `LIST` | array\\\u003cany\u003e | When the `TYPE` is `\"list\"` the topic prefix will be concatenated with `/\u003citem\u003e` for each item in the array | if `TYPE` is `\"list\"` |\n    | `RANGE_START` | number | When the `TYPE` is `\"multiple\"` the topic prefix will be concatenated with `/\u003cid\u003e` where `RANGE_START` will be the first number  | if `TYPE` is `\"multiple\"`  |\n    | `RANGE_END` | number | When the `TYPE` is `\"multiple\"` the topic prefix will be concatenated with `/\u003cid\u003e` where `RANGE_END` will be the last number | if `TYPE` is `\"multiple\"`  |\n    | `CLEAN_SESSION` | bool | Overwrites the broker level config value and applies only to this Topic | no |\n    | `RETAIN` | bool | Overwrites the broker level config value and applies only to this Topic | no |\n    | `QOS` | number | Overwrites the broker level config value and applies only to this Topic | no |\n    | `TIME_INTERVAL` | number |  Overwrites the broker level config value and applies only to this Topic | no |\n    | `PAYLOAD_ROOT` | object | The root set of params to include on all messages | optional |\n    | `DATA` | array\\\u003cobject\u003e | Specification of the data that will form the JSON to be sent in the topic | yes |\n\n* The key **DATA** inside TOPICS has a array of objects where each one has the format:\n\n    ```json\n    {\n        \"NAME\": \"temperature\",\n        \"TYPE\": \"float\",\n        \"INITIAL_VALUE\": 35,\n        \"MIN_VALUE\": 30,\n        \"MAX_VALUE\": 40,\n        \"MAX_STEP\": 0.2,\n        \"RETAIN_PROBABILITY\": 0.5,\n        \"RESET_PROBABILITY\": 0.1,\n        \"INCREASE_PROBABILITY\": 0.7,\n        \"RESTART_ON_BOUNDARIES\": true\n    }\n    ```\n\n    | Key | Type | Description | Required |\n    | --- | --- | --- | --- |\n    | `NAME` | string | JSON property name to be sent | yes |\n    | `TYPE` | string | It can be `\"int\"`, `\"float\"`, `\"bool\"`, `\"math_expression\"` or `\"raw_values\"` | yes |\n    | `RETAIN_PROBABILITY` | number | Number between 0 and 1 for the probability of the value being retained and sent again | optional, default is `0` |\n    | `RESET_PROBABILITY` | number | Number between 0 and 1 for the probability of the value being reset to `INITIAL_VALUE` | optional, default is `0` |\n    | `INITIAL_VALUE` | same that is returned according to `TYPE` | Initial value that the property will assume when the simulation starts. If not specified: random for `\"int\"`, `\"float\"` or `\"bool\"`, and determined by other parameters for `\"math_expression\"` or `\"raw_values\"` | optional |\n    | `MIN_VALUE` | number | Minimum value that the property can assume | if `TYPE` is `\"int\"` or `\"float\"` |\n    | `MAX_VALUE` | number | Maximum value that the property can assume | if `TYPE` is `\"int\"` or `\"float\"`  |\n    | `MAX_STEP` | number | Maximum change that can be applied to the property from a published data to the next | if `TYPE` is `\"int\"` or `\"float\"` |\n    | `INCREASE_PROBABILITY` | number | Number between 0 and 1 for the probability of the next value being greater than the previous one | optional, default is `0.5` (same probability to increase or decrease). Only valid if `TYPE` is `\"int\"` or `\"float\"` |\n    | `RESTART_ON_BOUNDARIES` | bool | When true and the value reaches `MAX_VALUE` or `MIN_VALUE` the next value will be the `INITIAL_VALUE` | optional, default is false. Only valid if `TYPE` is `\"int\"` or `\"float\"` |\n    | `MATH_EXPRESSION` | string | Math expression written in a *Pythonic* way. Also accept functions from [Math modules](https://docs.python.org/3/library/math.html)  | if `TYPE` is `\"math_expression\"` |\n    | `INTERVAL_START` | number | Minimum value that the `MATH_EXPRESSION`'s variable `x` can assume | if `TYPE` is `\"math_expression\"` |\n    | `INTERVAL_END` | number | Maximum value that the `MATH_EXPRESSION`'s variable `x` can assume | if `TYPE` is `\"math_expression\"` |\n    | `MIN_DELTA` | number | Minimum value that can be added to the  `MATH_EXPRESSION`'s variable `x` from a published data to the next | if `TYPE` is `\"math_expression\"` |\n    | `MAX_DELTA` | number | Maximum value that can be added to the  `MATH_EXPRESSION`'s variable `x` from a published data to the next | if `TYPE` is `\"math_expression\"` |\n    | `INDEX_START` | number | The index to start publishing from the `VALUES` array | optional, default is `0`. Only valid if `TYPE` is `\"raw_values\"` |\n    | `INDEX_END` | number | The index to end publishing from the `VALUES` array | optional, default is `len(values) - 1`. Only valid if `TYPE` is `\"raw_values\"` |\n    | `RESTART_ON_END` | bool | When true and the index of the `VALUES` array reaches `INDEX_END`, the next index will be `INDEX_START`. Otherwise, the param will become inactive and won’t be sent after reaching `INDEX_END` | optional, default is false. Only valid if `TYPE` is `\"raw_values\"` |\n    | `VALUES` | array\\\u003cany\u003e | The values to be published in array order | if `TYPE` is `\"raw_values\"` |\n    | `VALUE_DEFAULT` | object | The default value params used or overwritten by params in `VALUES` | optional, default is `{}`. Only valid if `TYPE` is `\"raw_values\"` and `VALUES` is an array\\\u003cobject\u003e |\n\n    \u003e **_NOTE:_** Access [math_expression.md](./docs/math_expression.md) file for more explanations and a example of `TYPE: \"math_expression\"`.\n\n## Main contributors\n\n[![DamascenoRafael](https://github.com/DamascenoRafael.png?size=70)](https://github.com/DamascenoRafael)\n[![Maasouza](https://github.com/Maasouza.png?size=70)](https://github.com/Maasouza)\n[![AJ Danelz](https://github.com/vordimous.png?size=70)](https://github.com/vordimous)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamascenorafael%2Fmqtt-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamascenorafael%2Fmqtt-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamascenorafael%2Fmqtt-simulator/lists"}