Skip to main content

Home Assistant Data Collection Service and Database

Project description

Home Assistant LiteDB

Home Assistant LiteDB is a Python script designed to interact with Home Assistant, fetch entities, save them to a local SQLite database, and provide various command-line functionalities.

Features

  • Fetch entities from Home Assistant and save them to a SQLite database.
  • Purge the database and recreate it.
  • Display the last 50 rows of logs.
  • Configurable polling interval.
  • Logging to file and/or console.

Installation

  1. Clone the repository:

    git clone https://github.com/willmo103/home_assistant_litedb.git
    cd home_assistant_litedb
    
  2. Create a virtual environment and install dependencies:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    pip install -r requirements.txt
    
  3. Run the setup script to create the configuration file:

    python setup.py
    
  4. Edit conf.yml to add your Home Assistant URL and long-lived access token.

Usage

Command Line Arguments

  • -d, --debug: Run once and output logging to terminal.
  • -p, --purge: Purge entire database and recreate, do not poll after creation, exit and inform.
  • -l, --logs: Display the last 50 rows of the logs.
  • --run-detached: Run this script headless.
  • --run-no-logging: Run this script without logging (can only be used with -d or --debug).

Examples

  1. Fetch entities and save to database:

    python home_assistant_litedb/main.py
    
  2. Run in debug mode:

    python home_assistant_litedb/main.py --debug
    
  3. Purge the database:

    python home_assistant_litedb/main.py --purge
    
  4. Display the last 50 rows of logs:

    python home_assistant_litedb/main.py --logs
    

Configuration

The configuration is stored in conf.yml. Edit this file to set your Home Assistant URL, token, database path, and polling interval.

Example conf.yml:

HA_URL: 'http://192.168.xxx.xxx:8123'
HA_TOKEN: '<your_long_lived_access_token>'
DB_PATH: 'C:\\Users\\YourUsername\\HomeAssistantLiteDB.db'
POLL_INTERVAL: 120

License

This project is licensed under the MIT License.

Roadmap

  • Integration with Other Home Automation Platforms
    • Extend the functionality of Home-Assistant LiteDB to support data collection and management from other popular home automation platforms.
    • Implement a unified interface to manage data from multiple platforms.

Read the full Roadmap.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Contact

For any issues or questions, please open an issue on GitHub or contact me at willmorris103@gmail.com.

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

home_assistant_litedb-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

home_assistant_litedb-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file home_assistant_litedb-0.1.0.tar.gz.

File metadata

  • Download URL: home_assistant_litedb-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for home_assistant_litedb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee96555bc1f2f5567c669df7482a49b30857b02d6fc8d8d1e4520fff96a54cca
MD5 69860e2b76b29eab6548b7f357601f89
BLAKE2b-256 868dff21fc533d1409f7397228010ec624d605afb0ae945f43187e8cecfe6fae

See more details on using hashes here.

File details

Details for the file home_assistant_litedb-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for home_assistant_litedb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b08522fe5c3ba41621414a2a5d4fb9776c2472aee5a3f9569e021836ac8fbc
MD5 35f06a1b133144fbc038c95126061d86
BLAKE2b-256 6364ac3f21eccb64a25ec8a36f26c2eda31b8a984ea18fb95f11272e4e993b1f

See more details on using hashes here.

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