Binary Sensor for Human Detection on Amcrest AD410 Doorbell

I’m trying to use events to set the state of a binary sensor showing when the doorbell detects a human, and the binary sensor should stay on until the human is no longer detected.

Here’s what I tried:

template:
  - trigger:
      -  platform: event
         id: start
         event_type: amcrest
         event_data:
           event: IntelliFrame
           payload:
             data:
               Action: Start
      - platform: event  
        id: stop       
        event_type: amcrest
        event_data:
          event: IntelliFrame
          payload:
            data:
              Action: Stop
    binary_sensor: 
      - name: Doorbell Human Detected
        state: "{% if is_state('trigger.id','start') %}on{% elif is_state('trigger.id','stop') %}off{% endif %}"

It does not work at all. I suppose it’s because I have no idea what I’m doing with templates. Any help would be greatly appreciated.

To clarify:
If I use those triggers in automations to control a boolean, they work as desired. That is why I suppose that it’s the template.

Probably formatting error as it differs from Turning an Event into a Binary Sensor’s example.

Can you try this? I have not used it myself, so I don’t know if it works or not.

template:
  trigger:
    - platform: event
      event_type: amcrest
      id: start
      event_data:
        event: IntelliFrame
        payload:
          data:
            Action: Start
    - platform: event
      event_type: amcrest
      id: stop
      event_data:
        event: IntelliFrame
        payload:
          data:
            Action: Stop
  binary_sensor:
    - name: Doorbell Human Detected
      state: >-
        {{ 'on' if trigger.id == 'start' else 'off' }}
1 Like

That works perfectly! Thanks for taking the time to help me out.

Hi,

I’m new to this too, it works for me also. I’ve got 2 Amcrest doorbells. How might I customise the triggers to match the specific doorbell.
Would I add in the “camera” to the data: section?

I’m a bit scared to change your script in case it breaks something

You’d add it like this:

template:
  trigger:
    - platform: event
      event_type: amcrest
      id: start
      event_data:
        camera: Your camera name
        event: IntelliFrame
        payload:
          data:
            Action: Start
    - platform: event
      event_type: amcrest
      id: stop
      event_data:
        camera: Your camera name
        event: IntelliFrame
        payload:
          data:
            Action: Stop
  binary_sensor:
    - name: Doorbell Human Detected
      state: >-
        {{ 'on' if trigger.id == 'start' else 'off' }}
1 Like

@chaibas

I didn’t see in the Amcrest integration documentation that it fires an event for human detection. Can you show me your configuration how to get human detection events to fire in home assistant?

Thanks!

template:
  - trigger:
      -  platform: event
         id: start
         event_type: amcrest
         event_data:
           event: IntelliFrame
           payload:
             data:
               Action: Start
      - platform: event  
        id: stop       
        event_type: amcrest
        event_data:
          event: IntelliFrame
          payload:
            data:
              Action: Stop
    binary_sensor: 
      - name: Doorbell Human Detected
        state: >-
          {{ 'on' if trigger.id == 'start' else 'off' }}
1 Like

It would be nice to see this template sensor, as well the “CallNoAnswered/Ring Press” to be added to the native integration.

Note that per the above examples, “CrossRegionDetection” is normally used for human detection on the AD410, but this odd/undocumented IntelliFrame event occurs in tandem.

For what it’s worth, the CrossRegionDetection event provides a lot more information in the payload which may only be useful in the future if the AD410 firmware is updated to select other object types like vehicles besides just humans.

Event Code:  CrossRegionDetection    Payload: {'Code': 'CrossRegionDetection', 'action': 'Start', 'index': '0', 'data': {'Action': 'Appear', 'CfgRuleId': '1,', 'Class': 'Normal', 'CountInGroup': '0,', 'DetectRegion': '[', 'Direction': 'Enter', 'EventID': '10839,', 'EventSeq': '8,', 'FrameSequence': '23472680,', 'GroupID': '8,', 'Mark': '0,', 'Name': 'IVS-1', 'Object': '{', 'Age': '0,', 'Angle': '0,', 'Bag': '0,', 'BagType': '0,', 'BoundingBox': '[', 'CarrierBag': '0,', 'Center': '[', 'Confidence': '0,', 'DownClothes': '0,', 'Express': '0,', 'FaceFlag': '0,', 'FaceRect': '[', 'Gender': '0,', 'Glass': '0,', 'HairStyle': '0,', 'HasHat': '0,', 'Helmet': '0,', 'HumanRect': '[', 'LowerBodyColor': '[', 'MainColor': '[', 'MessengerBag': '0,', 'ObjectID': '4278,', 'ObjectType': 'Human', 'Phone': '0,', 'RelativeID': '0,', 'SerialUUID': '', 'ShoulderBag': '0,', 'Source': '-1.0,', 'Speed': '0,', 'SpeedTypeInternal': '0,', 'Umbrella': '0,', 'UpClothes': '0,', 'UpperBodyColor': '[', 'UpperPattern': '0', 'PTS': '46128302210.0,', 'Priority': '0,', 'RuleID': '1,', 'RuleId': '1,', 'Track': '[],', 'UTC': '1630248627,', 'UTCMS': '181'}}
Event Code:  IntelliFrame    Payload: {'Code': 'IntelliFrame', 'action': 'Pulse', 'index': '0', 'data': {'Action': 'Start'}}

The main problem with getting new options added to the core Amcrest Integration is that no more YAML configurations can be added. If/when “config flow” is added to this code to provide option selections via the UI, then new sensors like this can be fairly easily added.

Until then, parsing events and optionally creating binary sensors for them is what must be done.
(EDIT: Or you can try the custom Dahua Integration which has a plethora of selectable sensors)