Skip to main content

A simple library to visualize lists.

Project description

AutoIoT Framework

AutoIoT is a framework to generate the server-side software of IoT applications. Based on a model represented as JSON, AutoIoT can generate different components of IoT applications; each component is generated by a different Specialized Builder (generators in the AutoIoT project).

Install

To install AutoIoT from this repository, clone the repository and run:

pip install dist/autoiot-0.1.0-py3-none-any.whl

Usage

To use AutoIoT you need to create a JSON file containing the description of your IoT project, like the one presented below.

In the future this JSON file will be generated by a Web Graphical User Interface (GUI).

{
    "name": "My IoT Project",
    "description": "This is a sample project to show how to use AutoIoT Specialized Builders.",
    "devices": [
        {
            "name": "Raspberry Pi",
            "description": "A small single-board computer.",
            "attributes": [
                {
                    "name": "room",
                    "type": "String"
                },
                {
                    "name": "model version",
                    "type": "Integer"
                }
            ],
            "sensors": [
                {
                    "name": "DHT11",
                    "attributes": [
                        {
                            "name": "temperature unit",
                            "type": "String"
                        }
                    ],
                    "data": [
                        {
                            "name": "temperature",
                            "type": "Float"
                        },
                        {
                            "name": "humidity",
                            "type": "Integer"
                        }
                    ]
                },
                {
                    "name": "GPS",
                    "attributes": [
                        {
                            "name": "model",
                            "type": "String"
                        }
                    ],
                    "data": [
                        {
                            "name": "position",
                            "type": "GPS"
                        }
                    ]
                }                            
            ]
        }
    ]
}

The types of data supported by AutoIoT in the description of the system are: String, Integer, Float, Boolean, GPS, Position.

Attributes represent features of devices and sensors and usually do not change very often, while data represent the data sent regularly from devices to the server application.

Now you can import this file into your code and generate the application's source code by choosing one of the available Specialized Builders. In this example we are going to use the SimpleDeviceAPI builder that is packed inside this module (others Specialized Builders need to be installed separately).

from autoiot.AutoIoT import AutoIoT
from autoiot.SimpleDeviceAPI import SimpleDeviceAPI

autoiot = AutoIoT()

autoiot.load_project_from_file('project.json')

autoiot.build(SimpleDeviceAPI, 'output')

The generated source code is written in the folder called "output".

Optionally, your can use the command line interface. Just open a command line in a folder type the following command:

autoiot -p project.json -o output

This will generate an IoT system based in your project.json file in the "output" folder.

SimpleDeviceAPI Builder

The system generated by SimpleDeviceAPI is a ready-to-use project written in Python using the FastAPI framework, it provide the abstraction of one IoT device and allow you to store and retrieve sensor data and the device information.

To make this example the simplest possible, we choose to avoid databases that require installation and configuration (e.g., PostgreSQ:, MySQL and MongoDB). The system created by this builder uses the tinyDB database.

To setup the generated system you need to navegate to its root folder (the "output" folder if you are following the example) and run the following commands:

pip install -r requirements.txt
uvicorn main:app

Your SimpleDeviceAPI system will be running in http://localhost:8000. To access its OpenAPI GUI you should use http://localhost:8000/docs, where you can try some requests and see the system in action.

The main idea behind this Specialized Builder is to be a Blueprint that shows how a Specialized Builder can be created. It is not intended to be used in production and provide very limited features.

Contributing to the project

Tests

This project uses pytest. To run the tests use:

First, you need to install the pytest-cov library to do coverage test:

pip install pytest-cov

and then run the tests:

pytest --cov-report html --cov=autoiot autoiot/tests/

Building the library

To build the library you need the wheel module:

pip install wheel

and run the following command:

python setup.py sdist bdist_wheel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visualist-0.1.0.tar.gz (74.4 kB view hashes)

Uploaded Source

Built Distribution

visualist-0.1.0-py3-none-any.whl (72.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page