Giter VIP home page Giter VIP logo

aag-weather's Introduction

aag-weather

A small script that is capable of reading the Lunatico AAG Cloud Watcher weather station data, including the anemometer.

Install

Clone the repository and then run either:

python setup.py install

or

pip install -r requirements.txt
pip install -e .

Running

Read AAG

The scripts/read-aag.py file is responsible for reading the serial data from the AAG. It requires a config file in order to properly read from the AAG, with default values provided by config.yaml. If you require any values to change (for instance the serial_address or the threshold values), then you can copy the config file to another location and specify it on the command line.

➜ scripts/read-aag.py --help
usage: read-aag.py [-h] --config-file CONFIG_FILE [--store-result]
                   [--db-file DB_FILE] [--db-table DB_TABLE]
                   [--serial-address SERIAL_ADDRESS] [--verbose]

Read an AAG CloudWatcher

optional arguments:
  -h, --help            show this help message and exit
  --config-file CONFIG_FILE
                        Config file that contains the AAG params.
  --store-result        If data entries should be saved to db, default False.
  --db-file DB_FILE     Name of sqlite3 db file to use.
  --db-table DB_TABLE   Name of db table to use.
  --serial-address SERIAL_ADDRESS
                        USB serial address to use. If None, value from config
                        will be used.
  --verbose             Output data on the command line.

Serve AAG data

⚠️ NOTE: There has been no attempt made to make this secure and Flask runs the development server out of the box. This is suitable for testing and a minimal network implementation but should never be used on an unsecure network (aren't they all?) and never in a "production" environment. Use at your own risk.

A minimal flask server is included with the repository that can be used to serve the latest results over the network.

The flask server provides two endpoints:

  • /latest.json: This will serve the latest weather records returned as JSON. By default will only return the most recent record, but num_records=5 can be used to return more records.
  • /download-db: Will send the weather.db as a file attachment for downloading.

Configure Flask Server

The Flask server uses python-dotenv for configuration. To configure, create a .env file in the main directory and add the absolute path to the database file. If a relative path is given then the latest.json endpoint will still work but the database will not be available for download.

Example .env file:

FLASK_DEBUG=1
DB_NAME=/home/pi/aag-weather/weather.db

If you would like to make the server available at your public IP address, add the host to the .env file, e.g.:

⚠️ 🐉 ⚠️ Use at your own risk.

FLASK_RUN_HOST=0.0.0.0
FLASK_RUN_PORT=8989

Running Flask Server

The Flask server uses the Flask command line interface. To start, run the following from the root of the repository:

flask run

aag-weather's People

Contributors

wtgee avatar

Watchers

James Cloos 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.