rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
383 stars 74 forks source link

For IVS event, include additional details as sensor attributes #373

Open actran opened 1 month ago

actran commented 1 month ago

Is your feature request related to a problem? Please describe. I typically have multiple tripwire rules for 1 cam (or intrusion rules). Each rule has a different name.

Describe the solution you'd like For each IVS event, any chance the rule name or number can be captured in the sensor attribute?

Nice to have, if IVS event includes A->B or B->A detail, store that detail as another sensor attribute. Nice to have, if IVS AI event includes human or vehicle detection detail, store that detail as another sensor attribute.

Knowing whether IVS rule1 or 2 or...was triggered will allow me to take the right action in my automations. Thanks.

jgverweij commented 1 month ago

This is already available in the event data.

Example automation:

alias: Example event data
description: Cross Line Detection (event-based)
trigger:
  - platform: event
    event_type: dahua_event_received
    event_data:
      name: Dahua
      Code: CrossLineDetection
      action: Start
    id: general
  - platform: event
    event_type: dahua_event_received
    event_data:
      name: Dahua
      Code: CrossLineDetection
      action: Start
      data:
        Object:
          ObjectType: Human
    id: Human Motion
  - platform: event
    event_type: dahua_event_received
    event_data:
      name: Dahua
      Code: CrossLineDetection
      action: Start
      data:
        Object:
          ObjectType: Vehicle
    id: Vehicle Motion
condition:
  - condition: state
    entity_id: input_boolean.dahua_cld_snapshot
    state: "on"
action:
  - variables:
      ivs_rule_name: '{{ trigger.event.data.data.Name }}'

You can then use the variable ivs_rule_name See the automation trace for all available event data.