KPRSpaceAPI/README.md
2025-10-19 23:02:59 -06:00

1.1 KiB

KPRSpaceAPI

Implementation of the Space API used in KPR, based on a simple webcam running through Motion which detects whether the light is turned on and updates the status of the space accordingly.

Run (fish shell)

Create and activate a virtual environment, install dependencies and run the server (example using fish):

python3 -m venv venv
source venv/bin/activate.fish
pip install -r requirements.txt

# Configure environment (examples)
set -x SNAPSHOT_INTERVAL 600           # seconds (600 = 10 minutes)
set -x BRIGHTNESS_THRESHOLD 100        # 0-255
set -x AUTO_START false                # true to auto-start on process launch

# Run the app
python app.py

Notes

  • Screenshots are saved to ./screenshots by default. Override with MOTION_DIR.
  • To start/stop the monitor at runtime:
    • Start: curl -X POST http://localhost:5000/api/start
    • Stop: curl -X POST http://localhost:5000/api/stop
  • The SNAPSHOT_INTERVAL env var is interpreted in seconds.
  • If you want the server to auto-start the monitor on launch, set AUTO_START=true before launching.
  • For production use, run under a WSGI server (gunicorn, systemd unit, docker, etc.).