From 594a42320f7f010688c6216c7bd2244950c08502 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Tue, 26 Oct 2021 21:38:19 +0100 Subject: [PATCH] Fix issue with fetching serial number (closes #35) --- src/amcrest2mqtt.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 200f099..5c6aad5 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -149,7 +149,12 @@ try: is_ad110 = device_type == "AD110" is_ad410 = device_type == "AD410" is_doorbell = is_ad110 or is_ad410 - serial_number = camera.serial_number.strip() + serial_number = camera.serial_number + + if not isinstance(serial_number, str): + log(f"Error fetching serial number", level="ERROR") + exit_gracefully(1) + sw_version = camera.software_information[0].replace("version=", "").strip() device_name = camera.machine_name.replace("name=", "").strip() device_slug = slugify(device_name, separator="_")