{"id":31779803,"url":"https://github.com/straightchlorine/async-httpd-data-collector","last_synced_at":"2025-10-10T07:57:40.482Z","repository":{"id":239300699,"uuid":"799150025","full_name":"straightchlorine/async-httpd-data-collector","owner":"straightchlorine","description":"Python gateway facilitating seamless communication between sensory data-emitting devices and InfluxDB. Manages asynchronous fetching, querying, and storage operations.","archived":false,"fork":false,"pushed_at":"2024-07-30T13:13:51.000Z","size":126,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T03:17:22.348Z","etag":null,"topics":["asyncio","flask","github-actions","influxdb2","middleware","pytest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/straightchlorine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-11T10:04:02.000Z","updated_at":"2025-01-23T10:04:33.000Z","dependencies_parsed_at":"2024-05-16T14:48:19.252Z","dependency_job_id":"40e2872d-fed7-4a8a-9407-6ff6611ae0ad","html_url":"https://github.com/straightchlorine/async-httpd-data-collector","commit_stats":null,"previous_names":["straightchlorine/async-httpd-data-collector"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/straightchlorine/async-httpd-data-collector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straightchlorine%2Fasync-httpd-data-collector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straightchlorine%2Fasync-httpd-data-collector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straightchlorine%2Fasync-httpd-data-collector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straightchlorine%2Fasync-httpd-data-collector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/straightchlorine","download_url":"https://codeload.github.com/straightchlorine/async-httpd-data-collector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straightchlorine%2Fasync-httpd-data-collector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003164,"owners_count":26083533,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asyncio","flask","github-actions","influxdb2","middleware","pytest"],"created_at":"2025-10-10T07:57:36.513Z","updated_at":"2025-10-10T07:57:40.473Z","avatar_url":"https://github.com/straightchlorine.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async-httpd-data-collector\n\nInterface handling the communication between sensory data-emitting devices, InfluxDB and the user.\n\nThe most important object that a user would use is `DatabseInterface` within `ahttpdc.reads.interface` module.\nThis class facilitates the communication between the fetcher and the querying apis of InfluxDB.\n\nIn order to control fetching, there are two methods:\n\n* `interface.daemon.enableg()`;\n* `interface.daemon.disable()`.\n\nThose methods control the thread within which fetching process is contained.\n\nYou can query data from the database using methods with `query_` prefix. For now there are three:\n\n* `interface.query_latest()`, which queries the lastest measurement;\n* `interface.query_historical()`, which queries data from a given time range or relative time (eg. -3h);\n* `interface.query()`, which can takes user's given query as an argument.\n\nSome examples will be presented below:\n\n# 1.1 Connecting to the database\n\n\n```python\nimport json\nfrom ahttpdc.reads.interface import DatabaseInterface\n\n# load the secrets\nwith open('../../../secrets/secrets.json', 'r') as f:\n    secrets = json.load(f)\n\n# define sensors\nsensors = {\n    'bmp180': ['altitude', 'pressure', 'seaLevelPressure'],\n    'mq135': ['aceton', 'alcohol', 'co', 'co2', 'nh4', 'toulen'],\n    'ds18b20': ['temperature'],\n    'dht22': ['humidity'],\n}\n\n# define the interface to the database\ninterface = DatabaseInterface(\n    secrets['host'],\n    secrets['port'],\n    secrets['token'],\n    secrets['organization'],\n    secrets['bucket'],\n    sensors,\n    secrets['dev_ip'],\n    80,\n    secrets['handle'],\n)\n```\n\n### 1.2 Extracting the dataframe from the database\n\n\n```python\nimport pandas as pd\nimport asyncio\nfrom datetime import datetime, timedelta\nfrom pathlib import Path\n\n# if there is readings.csv file, load it\n# if not - create it\nreadings_path = Path('../data/readings.csv')\nif readings_path.is_file():\n    sensor = pd.read_csv(readings_path)\nelse:\n    sensor = await interface.query_historical('-30d')\n    sensor.to_csv(readings_path)\n```\n\n\n```python\nsensor\n```\n\n\n\n\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003etime\u003c/th\u003e\n      \u003cth\u003eaceton\u003c/th\u003e\n      \u003cth\u003ealcohol\u003c/th\u003e\n      \u003cth\u003ealtitude\u003c/th\u003e\n      \u003cth\u003eco\u003c/th\u003e\n      \u003cth\u003eco2\u003c/th\u003e\n      \u003cth\u003ehumidity\u003c/th\u003e\n      \u003cth\u003enh4\u003c/th\u003e\n      \u003cth\u003epressure\u003c/th\u003e\n      \u003cth\u003eseaLevelPressure\u003c/th\u003e\n      \u003cth\u003etemperature\u003c/th\u003e\n      \u003cth\u003etoulen\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e2024-05-16 17:43:59.196399+00:00\u003c/td\u003e\n      \u003ctd\u003e0.41\u003c/td\u003e\n      \u003ctd\u003e1.17\u003c/td\u003e\n      \u003ctd\u003e149.92\u003c/td\u003e\n      \u003ctd\u003e3.38\u003c/td\u003e\n      \u003ctd\u003e402.54\u003c/td\u003e\n      \u003ctd\u003e37.4\u003c/td\u003e\n      \u003ctd\u003e3.93\u003c/td\u003e\n      \u003ctd\u003e999.35\u003c/td\u003e\n      \u003ctd\u003e1017.31\u003c/td\u003e\n      \u003ctd\u003e24.40\u003c/td\u003e\n      \u003ctd\u003e0.48\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e2024-05-16 17:44:01.768738+00:00\u003c/td\u003e\n      \u003ctd\u003e0.47\u003c/td\u003e\n      \u003ctd\u003e1.32\u003c/td\u003e\n      \u003ctd\u003e149.76\u003c/td\u003e\n      \u003ctd\u003e3.94\u003c/td\u003e\n      \u003ctd\u003e402.84\u003c/td\u003e\n      \u003ctd\u003e30.5\u003c/td\u003e\n      \u003ctd\u003e4.33\u003c/td\u003e\n      \u003ctd\u003e997.61\u003c/td\u003e\n      \u003ctd\u003e1015.56\u003c/td\u003e\n      \u003ctd\u003e24.03\u003c/td\u003e\n      \u003ctd\u003e0.55\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003e2024-05-16 17:44:03.255309+00:00\u003c/td\u003e\n      \u003ctd\u003e0.96\u003c/td\u003e\n      \u003ctd\u003e2.62\u003c/td\u003e\n      \u003ctd\u003e149.54\u003c/td\u003e\n      \u003ctd\u003e9.16\u003c/td\u003e\n      \u003ctd\u003e405.25\u003c/td\u003e\n      \u003ctd\u003e49.1\u003c/td\u003e\n      \u003ctd\u003e7.35\u003c/td\u003e\n      \u003ctd\u003e999.14\u003c/td\u003e\n      \u003ctd\u003e1017.08\u003c/td\u003e\n      \u003ctd\u003e23.16\u003c/td\u003e\n      \u003ctd\u003e1.15\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003e2024-05-16 17:44:04.618203+00:00\u003c/td\u003e\n      \u003ctd\u003e0.30\u003c/td\u003e\n      \u003ctd\u003e0.86\u003c/td\u003e\n      \u003ctd\u003e149.38\u003c/td\u003e\n      \u003ctd\u003e2.32\u003c/td\u003e\n      \u003ctd\u003e401.94\u003c/td\u003e\n      \u003ctd\u003e32.9\u003c/td\u003e\n      \u003ctd\u003e3.10\u003c/td\u003e\n      \u003ctd\u003e999.09\u003c/td\u003e\n      \u003ctd\u003e1017.02\u003c/td\u003e\n      \u003ctd\u003e23.05\u003c/td\u003e\n      \u003ctd\u003e0.35\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003e2024-05-16 17:44:05.954714+00:00\u003c/td\u003e\n      \u003ctd\u003e1.31\u003c/td\u003e\n      \u003ctd\u003e3.50\u003c/td\u003e\n      \u003ctd\u003e149.37\u003c/td\u003e\n      \u003ctd\u003e13.13\u003c/td\u003e\n      \u003ctd\u003e406.82\u003c/td\u003e\n      \u003ctd\u003e48.8\u003c/td\u003e\n      \u003ctd\u003e9.21\u003c/td\u003e\n      \u003ctd\u003e998.04\u003c/td\u003e\n      \u003ctd\u003e1015.93\u003c/td\u003e\n      \u003ctd\u003e23.92\u003c/td\u003e\n      \u003ctd\u003e1.57\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e...\u003c/th\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e284122\u003c/th\u003e\n      \u003ctd\u003e2024-05-21 14:42:57.894312+00:00\u003c/td\u003e\n      \u003ctd\u003e1.35\u003c/td\u003e\n      \u003ctd\u003e3.62\u003c/td\u003e\n      \u003ctd\u003e150.08\u003c/td\u003e\n      \u003ctd\u003e13.68\u003c/td\u003e\n      \u003ctd\u003e407.03\u003c/td\u003e\n      \u003ctd\u003e47.6\u003c/td\u003e\n      \u003ctd\u003e9.46\u003c/td\u003e\n      \u003ctd\u003e998.85\u003c/td\u003e\n      \u003ctd\u003e1016.81\u003c/td\u003e\n      \u003ctd\u003e24.35\u003c/td\u003e\n      \u003ctd\u003e1.63\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e284123\u003c/th\u003e\n      \u003ctd\u003e2024-05-21 14:42:59.277937+00:00\u003c/td\u003e\n      \u003ctd\u003e1.08\u003c/td\u003e\n      \u003ctd\u003e2.92\u003c/td\u003e\n      \u003ctd\u003e149.87\u003c/td\u003e\n      \u003ctd\u003e10.48\u003c/td\u003e\n      \u003ctd\u003e405.79\u003c/td\u003e\n      \u003ctd\u003e49.3\u003c/td\u003e\n      \u003ctd\u003e8.00\u003c/td\u003e\n      \u003ctd\u003e998.58\u003c/td\u003e\n      \u003ctd\u003e1016.53\u003c/td\u003e\n      \u003ctd\u003e23.41\u003c/td\u003e\n      \u003ctd\u003e1.29\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e284124\u003c/th\u003e\n      \u003ctd\u003e2024-05-21 14:43:00.594968+00:00\u003c/td\u003e\n      \u003ctd\u003e0.38\u003c/td\u003e\n      \u003ctd\u003e1.09\u003c/td\u003e\n      \u003ctd\u003e149.97\u003c/td\u003e\n      \u003ctd\u003e3.09\u003c/td\u003e\n      \u003ctd\u003e402.38\u003c/td\u003e\n      \u003ctd\u003e33.8\u003c/td\u003e\n      \u003ctd\u003e3.71\u003c/td\u003e\n      \u003ctd\u003e999.59\u003c/td\u003e\n      \u003ctd\u003e1017.54\u003c/td\u003e\n      \u003ctd\u003e24.88\u003c/td\u003e\n      \u003ctd\u003e0.44\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e284125\u003c/th\u003e\n      \u003ctd\u003e2024-05-21 14:43:01.918239+00:00\u003c/td\u003e\n      \u003ctd\u003e1.41\u003c/td\u003e\n      \u003ctd\u003e3.77\u003c/td\u003e\n      \u003ctd\u003e150.13\u003c/td\u003e\n      \u003ctd\u003e14.38\u003c/td\u003e\n      \u003ctd\u003e407.29\u003c/td\u003e\n      \u003ctd\u003e44.4\u003c/td\u003e\n      \u003ctd\u003e9.76\u003c/td\u003e\n      \u003ctd\u003e998.51\u003c/td\u003e\n      \u003ctd\u003e1016.48\u003c/td\u003e\n      \u003ctd\u003e23.54\u003c/td\u003e\n      \u003ctd\u003e1.70\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e284126\u003c/th\u003e\n      \u003ctd\u003e2024-05-21 14:43:03.248095+00:00\u003c/td\u003e\n      \u003ctd\u003e1.24\u003c/td\u003e\n      \u003ctd\u003e3.32\u003c/td\u003e\n      \u003ctd\u003e150.50\u003c/td\u003e\n      \u003ctd\u003e12.29\u003c/td\u003e\n      \u003ctd\u003e406.50\u003c/td\u003e\n      \u003ctd\u003e48.8\u003c/td\u003e\n      \u003ctd\u003e8.84\u003c/td\u003e\n      \u003ctd\u003e998.85\u003c/td\u003e\n      \u003ctd\u003e1016.85\u003c/td\u003e\n      \u003ctd\u003e22.44\u003c/td\u003e\n      \u003ctd\u003e1.49\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003e284127 rows × 12 columns\u003c/p\u003e\n\u003c/div\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraightchlorine%2Fasync-httpd-data-collector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstraightchlorine%2Fasync-httpd-data-collector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraightchlorine%2Fasync-httpd-data-collector/lists"}