Skip to main content

garagedoor-service

This project implements a simple webservice that can be used to open/close a garagedoor with a typical Chamerlain or equivalent motor. It relies on a Raspberry Pi's GPIO pins to drive a (solid-state) relay to short-cirquit the motor terminals that initiate motion. Additionally, two pins are used to detect the garage door being fully opened or closed.

Configuration

The service is configured in config.yaml in the working directory. This path can be overwritten with the GARAGEDOOR_SERVICE_CONFIG environment variable.

Note that all fields in config.yaml are mandatatory and should contain some sane value.

Operation mode

By setting mode to development, the GPIO interface will not be used and the state will only be printed to stdout.

mode: development

Set this variable to production if you want to drive the actual GPIO pins. Note, this will require that the code is run on a Rasberry Pi or analog.

Bind address and port

Define to which host and port uvicorn should bind.

bind:
  port: 8000
  host: 127.0.0.1

GPIO

This section defines the GPIO pins used for toggling the motor relay, and reading the sensors for the door's position.

gpio:
  toggle_pin: 11
  open_pin: 21
  closed_pin: 22

The numers should match the labeling on the board's GPIO spec. Not the numbers defined by the chipset (which is prone to change between different versions of RPis).

API Keys

Defines a list of API keys that should have access to this service. API keys should be hashed with bcrypt.

api_keys:
  - $2y$10$3lHF35DW58Cse5gtU9DBMukIcUkQNNclSk3SDLArd4g2/8xC12Qb2

Routes

The following routes are available:

  • POST /toggle

    {
      "result": "ok"
    }
    

    Toggle the door motor. This call requires a valid api-key that should be specified in the x-api-key header.

  • GET /state

    {
      "result": "ok",
      "state": "closed"
    }
    

    Get the door's state. This can either be open, closed or unknown. This call requires a valid api-key that should be specified in the x-api-key header.

  • GET /healthz GET /readyz

    {
      "result": "ok"
    }
    

    Basic health and readiness checks. These require no authentication.

Running

Run this service with the following command.

garagedoor-service

Metadata

Release files for garagedoor_service 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for garagedoor_service 0.1.0
File Size Uploaded Provenance
garagedoor_service-0.1.0.tar.gz 8.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for garagedoor_service 0.1.0
File Interpreter ABI Platform
garagedoor_service-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / garagedoor_service-0.1.0.tar.gz

Download URL garagedoor_service-0.1.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
88560be3df7e08190a21c006dbc0b24be28ec4c54d7327ba347f724d9afb3d4c
BLAKE2b-256 checksum
How to use checksums
120b5ef90d8bffdfeab2125124093c9d399e1205b98b93108a4939d07750179e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.19.1 CPython/3.12.6 Linux/6.10.4-linuxkit

Release files / garagedoor_service-0.1.0-py3-none-any.whl

Download URL garagedoor_service-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45fbfce7723322e091bde55735235cfa06a141edec1f48444d6148c387a59eae
BLAKE2b-256 checksum
How to use checksums
fffd6d397e24d609e69c9aaf42947c3476252433455ce0425921c33c3e9680e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.19.1 CPython/3.12.6 Linux/6.10.4-linuxkit

Security for garagedoor_service 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page