Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible support for amcrest AD110 ? #137

Open
aaamoeder opened this issue Jan 8, 2020 · 147 comments
Open

possible support for amcrest AD110 ? #137

aaamoeder opened this issue Jan 8, 2020 · 147 comments

Comments

@aaamoeder
Copy link

just bought one of these and am now sad to see the doorbell isnt supported (I know I should have done better research..)
any way this might be supported in the future ?

@PrplHaz4
Copy link

PrplHaz4 commented Jan 9, 2020

It seems to share at least some of the API with other Amcrest cameras but is not onvif compliant. You may have better luck with specific functionality requests or maybe we can document what is not working...

@aaamoeder
Copy link
Author

So basically trying to integrate this boorbell into Home assistant (which is using this code)
--> https://www.home-assistant.io/integrations/amcrest/
But using that with my credentials is not working..

Just having the button push and perhaps motion detection would be AMAZING..

@digiblur
Copy link

@aaamoeder use the ID of admin and the device password you made during pairing.

@digiblur
Copy link

@tchellomello if you want I'd be glad to send you an Amcrest doorbell for you to keep and take a crack at to see what you can pull out of the configs/API on it. Let me know.

@aaamoeder
Copy link
Author

@aaamoeder use the ID of admin and the device password you made during pairing.

Tried that, but sadly it's not working.

@digiblur
Copy link

@aaamoeder I would definitely try to hit with VLC on the RTSP stream then to verify you don't have any networking or password issues as I do know that method works.

@aaamoeder
Copy link
Author

have it setup as a generic camera atm and that works fine.. weird,
will test more later.

@reesericci
Copy link

Apparently there's no API spec for the push button, get amcrest to add it!

@reesericci
Copy link

image
She said it, not me. Go here: https://amcrest.com/forum/feature-device-request-f31/?sid=b06b1727d00da763f3bd30fa95b20c57

@MYeager1967
Copy link

I could care less about the doorbell press at the moment. I'm trying to get a reliable motion event out of the doorbell. The HA integration is fairly broken at the moment and has been for a little while. I don't need the camera (picture) part of it, or anything else they're putting into it. I just want a reliable way to read the motion event...

@GaryOkie
Copy link

GaryOkie commented Aug 18, 2020

I have been using Tasker/SmartHome to trigger both doorbell button and motion events in HA reliably and quickly. But that should not at all be necessary. Since the @pnbruckner update to python-amcrest to subscribe to events rather than poll, motion events from the HA Amcrest integration are also reliable and instantaneous. Not broken at all for me. (Besides the fact that this doorbell produces far too many unwanted events uncharacteristic for a PIR sensor).

Apparently there's no API spec for the push button, get amcrest to add it!

Yes, there is (but undocumented) - I have a working Python script that detects AD110 doorbell presses! It's not integrated into HA yet, but I'll work with anyone who wants to update the python-amcrest and HA code to incorporate the event code and toggle a new doorbell button binary sensor.

@MYeager1967
Copy link

Any chance you'd forward me a copy of that script? I've been working on an Appdaemon script to handle the doorbell and it's working pretty good. I'm polling, but I'm going to start looking into the subscription method when I get time.

@GaryOkie
Copy link

GaryOkie commented Aug 18, 2020

Sure! It's just a slightly modified version of an app Phil wrote for testing subscriptions to motion events. There is some extra parsing in it that isn't necessary, but works nicely as a proof of concept. Lots of others have gone down the Appdaemon/MQTT route and custom code to handling Dahua cameras, but my hope is we can get this Amcrest code updated for full support of the doorbell as well as Dahua IVS capability and NVR's.

The key bit was discovering the undocumented doorbell button event code _DoTalkAction_. Upon a button press, this event will return "Action" : "Invite". If the doorbell is answered via the SmartHome app, the event will return : "Answer" . And when call ends or is not answered, "Hangup" is returned. The only thing actually relevant for a button sensor is simply parsing for "Invite".

from datetime import datetime
import sys

from amcrest import Http

def lines(ret):
    line = ''
    for char in ret.iter_content(decode_unicode=True):
        line = line + char
        if line.endswith('\r\n'):
            yield line.strip()
            line = ''

def main():
    if len(sys.argv) != 5:
        print(f'{sys.argv[0]} host port user password')
        sys.exit(1)

    host = sys.argv[1]
    port = sys.argv[2]
    user = sys.argv[3]
    pswd = sys.argv[4]

    cam = Http(host, port, user, pswd, retries_connection=1, timeout_protocol=3.05)

    ret = cam.command(
        'eventManager.cgi?action=attach&codes=[_DoTalkAction_]',
        timeout_cmd=(3.05, None), stream=True)
    ret.encoding = 'utf-8'

    try:
        for line in lines(ret):
            if "Invite" in line:
                print(
                    datetime.now().replace(microsecond=0),
                    ' - Doorbell Button Pressed'
                )
    except KeyboardInterrupt:
        ret.close()
        print(' Done!')

if __name__ == '__main__':
    main()

NOTE: The DoTalkAction code is SmartHome-specific. There is also a more general CallNoAnswered (Start/Stop) event that always occurs at the same time the button is pressed. I believe this event is also used by Dahua doorbells and VTO devices, so it is more suitable than DoTalkAnswer for python-amcrest implementation.

@MYeager1967
Copy link

How possible would it be for this simple routine to watch for multiple events? I'm assuming it wouldn't take anything more than properly defining another 'ret' with a different name and another 'try' to check it as well. I'm currently using a little gem I found call onvif-motion-events to monitor for motion events on my cameras and start/stop recording in motion/motionEye. I'd like to be able to expand the capabilities of that program but I haven't figured out how duplicate the repo that it's in so that I can recompile it when I need to. It's in javascript which isn't much of an issue but python is easier to work with.

@pnbruckner
Copy link
Collaborator

@MYeager1967

The HA integration is fairly broken at the moment and has been for a little while.

What exactly do you believe is broken? Have you opened an issue in the HA repo?

I would be happy to consider adding support for the doorbell if Amcrest provided an API spec. But given the fact that they no longer even document the API of cameras they used to document, and other responses I've seen other people post, I'm not holding my breath.

Also, I'm not sure it would make sense to modify the HA amcrest integration to only support binary sensors and not the camera functionality, but I wouldn't necessarily rule that out if enough people thought that made sense.

@GaryOkie
Copy link

GaryOkie commented Aug 20, 2020

Phil,

Dahua apparently considers their API document confidential now, so this probably explains why Amcrest can't make their version public anymore. The latest Dahua API document ( V2.84) is available here. It requires an NDA to register for a login.

Now, that's not to say that Amcrest's API is still identical to Dahua's like it used to be. RTSP, Motion detection and Indicator Light control already works as-is for the AD110 using the existing Amcrest code. (There is a difference in toggling MD though based on my tests comparing how the SmartHome app works - it currently toggles Alarm.Enable[0] instead).

Adding a new event code "_DoTalkAction_" parsing for "Invite" in the reply signals that the doorbell button has been pressed. I didn't find this code in any documentation. I just discovered it by simply using an event code of "All" in the code above to display every event the doorbell triggers. So in a way, the code is "documented" simply by using a previously documented API call to show exactly what the events are :)

BTW - You can find a version 2.76 of the Dahua API that's only a year old on the ipcamtalk forum. Maybe see if Amcrest has an NDA for their version?

@GaryOkie
Copy link

GaryOkie commented Aug 20, 2020

How possible would it be for this simple routine to watch for multiple events? I'm assuming it wouldn't take anything more than properly defining another 'ret' with a different name and another 'try' to check it as well.recompile it when I need to. It's in javascript which isn't much of an issue but python is easier to work with.

pretty simple! As mentioned above...

'eventManager.cgi?action=attach&codes=[All]',

will show every event, including stuff you wouldn't care about, like querying an NTP server every 5 minutes and adjusting the time.

According to the API doc, you can specify multiple codes separated by commas in the same call, so you could also try:

'eventManager.cgi?action=attach&codes=[VideoMotion, CrossLineDetection]',

(I am away from home and haven't tried this myself).

This discussion about advanced IVS features that pertain to Dahua cameras and not the doorbell should be moved to a different thread. I would suggest the Dahua IP Camera Feature requests topic a good place. I had commented there a few days ago as well.

@MYeager1967
Copy link

MYeager1967 commented Aug 20, 2020

As soon as I get around to slapping this in a docker container, I'll let you know what I learn. Move it wherever you think is appropriate, just let me know so I can follow it there....

I got this stuffed into a docker container to play with and it does indeed give me WAY more info than I'll ever need with [All]. Not sure if it's working properly with multiple events to look for, will work on that. That said, I'll set one up to monitor the doorbell and see what useful information I get out of it. May be a day or two before I get that done...

@digiblur
Copy link

@GaryOkie I have some digging to do on the flood light camera. Uses the same app as the doorbell. I want to be able to turn the lights on and off.

@GaryOkie
Copy link

GaryOkie commented Aug 20, 2020

@digiblur - I've come up with a fairly easy way to determine exactly what configuration setting in the camera is updated by the SmartHome app.

First, turn the lights off with the app, then run this command:
<ip_address>/cgi-bin/configManager.cgi?action=getConfig&name=All

this will display several thousand (!) lines of internal camera configs in your browser. Select all and copy to a file or spreadsheet.

Then turn on the lights via the app and run the command/copy/paste results again.

Diff the 2 files to see exactly what setting was changed from false to true. That setting should then be able to be changed with an API setConfig command.

(There is a free windiff utility if you don't have a linux system, or don't want to use Excel to compare cells)

@digiblur
Copy link

Nice! Thanks for confirming exactly what the process that I believe I need to do. I'll throw them into Notepad++ and use the compare plugin to do the diff. I appreciate it! I dug through a bit of a few SDK commands already and found some minor differences between the doorbell.

@digiblur
Copy link

Hmm...not seeing any difference. I can toggle the light as motion activated to kick on the floods and see that change but nothing on just turning on the lights. I'll have to do a packet capture but I have this feeling it's going out to the cloud and back.

@GaryOkie
Copy link

Huh, that's certainly unexpected. Every SmartHome setting I tried for the doorbell was identified in this manner. Good luck with the packet capture. I tried several and they all interfered with the ability to stream video in the app, but that shouldn't be an issue for testing the lights.

@digiblur
Copy link

Technically it isn't a setting, it's just an action to turn on the floodlight and/or siren on the main screen under the video stream.

@digiblur
Copy link

I looked at your piece above about subscribing to all codes and happened to see the status of the "WightLight" :) I could see myself turning it on and off.

Code=LeFunctionStatusSync;action=Pulse;index=0;data={
"Function" : "WightLight",
"Status" : true
}

I'll have to give it a shot on the doorbell for the button as that's just an event we need to read so it should work as you say.

@digiblur
Copy link

I do see what you were talking about with the events of pushing the bell. Interesting...it is indeed there!

Code=DoTalkAction;action=Pulse;index=0;data={
"Action" : "Invite",
"CallID" : "xxxxxxxxxxxxx",
"CallSrcMask" : 4
}

Saw some other stuff of course.

Code=VideoMotion;action=Start;index=0
Code=AlarmLocal;action=Start;index=6
Code=ProfileAlarmTransmit;action=Start;index=0;data={
"SenseMethod" : "PassiveInfrared",
"UTC" : 1597942508
}
Code=UpdateFile;action=Pulse;index=0
Code=AlarmLocal;action=Stop;index=6
Code=VideoMotion;action=Stop;index=0
Code=ProfileAlarmTransmit;action=Stop;index=0;data={
"SenseMethod" : "PassiveInfrared",
"UTC" : 1597942518
}

@GaryOkie
Copy link

GaryOkie commented Aug 20, 2020

"WightLight?" LOL, A Ghost light or the developer didn't know how to spell White? Anyway, that's an interesting discovery you see this LeFunctionStatusSync event tripped.

@MYeager1967
Copy link

I'm monitoring the doorbell with the [All] setting to see what I can glean from it. Also watching one of my cameras with the same routine. Learning a few things about the camera, the doorbell has been pretty boring so far. Not much going on outside and I'm not feeling like walking out there. :-) I'll have company in a bit and they always ring the bell before they come in.

@digiblur
Copy link

@GaryOkie maybe the dev was keeping it legit from the cancel culture bots on the net? :)

I'll have to look at some NodeRed nodes to see if I can attach and grab stuff that way. Should be simple in theory...

@GaryOkie
Copy link

Oh no! How am I going to illuminate all my trippy fluorescent 70's posters?

@GaryOkie
Copy link

@wallace4793 - While still in the python court, you might want to check out the sample code from myeager1967 somewhere in this thread which uses MQTT to send motion detection events to a server.

@GeorgeIoak
Copy link

@wallace4793 @MYeager1967 and I worked offline after my post but I've been running a slightly modified version of his code for a while now. It's running as a service on a Raspberry Pi and after some initial glitches and tweaks it's been reliable.

@wallace4793
Copy link

Hi George,

Do you send the output from the script to a web server on the rpi? I might try this eventually although having the virtual switch on my Vera makes it really easy to integrate with my HDMI switch so my tv switches to my camera input for a while before switching back.

All of that’s possible on python im sure but thehomeremote uses JavaScript and device objects which I’m already familiar with.

Are you willing to share your new script?

Thanks

John

@reesericci
Copy link

reesericci commented Mar 27, 2021 via email

@wallace4793
Copy link

wallace4793 commented Mar 27, 2021 via email

@reesericci
Copy link

reesericci commented Mar 27, 2021 via email

@GeorgeIoak
Copy link

Hi John @wallace4793

I'm also using Home Assistant(HA). The program sends a message to my MQTT server which HA is able to pick up and act on it. In my case I have HA capture a picture and then have Alexa announce that someone is at the front door.

If we don't hear back from MYeager1967 I'll post the full code but since he did most of the work I hesitate to share without his permission.

...
client = mqtt.Client("Doorbell"+str(int(random.random()*100)))
...

if ad110:
        cam = Http(host, port, user, pswd, retries_connection=1, timeout_protocol=3.05)
        ret = cam.command('configManager.cgi?action=setConfig&Lighting[0] [0].Mode=Off', timeout_cmd=(3.05, None), stream=False)
        if ret.status_code == requests.codes.ok:
                print("Night Vision Disabled...")

def main():
        global config, camera, user, pswd, host, port, ad110, biurl, bicred

        cam = Http(host, port, user, pswd, retries_connection=1, timeout_protocol=3.05)
        ret = cam.command('eventManager.cgi?action=attach&codes=[All]', timeout_cmd=(3.05, None), stream=True)
        ret.encoding = 'utf-8'

        for line in lines(ret):
        # Look through the response to see if the "_DoTalkAction_" action happened and then
..
                if code == '_DoTalkAction_':
                        print("-----")
                        print(line)
                        print("-----")
                        print(obj['Action'])
                        if obj['Action'] == 'Invite':
                                print("Button Pressed")
                                client.publish(basetopic+'/'+camera+'/button','on',QOS,False)
                        elif obj['Action'] == 'Hangup':
                                print("Button Cancelled")
                                client.publish(basetopic+'/'+camera+'/button','off',QOS,False)

You could replace this MQTT action with whatever you want (like posting to the web server).

George

@MYeager1967
Copy link

By all means, share the code and any / all improvements that any of you have made. I haven't touched it in quite a while as it runs in a docker container and it's been flawless for my use. Some day, I'm going to get back to it though and see what I can improve.

@GeorgeIoak
Copy link

@wallace4793 I created a repo for this code at https://github.com/GeorgeIoak/Amcrest_AD110_Button

I added some brief instructions which I hope will help

Thanks again to @MYeager1967 for getting this to work!

@MYeager1967
Copy link

MYeager1967 commented Mar 27, 2021 via email

@digiblur
Copy link

Hi,

Im having general difficulty with my new AD110. It doesnt ring my phone when I press the doorbell - only sends a audioble and visual notification. Rev2maxx on the forum has reported similar issues and warns against using any NVR or none smarthome apps. Has anyone else got this problem - and how is it fixed?

John

If you turn off the call notification settings in the app I heard it does disable it all. I use mine with the RTSP feeds and both of them ring the phone fine.

@wallace4793
Copy link

Hi,

So thanks to your advice I managed to cobble together my own basic python script to do the following:

  1. Turn all the TV inputs in my house to the doorbell camera (via my nvr and HDMI switch) using a socket command.
  2. Move the inputs back to the orignal inputs after a delay.

I have managed to use one of the files on here that uses "invite" as a trigger to mean someone is at the door - but I want to run my additional file at that point. Im having a mare with getting the file to rune, first I had to make all the commands in the second file global but now I can run the additional functions as these arent "global" either. The file runs OK independently but not when called as exec(file.py) - I also tried import method.

cameraswitch.txt
amcrest_motion5.txt

Python files uploaded as txt :-)

@GeorgeIoak
Copy link

I'm not a Python expert but you should be able to modify amcrest_motion5.py by adding:

from cameraswitch import *

and then change your execfile('cameraswitch.py') to just statuscheck() (after removing that line from cameraswitch)

@wallace4793
Copy link

I'm not a Python expert but you should be able to modify amcrest_motion5.py by adding:

from cameraswitch import *

and then change your execfile('cameraswitch.py') to just statuscheck() (after removing that line from cameraswitch)

Perfect, that works. I tried the import cameraswitch but it didnt work - needed the from and * :-)

@pixeldoc2000
Copy link

pixeldoc2000 commented Aug 3, 2021

FYI:
There is a working project for the AD100 which exposes the Doorbell press as MQTT with a working Docker Container:
https://github.com/dchesterton/amcrest2mqtt
https://hub.docker.com/r/dchesterton/amcrest2mqtt
It's easy to integrate with Home Assistant.

That is what I am using ATM.

EDIT: Automation via Event with this Integration works too. Switch to this Integration.

@MYeager1967
Copy link

MYeager1967 commented Aug 3, 2021 via email

@reesericci
Copy link

is this working in the current python-amcrest lib?

@GaryOkie
Copy link

GaryOkie commented Sep 12, 2021

The ability to provide a complete event payload in support of the AD110/AD410 was added to python-amcrest a year ago - see: #162

The initial HASS Amcrest PR to leverage this did not pass go and was abandoned. A refreshed PR was approved/ merged last April (home-assistant/core#49004) which does now provide event handling. This allows HASS automations to trigger on events that detect doorbell presses, PIR motion, Human Detection as well as ANY event for other Amcrest or Dahua cameras (IVS tripwire, intrusion, etc.)

see: https://www.home-assistant.io/integrations/amcrest/#events

Automation example:

- id: doorbell_button_pressed
  alias: Doorbell button pressed
  trigger:
  - platform: event
    event_type: amcrest
    id: doorbell
    event_data:
      event: CallNoAnswered
      payload:
        action: Start

  action:
   - service: persistent_notification.create
     data_template:
         message: "Front Door Doorbell Pressed"

If preferred, binary sensors can also be created from templates and events.

Configuration.yaml example:

template:   # Create a binary_sensor for AD410 Human Detection
  trigger:
  - platform: event
    event_type: amcrest
    id: start
    event_data:
      event: CrossRegionDetect 
      payload:
        action: Start
        
  - platform: event
    event_type: amcrest
    id: stop
    event_data:
      event: CrossRegionDetect
      payload:
        action: Stop
        
  binary_sensor:
    - name: Human Motion Detected
      state: >-
        {{ 'on' if trigger.id == 'start' else 'off' }}

@reesericci
Copy link

so then why isn't this issue closed? what's left?

@GaryOkie
Copy link

GaryOkie commented Sep 17, 2021

really, nothing... except a documentation update and/or a new blueprint. I'll see if I can help with that after vacation.

Some would prefer to have new binary sensors created - especially for doorbell press rather than deal with events, but it's not necessary. The most important update this integration needs is config flow UI. New config options can't be added until that occurs as YAML updates aren't allowed. (Although I see that a crossline detection binary sensor was added several months ago in direct opposition of this rule!)

EDIT: BTW - my comments here were meant for the HASS Amcrest Integration, not python-amcrest, which is already good to go for supporting the doorbells via events. Agree this should be closed.

@m0ngr31
Copy link

m0ngr31 commented Dec 15, 2021

I got mine tied into Home Assistant. I'm curious if there's a way to fire an event to record to the SD card for x amount of time if a trigger happens?

@MYeager1967
Copy link

Many have found the SD card to be pretty unreliable. Better to catch the feed with another program and record it to a hard drive or something.

@pixeldoc2000
Copy link

@MYeager1967
Mine works fine for about 1/2 Year now.

What SD-Card are you using? "Cheap" SD-Cards often craps out with lot of write access / Temperatur swings / etc.

This one works fine for me: Transcend 16GB High Endurance microSDXC/SDHC TS16GUSDXC10V . There are a lot of "industrial" grade SD-Cards too.

@m0ngr31
You can setup Recording to SD-Card with the Amcrest App in Camera.

@MYeager1967
Copy link

@MYeager1967 Mine works fine for about 1/2 Year now.

What SD-Card are you using? "Cheap" SD-Cards often craps out with lot of write access / Temperatur swings / etc.

This one works fine for me: Transcend 16GB High Endurance microSDXC/SDHC TS16GUSDXC10V . There are a lot of "industrial" grade SD-Cards too.

@m0ngr31 You can setup Recording to SD-Card with the Amcrest App in Camera.

Honestly, I think I only had an SD-card in it for a few days. It could be still in there, I have no idea. Haven't used the app so it was uninstalled and I believe that's about the only way to check the SD-card.... I use either PNY or SanDisk cards although I have a few others laying around. Don't care for the cheap ones. By the way, the key to my last comment was "many have found", not "I have found"...

I've been using my AD110 with NVR software from the start.

@m0ngr31
Copy link

m0ngr31 commented Dec 17, 2021

@pixeldoc2000 I'm trying to activate a recording automatically if my alarm triggers - even if it's just audio and nobody comes out the front door.

@MYeager1967 What NVR are you using? I'd like to get into Frigate, but finding a Coral USB device is looking just about impossible for a reasonable price.

@MYeager1967
Copy link

@pixeldoc2000 I'm trying to activate a recording automatically if my alarm triggers - even if it's just audio and nobody comes out the front door.

That's going to be a function well above the doorbell itself.

@MYeager1967 What NVR are you using? I'd like to get into Frigate, but finding a Coral USB device is looking just about impossible for a reasonable price.

I'm currently using BlueIris, but you can use Frigate without the Coral device to record. What the Coral device does is vastly improve the object detection and tracking abilities of Frigate. In your position, I'd likely opt for setting it up and not activating the object detection until the prices came back down on the Coral devices. I'm fairly certain there's an API that would allow you to trigger a recording when needed.

@mattkerrison
Copy link

Has anyone been able to either send the quick responses or get bi-directional audio working on the AD410? I would assume it's possible somehow as the camera supports ONVIF profile T which supports bi-directional.

I also noted several other apps like Synology Surveillance Station support bi-directional locally, so it must be exposed somewhere.

@GaryOkie
Copy link

GaryOkie commented Jan 27, 2022

I was unable to determine how the app is communicating what sound files to play. When sending quick responses from the SH app to the AD410 I could detect no events being created when subscribing to "all". Nor could I find a documented API call.

As to 2-way talk, you're right about ONVIF support. Reportedly the Amcrest Vew Pro app is also bi-directional and does not use the cloud. So there is hope there. Refer to this post:
https://community.home-assistant.io/t/amcrest-video-doorbell-ad110-initial-impressions/171290/303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests