Git Product home page Git Product logo

smart-pots's Introduction

Contributors Stargazers Issues MIT License

Smart Pots

We take care of your plant so you don't have to.

About The Project

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.

Built With

Getting Started

Prerequisites

You should have python3 and pip3 installed.

Also, you should have an MQTT Broker installed.

Mosquitto MQTT Broker Installation

For installing Mosquitto MQTT Broker, go to their official website and download and install the Mosquitto Broker for your OS.

For Ubuntu/Debian:

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

For Mac:

Install Mosquitto on Mac OS using Homebrew:

brew install mosquitto

Installation

  1. Install virtualenv if not already installed.

On Linux, run:

sudo pip3 install virtualenv
  1. Create a new virtual environment:
cd Smart-Pots/
virtualenv .venv

Note: Use .venv or any $NAME for your virtualenv.

  1. Activate the environment:
source .venv/bin/activate

and you see your .venv activated

(.venv) ~/Smart-Pots$

Note: To deactivate the environment, simply use deactivate.

  1. Install the required libraries:
pip3 install -r requirements.txt
  1. To switch Flask to the development environment and enable debug mode, set FLASK_ENV:
export FLASK_ENV=development
  1. Initialize (or reinitialize) database:
flask init-db

Usage

  1. 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.

  1. 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
  1. [Optional] Run the MQTT subscriber to check that data is successfully received.
python3 mqtt_comms_sub.py

Testing

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.

Developer Tools

OpenAPI

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

AsyncAPI

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

Read the Docs Documentation

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

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):

  1. Download the official repo
git clone https://github.com/microsoft/restler-fuzzer.git && cd restler-fuzzer
  1. Create the folder for the Restler binaries
mkdir ../restler_bin
  1. Build the Restler project
python ./build-restler.py --dest_dir ../restler_bin
  1. Delete the downloaded repo
cd .. && rm restler-fuzzer
  1. Go to the folder where the binaries have been built
cd restler_bin
  1. Compile the neccessary files for Restler
dotnet ./restler/Restler.dll compile --api_spec ./swagger.json
  1. 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

Identified bugs so far (and fixed):

  • 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

License

Distributed under the Apache-2.0 License. See LICENSE for more information.

Contributing

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".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Acknowledgments

The following list includes resources we found helpful and would like to give credit to:

smart-pots's People

Contributors

ralucatudor avatar predamihaidragos avatar tifui-alexandru avatar antonioganea avatar deliadumitrescu avatar dawlau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.