Skip to main content

A robust Python service to ingest ESPHome MQTT data into a TimescaleDB multi-table schema.

Project description

MQTT to PostgreSQL Ingestor

This project is an MQTT to PostgreSQL ingestor that allows you to collect data from MQTT messages and store it in a PostgreSQL database. It is designed to work with ESPHome devices and Home Assistant, handling various types of messages including device discovery, state updates, and commands.

Features

  • Connects to an MQTT broker and subscribes to relevant topics.
  • Processes and stores device discovery messages, entity configurations, state updates, and command messages.
  • Automatically creates necessary database tables on the first run.
  • Supports batch processing for improved performance.

Installation

To install the package, you can use pip:

pip install mqtt_postgres_ingestor

Configuration

Before running the ingestor, you need to configure the following environment variables:

  • MQTT_BROKER_HOST: The hostname or IP address of the MQTT broker.
  • MQTT_BROKER_PORT: The port number of the MQTT broker (default is 1883).
  • MQTT_USERNAME: The username for the MQTT broker (if required).
  • MQTT_PASSWORD: The password for the MQTT broker (if required).
  • DB_HOST: The hostname or IP address of the PostgreSQL database.
  • DB_PORT: The port number of the PostgreSQL database (default is 5432).
  • DB_NAME: The name of the PostgreSQL database.
  • DB_USER: The username for the PostgreSQL database.
  • DB_PASSWORD: The password for the PostgreSQL database.

Usage

To run the ingestor, execute the following command:

python -m mqtt_postgres_ingestor.ingestor

Make sure to have the required dependencies installed and the database configured properly.

Testing

To run the tests, navigate to the project directory and execute:

pytest tests/

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

esphome_mqtt_timescaledb_ingestor-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

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

File metadata

File hashes

Hashes for esphome_mqtt_timescaledb_ingestor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c5137d3e58782abd39e19a4752c2ee2f0cde91a41dc3e8a1a3e644d8ea26d42
MD5 7ac0c4e6edd63a8403e102781bad33ff
BLAKE2b-256 e6d3ce630af19405c8e58fd24c8c37274935ca2f5a943854d40d586cc20efd7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for esphome_mqtt_timescaledb_ingestor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cee96bdf0f6aa50043f5eaaaec3b8a5d105be9af702412ae034b75b2166b1906
MD5 5c894b7378aee6e1bbc62e9be50ad81d
BLAKE2b-256 ff432dfa399f665e39a0b55836f7049d9d2d0120b806c95f2459f0938a015c1b

See more details on using hashes here.

Supported by

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