Indoor plant sensor simulator for early testing.
Configure the service and the connection to the OpenWeatherMap API:
- LOGGING_LEVEL (Default: "INFO"): Controls the level of logging output.
- WEATHER_API_KEY: API key to access the OpenWeatherMap API.
- WEATHER_API_URL: URL to access the OpenWeatherMap API.
Configure the connection to your RabbitMQ server:
- MQTT_HOST
- MQTT_PORT
- MQTT_USERNAME
- MQTT_PASSWORD
- MQTT_TOPIC
The simulator creates a data packet every fixed period. This packet contains simulated parameters data like:
- Temperature
- Humidity
- Light
- Watering
- Current timestamp
- Device ID
This fixed period can be:
- Every N seconds/minutes/hours.
- When a parameter P increases/decreases in a ΔP.
This parameters are fetched from the OpenWeatherMap API.
It would be nice to accept commands from TUI to simulate deviations fixes. Something like <parameter> <increase/decrease> <amount>
The repository includes a Makefile that encapsulates various commands used frequently in the project as targets. The targets are executed by invoking:
- make <target>: The essential targets to start and stop the system are docker-compose-up and docker-compose-down, with the remaining targets being useful for debugging and troubleshooting.
Available targets are:
- docker-compose-up: Initializes the development environment (builds docker images for the server and client, initializes the network used by docker, etc.) and starts the containers of the applications that make up the project.
- docker-compose-down: Performs a
docker-compose stop
to stop the containers associated with the compose and then performs adocker-compose down
to destroy all resources associated with the initialized project. It is recommended to execute this command at the end of each run to prevent the host machine's disk from filling up. - docker-compose-logs: Allows viewing the current logs of the project. Use with
grep
to filter messages from a specific application within the compose. - docker-image: Builds the images to be used. This target is used by docker-compose-up, so it can be used to test new changes in the images before starting the project.
Important Note: This service assumes a running instance of RabbitMQ and connects to it. Therefore, to run this service, it is necessary to first have the measurements service running. Please make sure to also check measurements repository.
To run the simulator using the CLI, you need to install the dependencies. Its highly recommended to use a virtual environment. You can create a virtual environment and install the dependencies by running the following commands:
cd simulator
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
After installing the dependencies, you can run the simulator by executing the following command:
cd src
python3 main.py simulator
By default, the simulator assigns a random device ID to the sensor. If you want to specify a device ID, you can pass it as an argument:
cd src
python3 main.py simulator --id-device <string>
Sorry, this is not available yet. . .
To send a custom package, you can run the following command:
cd src
python3 main.py simple-package --id-device <string> --temperature <float> --light <float> --humidity <int> --watering <int>
or reduce the typing by using the short version of the arguments:
cd src
python3 main.py simple-package -i <string> -t <float> -l <float> -h <int> -w <int>
By executing the command above, the simulator will send a package with the specified parameters.
To send a deviated package, you can run the following command:
cd src
python3 main.py deviated-package --id-device <string> --plant-name <string> --deviated-temperature <higher|lower|ideal> --deviated-light <higher|lower|ideal> --deviated-humidity <higher|lower|ideal> --deviated-watering <higher|lower|ideal>
or reduce the typing by using the short version of the arguments:
cd src
python3 main.py deviated-package -i <string> -pn <string> -dt <higher|lower|ideal> -dl <higher|lower|ideal> -dh <higher|lower|ideal> -dw <higher|lower|ideal>
By executing the command above, the simulator will send a package with the specified deviations.
The parameters deviated-temperature
, deviated-light
, deviated-humidity
, and deviated-watering
can be set to higher
, lower
, or ideal
. The simulator will generate a package with the specified deviations based on the plant's ideal values indicated in the dataset and rules defined in measurements service.