1
0
mirror of synced 2026-03-09 20:13:40 +00:00

Compare commits

5 Commits

Author SHA1 Message Date
Daniel Chesterton
cbb1995deb Merge pull request #42 from dchesterton/dependabot/pip/amcrest-1.9.3
Bump amcrest from 1.8.0 to 1.9.3
2021-10-26 21:06:20 +01:00
dependabot[bot]
8a1b1945ff Bump amcrest from 1.8.0 to 1.9.3
Bumps [amcrest](https://github.com/tchellomello/python-amcrest) from 1.8.0 to 1.9.3.
- [Release notes](https://github.com/tchellomello/python-amcrest/releases)
- [Commits](https://github.com/tchellomello/python-amcrest/compare/1.8.0...1.9.3)

---
updated-dependencies:
- dependency-name: amcrest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-20 12:03:25 +00:00
bump_version
7bbe3cbcf4 Version 1.0.9 [skip ci] 2021-08-07 20:26:29 +00:00
Daniel Chesterton
8e96fc5408 Add ping functionality to stop app hanging 2021-08-07 21:26:07 +01:00
bump_version
0f8858cef4 Version 1.0.8 [skip ci] 2021-08-03 17:10:40 +00:00
3 changed files with 27 additions and 11 deletions

View File

@@ -1 +1 @@
1.0.7
1.0.9

View File

@@ -1,3 +1,3 @@
amcrest==1.8.0
amcrest==1.9.3
paho-mqtt==1.5.1
python-slugify==5.0.2

View File

@@ -73,6 +73,8 @@ def on_mqtt_disconnect(client, userdata, rc):
def exit_gracefully(rc, skip_mqtt=False):
global topics, mqtt_client
log("Exiting app...")
if mqtt_client is not None and mqtt_client.is_connected() and skip_mqtt == False:
mqtt_publish(topics["status"], "offline", exit_on_error=False)
mqtt_client.loop_stop(force=True)
@@ -96,6 +98,14 @@ def refresh_storage_sensors():
except AmcrestError as error:
log(f"Error fetching storage information {error}", level="WARNING")
def ping_camera():
Timer(30, ping_camera).start()
response = os.system(f"ping -c1 -W100 {amcrest_host} >/dev/null 2>&1")
if response != 0:
log("Ping unsuccessful", level="ERROR")
exit_gracefully(1)
def signal_handler(sig, frame):
# exit immediately upon receiving a second SIGINT
global is_exiting
@@ -134,14 +144,18 @@ camera = AmcrestCamera(
# Fetch camera details
log("Fetching camera details...")
device_type = camera.device_type.replace("type=", "").strip()
is_ad110 = device_type == "AD110"
is_ad410 = device_type == "AD410"
is_doorbell = is_ad110 or is_ad410
serial_number = camera.serial_number.strip()
sw_version = camera.software_information[0].replace("version=", "").strip()
device_name = camera.machine_name.replace("name=", "").strip()
device_slug = slugify(device_name, separator="_")
try:
device_type = camera.device_type.replace("type=", "").strip()
is_ad110 = device_type == "AD110"
is_ad410 = device_type == "AD410"
is_doorbell = is_ad110 or is_ad410
serial_number = camera.serial_number.strip()
sw_version = camera.software_information[0].replace("version=", "").strip()
device_name = camera.machine_name.replace("name=", "").strip()
device_slug = slugify(device_name, separator="_")
except AmcrestError as error:
log(f"Error fetching camera details", level="ERROR")
exit_gracefully(1)
log(f"Device type: {device_type}")
log(f"Serial number: {serial_number}")
@@ -316,10 +330,12 @@ mqtt_publish(topics["config"], {
if storage_poll_interval > 0:
refresh_storage_sensors()
ping_camera()
log("Listening for events...")
try:
for code, payload in camera.event_actions("All", retries=5):
for code, payload in camera.event_actions("All", retries=5, timeout_cmd=(10.00, 3600)):
if (is_ad110 and code == "ProfileAlarmTransmit") or (code == "VideoMotion" and not is_ad110):
motion_payload = "on" if payload["action"] == "Start" else "off"
mqtt_publish(topics["motion"], motion_payload)