We take care of your plant so you don't have to.
This IoT project aims at implementing remote care for a potted plant through sensors and robotics, which monitor its state.
This project was developed by Blahovici Andrei, Dumitrescu Delia, Ganea Antonio, Preda Mihai, Tudor Raluca and Ţifui Alexandru, during their third year of CS studies at University of Bucharest, under guidance of Rareș Cristea.
The documentation can also be found at Smart Pots Documentation.
More information can be found in the Customer Requirements Analysis Document wiki page.
You should have python3 and pip3 installed.
Also, you should have an MQTT Broker installed.
For installing Mosquitto MQTT Broker, go to their official website and download and install the Mosquitto Broker for your OS.
sudo apt-get install mosquitto
To check whether the service is running or not and to start it, run:
sudo systemctl status mosquitto # Checking if the service is running
sudo systemctl start mosquitto # Start the service
Install Mosquitto on Mac OS using Homebrew:
brew install mosquitto
- Install virtualenv if not already installed.
On Linux, run:
sudo pip3 install virtualenv
- Create a new virtual environment:
cd Smart-Pots/
virtualenv .venv
Note: Use .venv
or any $NAME
for your virtualenv.
- Activate the environment:
source .venv/bin/activate
and you see your .venv
activated
(.venv) ~/Smart-Pots$
Note: To deactivate the environment, simply use deactivate
.
- Install the required libraries:
pip3 install -r requirements.txt
- To switch Flask to the development environment and enable debug mode, set
FLASK_ENV
:
export FLASK_ENV=development
- Initialize (or reinitialize) database:
flask init-db
- Start the MQTT Broker service. The Broker represents an intermediary entity that enables the MQTT clients to communicate.
If Mosquitto is used, run:
sudo service mosquitto start
To test if it is running use the netstat –at
command. You should see the Mosquitto broker running on port 1883.
To stop the service, use sudo service mosquitto stop
.
- Running the application. The proper way to run the application is:
python3 app.py
This way, we make sure that SocketIO is used, as Flask is wrapped in SocketIO.
Note: To only run the Flask app (no MQTT communication), just use:
flask run
- [Optional] Run the MQTT subscriber to check that data is successfully received.
python3 mqtt_comms_sub.py
To run the tests, simply execute:
pytest
To measure the code coverage, run:
coverage run -m pytest
and then use coverage report to report on the results:
coverage report -m
For a nicer presentation, use coverage html
to get annotated HTML listings detailing missed lines.
We used the OpenAPI Initiative (OAI) to specify what our API can do.
The Swagger UI can be accessed at:
http://127.0.0.1:5000/api/docs
The AsyncAPI Specification is a comprehensive specification language for describing asynchronous messaging APIs.
If AsyncAPI Generator is not installed, you can install it by running:
npm install -g @asyncapi/generator
Then, run:
ag water.yml @asyncapi/html-template -o output
Using Read the Docs, the documentation (available at https://smart-pots.readthedocs.io/) was set up to be built automatically on each new release.
The docs was done using Sphinx. Check out the docs
directory in the top level of the project directory. docs/conf.py
controls how Sphinx runs when the docs are built.
The Makefile that was generated by Sphinx controls how shortcut commands that start with make operate. Run
make html
from the command line to manually build the docs - then, in docs->build_->html
directory you should see index.html
.
Note: we followed the Style guide for Sphinx-based documentations.
Bug identification was done by using the Restler tool. To use this run the following commands (these were tested on Linux, but if you want to test on other platforms check out the official documentation):
- Download the official repo
git clone https://github.com/microsoft/restler-fuzzer.git && cd restler-fuzzer
- Create the folder for the Restler binaries
mkdir ../restler_bin
- Build the Restler project
python ./build-restler.py --dest_dir ../restler_bin
- Delete the downloaded repo
cd .. && rm restler-fuzzer
- Go to the folder where the binaries have been built
cd restler_bin
- Compile the neccessary files for Restler
dotnet ./restler/Restler.dll compile --api_spec ./swagger.json
- Run it (for other modes check out the official documentation)
dotnet ./restler/Restler.dll test --grammar_file grammar.py --dictionary_file dict.json --settings engine_settings.json --no_ssl
- Accepted temperature and humidity values are real numbers, but at first they were checked for integers (non-floating numbers)
- Empty form bodies made all endpoints throw exceptions
Distributed under the Apache-2.0 License. See LICENSE
for more information.
Any contributions are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
The following list includes resources we found helpful and would like to give credit to:
- The Software Engineering Courses provided by University of Bucharest;
- raresito/SmartBed-RESTApi-example;
- Flask-MQTT Package Usage;
- Getting Started with OpenAPI Tools
- asyncapi/html-template.
- How to Write Your First AsyncAPI Specification
- How to Set Up Your Python Project Docs for Success🎉