dahua icon indicating copy to clipboard operation
dahua copied to clipboard

CrossLineDetection not processed correctly in home assistant

Open RobinHarteveld opened this issue 2 years ago • 4 comments

Hello,

First of all thanks for all your hard work you put into this project. I'm very pleased with it.

Unfortunately I have a problem with the Crosslinedetection on one of my cams. I have 2 different types of Dahua cams. Camera1 IPC-HDW4421EM-AS Firmware: 2.620.0000002.0.R,build:2017-08-30 Camera2 IPC-HDW5442TM-ASE Firmware: 2.800.0000000.19.R,build:2020-07-09

One works fine (camera1) with the detection of the "crosslinedetection"events

2022-05-18 09:39:09 DEBUG (MainThread) [custom_components.dahua] Events received from 172.16.1.170 on channel 0: [{'Code': 'CrossLineDetection', 'action': 'Start', 'index': '0'}] 2022-05-18 09:39:11 DEBUG (MainThread) [custom_components.dahua] Events received from 172.16.1.170 on channel 0: [{'Code': 'CrossLineDetection', 'action': 'Stop', 'index': '0'}]

But HA receives the event from camera2, but does NOT trigger the entity in HA.

2022-05-18 09:44:31 DEBUG (MainThread) [custom_components.dahua] Events received from 172.16.1.171 on channel 0: [{'Code': 'CrossLineDetection', 'action': 'Start', 'index': '0', 'data': {'Class': 'Normal', 'CountInGroup': 1, 'DetectLine': [[2209, 6041], [3386, 4450], [5256, 6708], [4918, 7998], [2499, 7933]], 'Direction': 'RightToLeft', 'EventID': 10021, 'GroupID': 20, 'Name': 'Rule 1', 'Object': {'Action': 'Appear', 'BoundingBox': [1032, 2352, 3832, 7952], 'Center': [2432, 5152], 'Confidence': 0, 'LowerBodyColor': [0, 0, 0, 0], 'MainColor': [0, 0, 0, 0], 'ObjectID': 20530, 'ObjectType': 'Human', 'RelativeID': 0, 'Speed': 0}, 'PTS': 43063581930.0, 'RuleID': 4, 'Track': [], 'UTC': 1652867071, 'UTCMS': 448}}] 2022-05-18 09:44:34 DEBUG (MainThread) [custom_components.dahua] Events received from 172.16.1.171 on channel 0: [{'Code': 'CrossLineDetection', 'action': 'Stop', 'index': '0', 'data': {'Class': 'Normal', 'CountInGroup': 1, 'DetectLine': [[2209, 6041], [3386, 4450], [5256, 6708], [4918, 7998], [2499, 7933]], 'Direction': 'RightToLeft', 'EventID': 10021, 'GroupID': 20, 'Name': 'Rule 1', 'Object': {'Action': 'Appear', 'BoundingBox': [1032, 2352, 3832, 7952], 'Center': [2432, 5152], 'Confidence': 0, 'LowerBodyColor': [0, 0, 0, 0], 'MainColor': [0, 0, 0, 0], 'ObjectID': 20530, 'ObjectType': 'Human', 'RelativeID': 0, 'Speed': 0}, 'PTS': 43063581930.0, 'RuleID': 4, 'Track': [], 'UTC': 1652867071, 'UTCMS': 448}}]

Configuration: Version: core-2022.5.4 Install type: Home Assistant OS Dahua integration version 0.9.39

I think the problem has something to do with the extra "data" (Class, CountIngroup, etc.) in the response of the camera during an event such as somebody walking by.

Hope you can help.

Robin

RobinHarteveld avatar May 18 '22 23:05 RobinHarteveld

I've encountered the same thing and I think it happens with both CrossLineDetection and CrossRegionDetection. There is some mention in other places but it's not clear it's the same issue - the closest I have found is on the HA forums (https://community.home-assistant.io/t/home-assistant-dahua-integration-questions/387305/21 user: "undecimo" Jun 13)

I've been looking at the code and I'm wondering if it's in line 481 of init.py where I think for some reason CrossLineDetection and CrossRegionDetection is being renamed SmartMotionHuman?

@rroller - hopefully you've got time to look at this one? Thanks for what you've done by the way, it's a lot of work to get here!

        if code == "CrossLineDetection" or code == "CrossRegionDetection":
            data = event.get("data", event.get("Data", {}))
            is_human = data.get("Object", {}).get("ObjectType", "").lower() == "human"
            if is_human and self._dahua_event_listeners.get(self.get_event_key(code)) is not None:
                return "SmartMotionHuman"

madpig83 avatar Aug 25 '22 11:08 madpig83

I don't know if it's exactly the same problem, but with my IPC-HDW5241H-AS-PV camera, I correctly receive Crossline=Tripware, but I don't receive Crossregion=Intrusion.

The controls work properly, from the tested Crossline and Smart Motion Human sensors.

HomeAssistant 2022.8.6 IPC-HDW5241H-AS-PV Firmware: 2.800.9999007.0.R,build:2021-04-12

image

isabido avatar Aug 30 '22 17:08 isabido

@isabido looking at the code I wouldn't think it's the same issue (because the code looks to apply for both CrossLine and CrossRegion), but maybe try it and see what you find. I've now had the change in code for more than 1 week and it's working fine for me.

madpig83 avatar Sep 03 '22 07:09 madpig83

Just want to chime in - pretty new to HA; but thanks a bunch for this Dahua integration.

On both my cameras, I have the tripwire detection set and works well via the Dahua interface via web browser.

However, the tripwire sensor (Cross Line Alarm) does not get triggered in HA; where the Smart Motion Detection does get triggered, even though it is turned off?

Cam 1: IPC-HFW3249T1-AS-PV / Firmware: 2.820.0000000.2.R,build:2021-04-03 Cam 2: IPC-HDW3249H-AS-PV / Firmware: 2.820.0000000.2.R,build:2021-04-03

Would be great if the Cross Line Alarm sensor would trigger as per the cams settings.

Thanks!

Jieper001 avatar Sep 08 '22 10:09 Jieper001