From 2bf406d7c98a154d54efa20bee4cb7627684c439 Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Tue, 9 Feb 2021 10:13:50 +0000 Subject: [PATCH] Support AD410 doorbell --- README.md | 4 ++-- src/amcrest2mqtt.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6d94493..7b2d3d7 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ It supports the following environment variables: - `HOME_ASSISTANT` (optional, default = false) - `HOME_ASSISTANT_PREFIX` (optional, default = 'homeassistant') -It exposes events to the `amcrest2mqtt/[SERIAL_NUMBER]/event` MQTT topic. If the device is an AD110 doorbell it will expose the -doorbell status to `amcrest2mqtt/[SERIAL_NUMBER]/doorbell`. If the device supports motion events it will expose motion events +It exposes events to the `amcrest2mqtt/[SERIAL_NUMBER]/event` MQTT topic. If the device is an AD110 or AD410 doorbell it will expose +the doorbell status to `amcrest2mqtt/[SERIAL_NUMBER]/doorbell`. If the device supports motion events it will expose motion events to `amcrest2mqtt/[SERIAL_NUMBER]/motion`. ## Device Support diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index ded7208..3dd55da 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -138,7 +138,7 @@ if home_assistant: log("Writing Home Assistant discovery config...") - if device_type == "AD110": + if device_type in ["AD110", "AD410"]: mqtt_publish(doorbell_home_assistant_topic, json.dumps({ "availability_topic": status_topic, "state_topic": doorbell_topic, @@ -164,17 +164,15 @@ log("Listening for events...") try: for code, payload in camera.event_actions("All", retries=5): - log(str(payload)) - if code == "ProfileAlarmTransmit": mqtt_payload = "on" if payload["action"] == "Start" else "off" mqtt_publish(motion_topic, mqtt_payload) - - if code == "_DoTalkAction_": + elif code == "_DoTalkAction_": mqtt_payload = "on" if payload["data"]["Action"] == "Invite" else "off" mqtt_publish(doorbell_topic, mqtt_payload) mqtt_publish(event_topic, json.dumps(payload)) + log(str(payload)) except AmcrestError as error: log(f"Amcrest error {error}", level="ERROR")