diff --git a/pi/README.md b/pi/README.md index 4e959cd..902a520 100644 --- a/pi/README.md +++ b/pi/README.md @@ -52,13 +52,19 @@ sudo journalctl -u doorbell -f # live logs Add to home screen (Chrome menu -> Add to home screen) for an app-like experience. -## Changing the camera +## Choosing the camera -`server.py` near the top: -```js -const CAMERA_NAME = "front_door"; +`server.py` near the top has the list of cameras the page offers: +```python +CAMERAS = ["front_door"] ``` +Each name must match a `go2rtc.streams` entry in +`frigate_config/config.yml` and the camera must be `enabled: true` in +Frigate. With more than one entry the page shows a dropdown above the +talk button; the choice is remembered per-browser in `localStorage`. The +first entry is the default for new visitors. + After editing: ```bash sudo systemctl restart doorbell diff --git a/pi/server.py b/pi/server.py index 5fd342b..857dd37 100644 --- a/pi/server.py +++ b/pi/server.py @@ -20,6 +20,11 @@ from flask_sock import Sock app = Flask(__name__) sock = Sock(app) +# Cameras to offer in the page's dropdown. First entry is the default. +# Names must match go2rtc stream names in frigate_config/config.yml and +# the corresponding camera must be enabled in Frigate. +CAMERAS = ["front_door"] + PAGE = """ @@ -46,6 +51,9 @@ PAGE = """ .row{display:flex;gap:8px} .row button{flex:1;padding:10px;background:#333;color:#fff;border:none; border-radius:8px;font-size:13px} + .row select{flex:1;padding:10px;background:#333;color:#fff;border:none; + border-radius:8px;font-size:14px;appearance:none;-webkit-appearance:none; + text-align:center;text-align-last:center} #status{font-size:12px;color:#888;text-align:center;min-height:1em} @@ -55,6 +63,9 @@ PAGE = """
+
@@ -67,21 +78,43 @@ PAGE = """ @@ -192,7 +226,7 @@ setupPTT(); @app.route('/') def index(): - return render_template_string(PAGE) + return render_template_string(PAGE, cameras=CAMERAS) @app.route('/healthz')