src.nth.io/

summaryrefslogtreecommitdiff
path: root/unifi-protect-viewport/files
diff options
context:
space:
mode:
Diffstat (limited to 'unifi-protect-viewport/files')
-rw-r--r--unifi-protect-viewport/files/unifi-protect-viewport-debug34
-rw-r--r--unifi-protect-viewport/files/unifi-protect-viewport.py30
2 files changed, 32 insertions, 32 deletions
diff --git a/unifi-protect-viewport/files/unifi-protect-viewport-debug b/unifi-protect-viewport/files/unifi-protect-viewport-debug
index 1305c13..65f67b0 100644
--- a/unifi-protect-viewport/files/unifi-protect-viewport-debug
+++ b/unifi-protect-viewport/files/unifi-protect-viewport-debug
@@ -1,5 +1,5 @@
#!/bin/bash
-# doorbell-viewport-debug: CLI debug tool
+# unifi-protect-viewport-debug: CLI debug tool
#
# Commands:
# show Turn display on
@@ -11,7 +11,7 @@
set -e
-ENV_FILE="/etc/doorbell-viewport/doorbell-viewport.env"
+ENV_FILE="/etc/unifi-protect-viewport/unifi-protect-viewport.env"
CMD="${1:-help}"
_load_env() {
@@ -100,19 +100,19 @@ PYEOF
cmd_test_stream() {
_load_env
- if [ -z "$DOORBELL_VIEWPORT_PROTECT_HOST" ]; then
- echo "Error: DOORBELL_VIEWPORT_PROTECT_HOST not set" >&2
+ if [ -z "$UNIFI_PROTECT_VIEWPORT_PROTECT_HOST" ]; then
+ echo "Error: UNIFI_PROTECT_VIEWPORT_PROTECT_HOST not set" >&2
exit 1
fi
- echo "Fetching RTSP URL from $DOORBELL_VIEWPORT_PROTECT_HOST..."
+ echo "Fetching RTSP URL from $UNIFI_PROTECT_VIEWPORT_PROTECT_HOST..."
RTSP_URL=$(python3 - <<PYEOF
import os, sys, requests, urllib3
urllib3.disable_warnings()
-host = os.environ['DOORBELL_VIEWPORT_PROTECT_HOST']
-user = os.environ['DOORBELL_VIEWPORT_PROTECT_USERNAME']
-passwd = os.environ['DOORBELL_VIEWPORT_PROTECT_PASSWORD']
-camera_id = os.environ['DOORBELL_VIEWPORT_CAMERA_ID']
+host = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_HOST']
+user = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_USERNAME']
+passwd = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_PASSWORD']
+camera_id = os.environ['UNIFI_PROTECT_VIEWPORT_CAMERA_ID']
s = requests.Session()
s.verify = False
r = s.post(f'https://{host}/api/auth/login',
@@ -138,7 +138,7 @@ PYEOF
echo "(press q to quit)"
mpv \
--vo=drm \
- "--video-rotate=${DOORBELL_VIEWPORT_ORIENTATION:-270}" \
+ "--video-rotate=${UNIFI_PROTECT_VIEWPORT_ORIENTATION:-270}" \
--fullscreen \
--no-border \
--no-osc \
@@ -149,18 +149,18 @@ PYEOF
cmd_test_protect() {
_load_env
- if [ -z "$DOORBELL_VIEWPORT_PROTECT_HOST" ]; then
- echo "Error: DOORBELL_VIEWPORT_PROTECT_HOST not set" >&2
+ if [ -z "$UNIFI_PROTECT_VIEWPORT_PROTECT_HOST" ]; then
+ echo "Error: UNIFI_PROTECT_VIEWPORT_PROTECT_HOST not set" >&2
exit 1
fi
python3 - <<PYEOF
import os, requests, urllib3
urllib3.disable_warnings()
-host = os.environ['DOORBELL_VIEWPORT_PROTECT_HOST']
-user = os.environ['DOORBELL_VIEWPORT_PROTECT_USERNAME']
-passwd = os.environ['DOORBELL_VIEWPORT_PROTECT_PASSWORD']
-camera_id = os.environ['DOORBELL_VIEWPORT_CAMERA_ID']
+host = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_HOST']
+user = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_USERNAME']
+passwd = os.environ['UNIFI_PROTECT_VIEWPORT_PROTECT_PASSWORD']
+camera_id = os.environ['UNIFI_PROTECT_VIEWPORT_CAMERA_ID']
s = requests.Session()
s.verify = False
@@ -193,7 +193,7 @@ case "$CMD" in
test-stream) cmd_test_stream ;;
test-protect) cmd_test_protect ;;
help|*)
- echo "Usage: doorbell-viewport-debug <command>"
+ echo "Usage: unifi-protect-viewport-debug <command>"
echo ""
echo "Commands:"
echo " show Turn display on"
diff --git a/unifi-protect-viewport/files/unifi-protect-viewport.py b/unifi-protect-viewport/files/unifi-protect-viewport.py
index 455a3cd..f5283ae 100644
--- a/unifi-protect-viewport/files/unifi-protect-viewport.py
+++ b/unifi-protect-viewport/files/unifi-protect-viewport.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
-doorbell-viewport: UniFi Protect doorbell display daemon
+unifi-protect-viewport: UniFi Protect doorbell display daemon
Connects to UniFi Protect, listens for doorbell ring events, and manages
display power + video playback on a Raspberry Pi portrait touchscreen.
@@ -13,7 +13,7 @@ Transitions:
ring event : IDLE -> ACTIVE (or extend timer if already ACTIVE)
touch (idle) : IDLE -> ACTIVE
touch (active): ACTIVE -> IDLE (immediate)
- timeout : ACTIVE -> IDLE (after doorbell_viewport_timeout seconds)
+ timeout : ACTIVE -> IDLE (after unifi_protect_viewport_timeout seconds)
"""
import asyncio
@@ -46,7 +46,7 @@ logging.basicConfig(
format="%(asctime)s %(levelname)s %(message)s",
stream=sys.stdout,
)
-log = logging.getLogger("doorbell-viewport")
+log = logging.getLogger("unifi-protect-viewport")
class State(Enum):
@@ -56,16 +56,16 @@ class State(Enum):
class Config:
def __init__(self):
- self.protect_host = os.environ["DOORBELL_VIEWPORT_PROTECT_HOST"]
- self.protect_username = os.environ["DOORBELL_VIEWPORT_PROTECT_USERNAME"]
- self.protect_password = os.environ["DOORBELL_VIEWPORT_PROTECT_PASSWORD"]
- self.camera_id = os.environ["DOORBELL_VIEWPORT_CAMERA_ID"]
- self.timeout = int(os.environ.get("DOORBELL_VIEWPORT_TIMEOUT", "45"))
- self.touch_match = os.environ.get("DOORBELL_VIEWPORT_TOUCH_MATCH", "")
- self.orientation = int(os.environ.get("DOORBELL_VIEWPORT_ORIENTATION", "270"))
- self.drm_device = os.environ.get("DOORBELL_VIEWPORT_DRM_DEVICE", "/dev/dri/card1")
- self.drm_connector = os.environ.get("DOORBELL_VIEWPORT_DRM_CONNECTOR", "HDMI-A-1")
- self.drm_mode = os.environ.get("DOORBELL_VIEWPORT_DRM_MODE", "")
+ self.protect_host = os.environ["UNIFI_PROTECT_VIEWPORT_PROTECT_HOST"]
+ self.protect_username = os.environ["UNIFI_PROTECT_VIEWPORT_PROTECT_USERNAME"]
+ self.protect_password = os.environ["UNIFI_PROTECT_VIEWPORT_PROTECT_PASSWORD"]
+ self.camera_id = os.environ["UNIFI_PROTECT_VIEWPORT_CAMERA_ID"]
+ self.timeout = int(os.environ.get("UNIFI_PROTECT_VIEWPORT_TIMEOUT", "45"))
+ self.touch_match = os.environ.get("UNIFI_PROTECT_VIEWPORT_TOUCH_MATCH", "")
+ self.orientation = int(os.environ.get("UNIFI_PROTECT_VIEWPORT_ORIENTATION", "270"))
+ self.drm_device = os.environ.get("UNIFI_PROTECT_VIEWPORT_DRM_DEVICE", "/dev/dri/card1")
+ self.drm_connector = os.environ.get("UNIFI_PROTECT_VIEWPORT_DRM_CONNECTOR", "HDMI-A-1")
+ self.drm_mode = os.environ.get("UNIFI_PROTECT_VIEWPORT_DRM_MODE", "")
self.rtsp_url = None
def log_config(self):
@@ -231,7 +231,7 @@ class DoorbellViewport:
self._running = True
async def run(self):
- log.info("doorbell-viewport starting")
+ log.info("unifi-protect-viewport starting")
self.config.log_config()
self.display.off()
@@ -511,7 +511,7 @@ async def main():
log.info("Shutting down")
await viewport.stop_mpv()
viewport.display.off()
- log.info("doorbell-viewport stopped")
+ log.info("unifi-protect-viewport stopped")
if __name__ == "__main__":