Getting Ezviz DB1 (or Hikision or LaCie) doorbell presses

Ok, this is most probably the most ridiculous and cumbersome way to overcome a problem that could be mitigated by a munfacturer easily, but until someone improves the firmware of the Ezviz DB1 the Home Automation enthusiasts will be stuck without the ability to use de keypress in a simpler way.

The story: the Ezviz DB1 does offer ONVIF (if flashed with the Hikvision firmware LINK) and the Onvif integration does allow you to use motion alerts, but somehow someone forgot to add a simple “doorbell press” to it.

First I tried to circumvent this issue by adding a relay, but failed (the relay didn’t respond and I didn’t bother to further investigate). After some reading it became clear that the Hikvision doorbell connects to a webserver ( every time it’s button was pressed.

As I am running Pihole I could find these DNS queries in my logs which led me to the idea of using that in homeassistant. I therefore created the following script that continuously runs through the pihole log to see if there are any DNS queries to that server and if so; flip the switch of my doorbell in Homeassistant. This script runs in a cron at reboot.

The script:

#! /bin/bash
tail -fn0 /PATHTOTHEPIHOLELOG/pihole.log|while read;do echo "$REPLY"|grep -q "" && curl -X POST -H "Authorization: Bearer LONGLIVEDACCESSTOKENFROMHOMEASSISTANT" -H "Content-Type: application/json" -d '{"entity_id": "switch.THENAMEOFYOURDOORBELLINHOMEASSISTANT"}' http://HOMEASSISTANTIP:8123/api/services/switch/turn_on;done

Maybe others can benefit from the above :smiley:


Nice find! I am trying to set it up just as you described but I am wondering what kind of switch you have added? Just a dummy switch?

You can leverage a dummy switch for it. I use an old 433Mhz which was still in Homeassistant to set the state manually.

The strange thing is that this hacky setup is still working flawlessly…

Sometimes the strangest hacks work the best. :slight_smile:

What happens after a while with your switch? Do you reset it back to off with an automation after some period, allowing it to be triggered again?

I reset it automatically. Find the full automation below:

- id: '1538109173790'
  alias: Deurbel notify
  - entity_id: switch.deurbel
    platform: state
    to: 'on'
  condition: []
  - data:
      entity_id: media_player.homef
      language: nl
      message: Er staat iemand voor de deur
    service: tts.google_say
  - service: script.send_doorbell_photo_via_telegram
    data: {}
  - data: {}
    entity_id: switch.deurbel
    service: switch.turn_off
  mode: single
1 Like

Thanks alot for your automation. I will try it with an input boolean instead, which I can create through the Helpers section in HomeAssistant.

It also works with an input boolean and a little modification to your command. I even created a second way to update the input boolean using the RESTapi.

Your version, modified for an input boolean:

#! /bin/bash
tail -fn0 /PATHTOTHEPIHOLELOG/pihole.log|while read;do echo "$REPLY"|grep -q "" && curl -X POST -H "Authorization: Bearer LONGLIVEDACCESSTOKENFROMHOMEASSISTANT" -H "Content-Type: application/json" -d '{"entity_id": "input_boolean.THENAMEOFTHEHELPERINPUTBOOLEAN"}' http://HOMEASSISTANTIP:8123/api/services/input_boolean/turn_on;done

Another variant, not calling the service to “turn on”, but change the “state” of the input boolean:

#! /bin/bash
tail -fn0 /PATHTOTHEPIHOLELOG/pihole.log|while read;do echo "$REPLY"|grep -q "" && curl -X POST -H "Authorization: Bearer LONGLIVEDACCESSTOKENFROMHOMEASSISTANT" -H "Content-Type: application/json" -d '{"state": "on"}' http://HOMEASSISTANTIP:8123/api/states/input_boolean.THENAMEOFTHEHELPERINPUTBOOLEAN;done

Both give the same quick response. I like it. :slight_smile:

Ok, the script works if I run it manually, but I cannot get it to work on the background on my dockerized pihole. How did you setup the script to run at reboot?

I tried to create a file calling the script in /etc/cron.d/, tried to add a reference to the script through crontab -e, but all without success. :frowning:

I run it in Cron at the host. This does mean that it is best to store the pihole log somewhere in the filesystem of the host. This was for me, as relative Docker noob, the biggest challenge to figure out.

Docker noob here also, so your hint helped me again. I have set it up like you did: store the log local on my Ubuntu machine instead of in the docker container, and make the script run on the Ubuntu host. This works directly.

Thanks for the post - I am trying to use the same DNS query trigger and have it working with a binary_sensor that Alexa can sense, but I cannot figure out how to reset the state to OFF after doorbell press. This seems so silly that I cannot believe there is not an easy solution. Am I missing something?? I tried working with an input_boolean and was hopeful with that, but Alexa does not work with that as a trigger for a routine (which is what I am after). I have tried off_delay but that does not seem to work for me. Any help or suggestions would be greatly appreciated!

To reply to myself, I think I figured it out with the following:

  - trigger:                                      
      - platform: webhook
        webhook_id: doorbell_dns
      - name: "Doorbell_dns"
        state: "{{ trigger.json.pressed }}"
        device_class: motion                                                         
        auto_off: 1                

and a script running on my router with DNS logging enabled:

#! /bin/sh

tail -fn0 /var/log/messages | while read;do echo "$REPLY" | grep -q "" &&
curl -k --header "Content-Type: application/json" \
  --request POST \
  --data '{"pressed": true}' \
  https://homeassistant:8123/api/webhook/doorbell_dns ; done

I’m using Adguard integration in HA. I can see the DNS rule but i don’t have any option to use it in any automation.

There isn’t an option in Adguard or Pihole. That’s why, if you look at my mentioned script, I constantly monitor the log of pihole and trigger based on that.

Thanks for this script. Can you share your camera config (the bell) and ONVIF I added mine to HA but is laggy). In hikvison app its not laggy.

I added my doorbell to Motioneye and then use the “stream” function of Motioneye to further do the cool stuff in homeassistant. Camera is added via rtsp URL as: rtsp://

Are you also using homekit? I added the camera directly to ha via the rstp url you pasted. But in homekit it takes ages to load the camera. But in HA its fast.

I don’t use homekit. Just to check: you did change the IP address of the camera didn’t you? Chances are next to none you have it running on the same IP as I am running it…

Of course I changed the ip, and as I said it works in homeassiant gui.

It is quite common for a stream to take some time to start. What you can do is keep the stream alive. This can be done with the preload stream setting. More on this can be found at: Camera - Home Assistant