{"id":13658022,"url":"https://github.com/raviles/rpi_automator","last_synced_at":"2025-04-24T08:31:01.758Z","repository":{"id":57462829,"uuid":"158667825","full_name":"raviles/rpi_automator","owner":"raviles","description":"Raspberry Pi Automation Tool","archived":false,"fork":false,"pushed_at":"2022-12-26T22:42:37.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T22:35:23.590Z","etag":null,"topics":["automation","python","raspberry-pi"],"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/raviles.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}},"created_at":"2018-11-22T08:39:40.000Z","updated_at":"2022-12-26T22:42:33.000Z","dependencies_parsed_at":"2023-01-31T02:01:02.516Z","dependency_job_id":null,"html_url":"https://github.com/raviles/rpi_automator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raviles%2Frpi_automator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raviles%2Frpi_automator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raviles%2Frpi_automator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raviles%2Frpi_automator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raviles","download_url":"https://codeload.github.com/raviles/rpi_automator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250591939,"owners_count":21455467,"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":["automation","python","raspberry-pi"],"created_at":"2024-08-02T05:00:55.190Z","updated_at":"2025-04-24T08:30:59.073Z","avatar_url":"https://github.com/raviles.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"## Raspberry Pi Automator\n\nAn extendable, event-driven automation tool for Raspberry Pi GPIO components.  \n\nThe automator provides a built-in cron facility (via `apscheduler`) and a chainable component model.\n\n##### Installation\n```commandline\npip install rpi_automator\n```\n\n##### Running\n```commandline\nrpi_automator --config /\u003cpath to your config.json\u003e\n```\nWill block until SIGTERM is received.\n\n## Usage\nThe automator can be run in two different ways:\n\n**1) Using code**\n\n```python\ncam = PICamera(name='backyard_cam', width=640, height=480, cron=\"*/15 5-17 * * *\")\ns3 = S3Uploader(bucket_name='my-house-images', base_url='http://d1w07f3h9z0.cloudfront.net')\n\ncam.then(s3)\n\nbutton = ButtonDetector(name='red_button', pin=4)\nlight_relay = RelaySwitch(name='backyard_light', pin=8)\n\nlight_relay.then(cam)\nbutton.then(light_relay)\n\nBaseModule.start()\n```\n\nThe above code will do the following:\n\u003e Take a photo and upload to an S3 bucket every 15 minutes from 5am to 5pm each day.\n\n\u003e If the red button is pushed, turn on the light and then take a photo.\n\n    \nA `DataStore` implementation can be optionally set to send each module result to a backend storage.  New data stores can be \n    created by sub-classing `DataStore`.\n    \n```python\nBaseModule.datastore = DynamoDBDataStore(table='house_data')\n```\n\nSee [rpi_automator_web](https://github.com/raviles/rpi_automator_web) for DynamoDB setup and data visualizer.\n\n**2) Using a configuration file**\n\n```javascript\n{\n  \"datastore\" : \"DynamoDBDataStore\",\n\n  \"modules\" : [\n    {\n      \"type\" : \"modules/PICamera\",\n      \"name\" : \"piCam1\",\n      \"cron\" : \"*/15 * * * *\",\n      \"enabled\" : true\n    },\n    {\n      \"type\" : \"modules/S3Uploader\",\n      \"bucket_name\" : \"my-cam-images\",\n      \"name\" : \"s3\",\n      \"subscribed_to\" : [\"piCam1\"],\n      \"enabled\" : true\n    },\n    {\n      \"type\" : \"modules/TempHumiditySensor\",\n      \"name\" : \"temp1\",\n      \"use_fahrenheit\" : true,\n      \"cron\" : \"*/1 * * * *\",\n      \"enabled\" : true\n    },\n    {\n      \"type\" : \"modules/RelaySwitch\",\n      \"name\" : \"light\",\n      \"cron\" : \"0 7 * * *\",\n      \"duration\": 43200,\n      \"pin\" : 18,\n      \"value\" : 1,\n      \"enabled\" : true\n    },\n    {\n      \"type\" : \"ButtonDetector\",\n      \"name\" : \"wateringButton1\",\n      \"enabled\" : true,\n      \"pin\" : 28\n    },\n    {\n      \"type\" : \"RelaySwitch\",\n      \"name\" : \"waterPump1\",\n      \"duration\": 10,\n      \"pin\" : 20,\n      \"value\" : true,\n      \"value_toggle\" : false,\n      \"subscribed_to\" : [\"wateringButton1\"],\n      \"enabled\" : true\n    }\n  ]\n}\n```\n    \nThe configuration file above will automate the following actions:\n\n\u003eEvery 15 minutes, take a photo using the attached camera module and upload to S3.\n\n\u003eEvery minute, read from a DHT22 temperature \u0026 humidity sensor.\n\n\u003eAt 7am each day, enable the attached relay power switch (via pin 18) to turn on a light for 12 hours.\n\n\u003eRun the attached water pump (waterPump1) for 10 seconds when the watering button (wateringButton1) is pressed.\n\nIn each case, result data will be sent to DynamoDB\n\nRun via:\n    \n```commandline\nrpi_automator --config /\u003cpath to your config.json\u003e\n```\n\n## Available Modules\n\n- [PICamera](rpi_automator/modules/PICamera.py): V2 Raspberry PI camera module\n- [ButtonDetector](rpi_automator/modules/ButtonDetector.py): Basic push button\n- [CV2Camera](rpi_automator/modules/CV2Camera.py): USB-based web cam\n- [RelaySwitch](rpi_automator/modules/RelaySwitch.py): Relay switch controlling power to a connected device\n- [TempHumiditySensor](rpi_automator/modules/TempHumiditySensor.py): Reads data from a DHT22 temperature/humidity sensor\n- [VeSyncOutlet](rpi_automator/modules/VeSyncOutlet.py): Controls [Etekcity/VeSync](https://smile.amazon.com/Etekcity-Voltson-Outlet-Monitoring-Required/dp/B074GVPYPY) smart outlets\n- [S3Uploader](rpi_automator/modules/S3Uploader.py): Modules that generate files can return LocalFileData and get \nuploaded to an S3 bucket\n\nMultiple instances of each module can be configured for different purposes e.g. several instances of `RelaySwitch`\nfor different lights, each operating on their own GPIO pin.\n\n## Custom Modules\nCreate new modules by sub-classing [`modules.BaseModule`](rpi_automator/modules/BaseModule.py). The directory\ncontaining the source code should be added to $PYTHONPATH (or `sys.path`).\n\nCustom datastores can also be created by subclassing [`datastores.DataStore`](rpi_automator.datastores.DataStore.py).\n\n## Running Tests\n\n```commandline\ncd rpi_automator\nexport PYTHONPATH=.\npython -m unittest tests.EventControllerTests.EventControllerTests\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraviles%2Frpi_automator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraviles%2Frpi_automator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraviles%2Frpi_automator/lists"}