#!/usr/bin/env python3 """ Doorbell PTT server for Pi Zero W. Serves a single-page web app that: * shows the Frigate WebRTC live feed (video + camera mic if present) * provides a push-to-talk button that streams phone mic audio over a WebSocket; this script decodes and plays it out ALSA. Deployment: * listens on 127.0.0.1:5555; expose publicly via Caddy reverse proxy * runs under systemd as the 'pi' user * requires: python3-flask, flask-sock, ffmpeg, alsa-utils """ import subprocess from flask import Flask, render_template_string from flask_sock import Sock app = Flask(__name__) sock = Sock(app) # Camera this Pi corresponds to. Must match a go2rtc stream name in # frigate_config/config.yml. The PTT button talks to the speaker physically # attached to this Pi, so this should be the camera at the same location. CAMERA_NAME = "front_door" # Optional jump-links to sibling doorbell Pis (each running its own copy of # this app, hardcoded to its own camera). Rendered as a row of buttons above # the PTT button when non-empty. Leave empty if there are no other Pis. PEER_LINKS = [ # {"label": "Back door", "url": "https://backdoor.yourdomain.com"}, ] PAGE = """