I bought an ezviz DB1 camera a while ago, expecting to be able to set it up to play a notification on my Google Home mini when someone pressed the doorbell but it looks like the only way to get any notification is through ezviz's own app. The problem is that notification takes 30 seconds or more to appear (if it works at all). The doorbell has other names like HikVision and LaCie, but I couldn't find any information about getting any of the devices to just GET a URL on the local network whenever the doorbell button was pressed.
What they do do though is a DNS lookup for alarmeu.ezvizlife.com or ali-alarm-eu.oss-eu-central-1.aliyuncs.com alarm.eu.s3.amazonaws.com when sending the event to the cloud servers. This DNS lookup happens as soon as the button is pressed, and since I am running my own caching name server I can see that DNS query in the logs. This means I can run a script which will watch the logs for the alarm address query and then I know when the button has been pressed.

This method would work for any doorbell camera which makes predictable DNS lookups.

For now I will just send an email to myself when it gets pressed. The script pipes the log to read and then uses bash string compare to check each line for either DNS query. If the hostname is found then the next bit of the code to send the email will be run. I also added a maximum frequency in there so that the email will only be sent if none had been sent in the last 30 seconds.

Update: alarmeu.ezvizlife.com seems to be used for PIR notifications, and alarm.eu.s3.amazonaws.com for door bell presses. So it would be possible to determine the action using the hostname

Update 2: It looks like the hostname for doorbell button presses is now ali-alarm-eu.oss-eu-central-1.aliyuncs.com instead of alarm.eu.s3.amazonaws.com, but that could change again at any time

#!/bin/bash
FREQ=30         # max every 30 secs
LASTSENT=0
tail -fn0 /var/log/named/queries.log | while read; do   
        if [[ "$REPLY" =~ .*"ali-alarm-eu.oss-eu-central-1.aliyuncs.com"|"alarm.eu.s3.amazonaws.com".* ]]; then
                NOW=$(date +%s)
                if [ $NOW -gt $((LASTSENT+FREQ)) ]; then
                        echo "BUTTON PRESSED" | mail -s "Doorbell pressed" adam
                        LASTSENT=$NOW
                else
                        echo "Button pressed, but not sending mail"
                fi
        fi
done

I get this email notification on my phone after 1 or 2 seconds, much faster than the 30 seconds of waiting for the ezviz app.

Previous Post Next Post