From 2b692c17ab0b9656ba0db739cb7462c54258c963 Mon Sep 17 00:00:00 2001 From: Cam Soper Date: Fri, 8 Oct 2021 11:27:09 -0500 Subject: [PATCH] Added ability to disable camera ping loop --- README.md | 1 + src/amcrest2mqtt.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 69195f9..dd72d97 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ It supports the following environment variables: - `AMCREST_PORT` (optional, default = 80) - `AMCREST_USERNAME` (optional, default = admin) - `AMCREST_PASSWORD` (required) +- `CAMERA_PING_ENABLED` (optional, default = `true`) - `MQTT_USERNAME` (required) - `MQTT_PASSWORD` (optional, default = empty password) - `MQTT_HOST` (optional, default = 'localhost') diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 200f099..c5b8e6e 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -18,6 +18,7 @@ amcrest_port = int(os.getenv("AMCREST_PORT") or 80) amcrest_username = os.getenv("AMCREST_USERNAME") or "admin" amcrest_password = os.getenv("AMCREST_PASSWORD") storage_poll_interval = int(os.getenv("STORAGE_POLL_INTERVAL") or 3600) +camera_ping_enabled = os.getenv("CAMERA_PING_ENABLED") == "true" mqtt_host = os.getenv("MQTT_HOST") or "localhost" mqtt_qos = int(os.getenv("MQTT_QOS") or 0) @@ -330,7 +331,11 @@ mqtt_publish(topics["config"], { if storage_poll_interval > 0: refresh_storage_sensors() -ping_camera() +if camera_ping_enabled: + log("Setting up camera ping...") + ping_camera() +else: + log("Skipping camera ping...") log("Listening for events...")