{"id":19310597,"url":"https://github.com/sepppenner/mqtt2postgresbridge","last_synced_at":"2025-04-22T13:34:26.464Z","repository":{"id":82869197,"uuid":"146170477","full_name":"SeppPenner/MQTT2PostgresBridge","owner":"SeppPenner","description":"MQTT2PostgresBridge is a project to connect a locally running broker to a Postgres database and store the messages in a database table. The project was written and tested in Python 3.","archived":false,"fork":false,"pushed_at":"2023-07-03T17:51:05.000Z","size":20,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T00:24:44.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeppPenner.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-26T10:16:14.000Z","updated_at":"2025-02-12T06:37:54.000Z","dependencies_parsed_at":"2023-07-11T18:46:36.564Z","dependency_job_id":null,"html_url":"https://github.com/SeppPenner/MQTT2PostgresBridge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2PostgresBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2PostgresBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2PostgresBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeppPenner%2FMQTT2PostgresBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeppPenner","download_url":"https://codeload.github.com/SeppPenner/MQTT2PostgresBridge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250249137,"owners_count":21399403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T00:25:06.485Z","updated_at":"2025-04-22T13:34:26.447Z","avatar_url":"https://github.com/SeppPenner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT2PostgresBridge\n\nMQTT2PostgresBridge is a project to connect a locally running broker to a Postgres database and store the messages in a database table. The project was written and tested in Python 3.\n\n[![Build status](https://ci.appveyor.com/api/projects/status/bhqkj3oacr7jix8x?svg=true)](https://ci.appveyor.com/project/SeppPenner/mqtt2postgresbridge)\n[![GitHub issues](https://img.shields.io/github/issues/SeppPenner/MQTT2PostgresBridge.svg)](https://github.com/SeppPenner/MQTT2PostgresBridge/issues)\n[![GitHub forks](https://img.shields.io/github/forks/SeppPenner/MQTT2PostgresBridge.svg)](https://github.com/SeppPenner/MQTT2PostgresBridge/network)\n[![GitHub stars](https://img.shields.io/github/stars/SeppPenner/MQTT2PostgresBridge.svg)](https://github.com/SeppPenner/MQTT2PostgresBridge/stargazers)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/SeppPenner/MQTT2PostgresBridge/master/License.txt)\n[![Known Vulnerabilities](https://snyk.io/test/github/SeppPenner/MQTT2PostgresBridge/badge.svg)](https://snyk.io/test/github/SeppPenner/MQTT2PostgresBridge) \n\n## Adjust your settings:\n\n* Adjust the broker to the address you want to use: `broker_source`\n* Add your custom filters to `filterMessage()` if you want to filter messages\n* Adjust your credentials (uncomment if anonymous): \n\n```python\nclient_source.username_pw_set(\"mqtt\", \"IoT\")\n```\n\n* Adjust your PostgreSQL credentials:\n\n```python\nDatabaseHostName = 'YourHost'\nDatabaseUserName = 'YourUser'\nDatabasePassword = 'YourPassword'\nDatabasePort = 5432\n```\n\n* Run the script `SetupDatabase.sql` on your database to setup the database correctly\n\n* Add filters to the bridging like described in the `bridgeFiltering.py` file if needed:\n\n```python\ndef filterMessage(payload, topic, qos):\n\t\"Filters the messages depending on the configuration for the attributes payload, topic and QoS. 'True' means that the message is not forwarded.\"\n\t# Examples below:\n\tif(payload == \"10 %\"):\n\t\tprint('Filtered: payload == \"10 %\"')\n\t\treturn True\n\tif(topic == \"humidity\" and qos == 0):\n\t\tprint('Filtered: topic == \"humidity\" and qos == 0')\n\t\treturn True\n\tif(topic == \"temperature\" or qos == 2):\n\t\tprint('Filtered: topic == \"temperature\" or qos == 2')\n\t\treturn True\n\t#Add your filters here\n```\n\n## Setup on the Raspberry Pi\n\n```bash\nsudo apt-get install python3\nsudo apt-get install python3-pip\nsudo pip3 install paho-mqtt\nsudo pip3 install psycopg2\n```\n\nor\n\n```bash\nsudo apt-get install python3\nsudo apt-get install python3-pip\nsudo pip3 install -r requirements.txt\n```\n\n## Running the programms:\n\n```bash\npython3 bridge.py\npython3 bridgeFiltering.py\n```\n\n## Installing the latest version of Python (Currently 3.7.4) on the Raspberry Pi:\n\nhttps://gist.github.com/SeppPenner/6a5a30ebc8f79936fa136c524417761d\n\n## Paho MQTT client documentation\n\n* https://pypi.org/project/paho-mqtt/\n* https://www.hivemq.com/blog/mqtt-client-library-paho-python\n\n## Postgres client documentation\n\n* http://www.postgresqltutorial.com/postgresql-python/connect/\n* http://www.postgresqltutorial.com/postgresql-python/call-stored-procedures/\n\n## See also\n\n* [MQTT2AWSS3Bridge](https://github.com/SeppPenner/MQTT2AWSS3Bridge)\n* [MQTT2MySQLBridge](https://github.com/SeppPenner/MQTT2MySQLBridge)\n* [MQTT2MQTTBridge](https://github.com/SeppPenner/MQTT2MQTTBridge)\n\nChange history\n--------------\n\nSee the [Changelog](https://github.com/SeppPenner/MQTT2PostgresBridge/blob/master/Changelog.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsepppenner%2Fmqtt2postgresbridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsepppenner%2Fmqtt2postgresbridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsepppenner%2Fmqtt2postgresbridge/lists"}