python-amcrest
python-amcrest copied to clipboard
possible support for amcrest AD110 ?
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 ?
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...
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..
@aaamoeder use the ID of admin and the device password you made during pairing.
@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 use the ID of admin and the device password you made during pairing.
Tried that, but sadly it's not working.
@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.
have it setup as a generic camera atm and that works fine.. weird, will test more later.
Apparently there's no API spec for the push button, get amcrest to add it!
She said it, not me. Go here: https://amcrest.com/forum/feature-device-request-f31/?sid=b06b1727d00da763f3bd30fa95b20c57
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...
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.
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.
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.
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.
@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.
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?
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.
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...
@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.
@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)
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.
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.
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.
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.
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.
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 }
"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.
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.
@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...
Oh no! How am I going to illuminate all my trippy fluorescent 70's posters?