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

dahua_event_received events coming in inconsistent format #404

Open
jakon89 opened this issue Oct 30, 2024 · 0 comments
Open

dahua_event_received events coming in inconsistent format #404

jakon89 opened this issue Oct 30, 2024 · 0 comments

Comments

@jakon89
Copy link
Contributor

jakon89 commented Oct 30, 2024

I have an automation setup that listens for dahua_event_received events.

So far, all dahua_event_received events except one came with the correct format. However, there was a single event where trigger.event.data.data was sent as a string (JSON), and my automation could not process it - it expected the object to be sent, not a "flat" string. This is strange - both events are posted below.

Below I am pasting two automation traces: first one where valid event was received and the second one with malformed data.

The correct event that is usually fired by this dahua integration:

this:
  entity_id: automation.notify_about_irv_rule
  state: 'on'
  attributes:
    id: '1730047532723'
    last_triggered: '2024-10-30T13:07:15.323646+00:00'
    mode: single
    current: 0
    friendly_name: Notify about IVS event
  last_changed: '2024-10-29T10:58:51.931804+00:00'
  last_reported: '2024-10-30T13:07:15.327532+00:00'
  last_updated: '2024-10-30T13:07:15.327532+00:00'
  context:
    id: 01JBERK67VAR15VJ5QRPQ87AT5
    parent_id: 01JBERK67TT5X5WBR0MCD5E947
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: event
  event:
    event_type: dahua_event_received
    data:
      Code: CrossRegionDetection
      action: Start
      index: '0'
      data:
        Action: Appear
        Class: Normal
        CountInGroup: 1
        DetectRegion:
          - - 1772
            - 3215
          - - 2054
            - 4514
          - - 8188
            - 3971
          - - 8172
            - 2470
        EventID: 10019
        GroupID: 18
        Name: TEST RULE
        Object:
          Action: Appear
          Attachment: []
          BelongID: 0
          BoundingBox:
            - 6600
            - 3256
            - 7208
            - 3720
          BrandYear: 0
          CarLogoIndex: 0
          CarWindow:
            BoundingBox:
              - 0
              - 0
              - 0
              - 0
          Category: Unknown
          CategoryConfidence: 0
          Center:
            - 6904
            - 3488
          Confidence: 0
          FusionInfo:
            BelongID: 0
            CartPosX: 0
            CartPosY: 0
            GpsPosValid: 0
            GpsPostion:
              Latitude: 0
              Longitude: 0
            ObjectSource: 0
            RadarCoorXyValid: 0
            Speed: 0
            SpeedValid: 0
            SpeedX: 0
            SpeedY: 0
          MainColor:
            - 0
            - 0
            - 0
            - 0
          ObjectID: 114
          ObjectType: Vehicle
          PTZ:
            - 0
            - 0
            - 0
          RelativeID: 0
          Speed: 0
          SubBrand: 0
          Text: Unknown
          VehiclePosture: 1
          VehicleSignConfidence: 0
          carLenMode: 0
          carLength: 0
          carTripLineDirection: 0
        PTS: 42997199400
        RealUTC: 1730298017
        RuleID: 3
        Track: []
        UTC: 1730301617
        UTCMS: 365
      name: Kamera-Front
      DeviceName: Kamera-Front
    origin: LOCAL
    time_fired: '2024-10-30T14:20:17.348718+00:00'
    context:
      id: 01JBEWRXJ423MEBPACX94HXGEF
      parent_id: null
      user_id: null
  description: event 'dahua_event_received'

The malformed event that was sent once by this dahua integration: (notice difference in key trigger.event.data.data between this and above event)

this:
  entity_id: automation.notify_about_irv_rule
  state: 'on'
  attributes:
    id: '1730047532723'
    last_triggered: '2024-10-30T12:56:10.524856+00:00'
    mode: single
    current: 0
    friendly_name: Notify about IVS event
  last_changed: '2024-10-29T10:58:51.931804+00:00'
  last_reported: '2024-10-30T12:56:11.070321+00:00'
  last_updated: '2024-10-30T12:56:11.070321+00:00'
  context:
    id: 01JBEQYX0WSQ0XG24FJMF7X77H
    parent_id: 01JBEQYX0TKVRM6ZHZCHYRT6SG
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: event
  event:
    event_type: dahua_event_received
    data:
      Code: CrossRegionDetection
      action: Start
      index: '0'
      data: |-
        {
           "Action" : "Appear",
           "Class" : "Normal",
           "CountInGroup" : 1,
           "DetectRegion" : [
              [ 1772, 3215 ],
              [ 2054, 4514 ],
              [ 8188, 3971 ],
              [ 8172, 2470 ]
           ],
           "EventID" : 10017,
           "GroupID" : 16,
           "Name" : "TEST RULE",
           "Object" : {
              "Action" : "Appear",
              "Attachment" : [],
              "BelongID" : 0,
              "BoundingBox" : [ 6896, 3488, 7136, 3712 ],
              "BrandYear" : 0,
              "CarLogoIndex" : 0,
              "CarWindow" : {
                 "BoundingBox" : [ 0, 0, 0, 0 ]
              },
              "Category" : "Unknown",
              "CategoryConfidence" : 0,
              "Center" : [ 7016, 3600 ],
              "Confidence" : 0,
              "FusionInfo" : {
                 "BelongID" : 0,
                 "CartPosX" : 0.0,
                 "CartPosY" : 0.0,
                 "GpsPosValid" : 0,
                 "GpsPostion" : {
                    "Latitude" : 0.0,
                    "Longitude" : 0.0
                 },
                 "ObjectSource" : 0,
                 "RadarCoorXyValid" : 0,
                 "Speed" : 0.0,
                 "SpeedValid" : 0,
                 "SpeedX" : 0.0,
                 "SpeedY" : 0.0
              },
              "MainColor" : [ 0, 0, 0, 0 ],
              "ObjectID" : 112,
              "ObjectType" : "Vehicle",
              "PTZ" : [ 0, 0, 0 ],
              "RelativeID" : 0,
              "Speed" : 0,
              "SubBrand" : 0,
              "Text" : "Unknown",
              "VehiclePosture" : 1,
              "VehicleSignConfidence" : 0,
              "carLenMode" : 0,
      name: Kamera-Front
      DeviceName: Kamera-Front
    origin: LOCAL
    time_fired: '2024-10-30T13:07:15.322836+00:00'
    context:
      id: 01JBERK67TT5X5WBR0MCD5E947
      parent_id: null
      user_id: null
  description: event 'dahua_event_received'
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

1 participant