Skip to content

Commit

Permalink
Support human detection binary sensor for camera devices
Browse files Browse the repository at this point in the history
  • Loading branch information
rroller committed Aug 30, 2021
1 parent 860c269 commit 6b70dbd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/dahua/__init__.py
Expand Up @@ -394,7 +394,7 @@ def on_receive(self, data_bytes: bytes, channel: int):
# We'll use these timestamps in binary_sensor to know how long to trigger the sensor

# This is the event code, example: VideoMotion, CrossLineDetection, etc
event_name = event["Code"]
event_name = self.translate_event_code(event)

event_key = self.get_event_key(event_name)
listener = self._dahua_event_listeners.get(event_key)
Expand Down Expand Up @@ -424,7 +424,8 @@ def translate_event_code(self, event: dict):
# }
# }
if code == "CrossLineDetection":
is_human = event.get("Data", {}).get("Object", {}).get("ObjectType", "").lower() == "human"
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:
code = "SmartMotionHuman"

Expand Down

0 comments on commit 6b70dbd

Please sign in to comment.