I wanted to start a new thread to discuss the possibility of using the "Subscribe to event message" as a means of replacing the builtin lack luster algorithms that NVRs provide as a replacement for false motion detections, since doorbell utilizes the PIR sensor to detect motion and generate events for each motion detected.
This is the API in question and has anyone looked into it by any chance?
Comment
eventCode can be any one of the standard codes defined in DHIIF, or “All”. All means all kinds of the eventcode.
eventcode include:
VideoMotion:
VideoLoss:
VideoBlind:
AlarmLocal: CrossLineDetection: CrossRegionDetection: LeftDetection: TakenAwayDetection: VideoAbnormalDetection: FaceDetection: AudioMutation: AudioAnomaly: VideoUnFocus: WanderDetection: RioterDetection: ParkingDetection: MoveDetection: StorageNotExist: StorageFailure: StorageLowSpace: AlarmOutput:
tripwire event
intrusion event
abandoned object detection missing object detection scene change event
face detect event
intensity change
input abnormal
defocus detect event loitering detection event People Gathering event parking detection event
fast moving event
storage not exist event. storage failure event. storage low space event. alarm output event.
motion detection event video loss detection event video blind detection event. alarm detection event.
MDResult: motion detection data reporting event. The motion detect window contains 18 rows and 22 columns. The event info contains motion detect data with mask of every row.
HeatImagingTemper: temperature alarm event
133
keepalive: if this param exist, the client must send any data to device by this connection in cycle. The keepalive is in range
of [1,60] second. For example:
The keeplive data can be the string “keep alive”.
My assumption is that the responses are streamed for as long as the connection remains active. For example Synology's Surveillance Station action rules could establish the connection and generate it's on events to its client apps based on the reception of these HTTP API data streams (I think).
My assumptions were correct the subscription to events is indeed a persistent http connection which is really good news. Perhaps a simple script to parse the responses then feed the events to a Synology webhook would work. The following is the curl command for those who want to play with it:
Note: %2c is a comma, but needs to be escaped for http url parsing.
I now have enough information to create a script where we can accurately relay these events to NVR as motion triggers by utilizing both VideoMotion and AlarmLocal event "Codes" where the action value is of type "Start". I should be able write a generic shell script using curl, json parser and tcp/telnet socket to forward the custom notification to my Synology.
Here is the proof-of-concept. It's a bash script which detects a motion + alarm event and generates a http post to the Synology Surveillance Station. The contents are pretty straight forward for manipulating it for you own use. At the moment I am creating snapshots since there is no option to update the camera's timeline with a notification marker.
script name:
amcrest-ad110-events
Mandatory fields to update:
PASS == Device password.
TRIGGER == Synology webhook url or something similiar if not synology.
Optional fields to update:
ADDRESS == Specify one if you don't use hostnames.
TMP_DIR == Where to write the PID and Named Pipe files.
@pcabral - It's great to see the advances you are making in improving this doorbells motion handling.
In my testing, the undocumented Amcrest-specific "_DoTalkAction_" event with the Action "Invite" signals the doorbell push. I am working with the python-amcrest devs to get this added so that Home Assistant's Amcrest integration will have a new doorbell button sensor.
I'm not understanding how you think this doorbell is capable of PEOPLE detection. That is an advanced IVS feature of Dahua cameras and I sure wasn't aware that any Amcrest devices were capable of it (unless flashed with Dahua firmware). So you are saying that AlarmLocal;action=Start;index=6 signifies a person detected?
Bad wording on my end.... not people but an object was detected which is a combination of video motion and the alarm local event.... which I'm assuming it is utilizing both video and PIR?!?
I did notice that there are constant events with video motion events being generated but they do not translate into an amcrest app notification.
It's only when an AlarmLocal and VideoMotion are both generated that the amcrest app is then notified it would seem.
GaryOkie wrote: ↑Sat Aug 22, 2020 12:17 pm
"I'm not understanding how you think this doorbell is capable of PEOPLE detection. That is an advanced IVS feature of Dahua cameras and I sure wasn't aware that any Amcrest devices were capable of it (unless flashed with Dahua firmware). "
Thanks @jack7 for pointing out some Amcrest devices do have AI person detection. As to the doorbell, that's a feature it really ought to have without an NVR required.
@pcabral - So that's interesting that a MotionDetection event by itself isn't sufficient to trigger an alert and recording in the SH app. This actually meshes with what I noticed when you toggle Motion Detection in the app. The Motiondetection config setting internally in the doorbell never changes - it's always enabled. But when you turn off MD in the app, two things get set to false in the doorbell config: Alarm[0].Enable & Alarm[0].EventHandler.SnapshotEnable (I have no idea why snapshot was necessary to be disabled).
This motion detection event logic apparently is unique to the AD110 doorbell.
EDIT: This also probably means that the motion detection logic in Home Assistant/python-amcrest and others will respond to MD events even when MD has been turned off by the SH app, since they aren't AND'ing alarm events too to my knowledge. I wonder how the NVR's are handling this if this is a SmartHome-specific contrivance? Something else for me to test when I get back home next week...
@GaryOkie honestly I'm thinking the video motion event can be ignored all together and only handle the AlarmLocal with index 6 or 7 should be good enough.
I will also update my script to reflect that change and also use basic shell support and not bash to allow this script to be run from busy box and other devices where bash is not available.
I'm also betting that index 6 and 7 are used in some sort of lookup table to identify the detection type.