dahua
dahua copied to clipboard
AD410: Failed to read data and goes goes offline
Version of the custom_component
Dahua version 0.9.34 on HACS 1.18.0
Configuration
I do not have a configuration as it was done through the integration. It should be noted that I did enable the 'cross region detection' because without it enabled, motion detection didn't work until it was enabled. When I was listening for events, I did noticed that it seemed required.
Describe the bug
I am seeing errors appear in my home assistant log related to teh following:
Logger: custom_components.dahua Source: custom_components/dahua/vto.py:355 Integration: Dahua (documentation, issues) First occurred: 4:39:16 PM (1 occurrences) Last logged: 4:39:16 PM
Debug log
I do not have debug logging enabled but I can enable it and wait for it to reoccur if that would help.
ailed to read data: b' \x00\x00\x00DHIP\xdc^,f\x08\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10437,"EventSeq":222,"FrameSequence":3113933,"GroupID":222,"LocaleTime":"2022-01-25 16:39:16","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIP\xdc^,f\x08\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10439,"EventSeq":224,"FrameSequence":3114692,"GroupID":224,"LocaleTime":"2022-01-25 16:40:25","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":[2984,3504,5304,7984],"CarrierBag":0,"Center":[4144,5744],"Confidence":0,"DownClothes":0,"Express":0,"FaceFlag":0,"FaceRect":[0,0,0,0],"FrameSequence":3114692,"Gender":0,"Glass":0,"HairStyle":0,"HasHat":0,"Helmet":0,"HumanRect":[0,0,0,0],"LowerBodyColor":[0,0,0,0],"MainColor":[0,0,0,0],"MessengerBag":0,"ObjectID":582,"ObjectType":"Human","Phone":0,"RelativeID":0,"SerialUUID":"","ShoulderBag":0,"Source":0.0,"Speed":0,"SpeedTypeInternal":0,"Umbrella":0,"UpClothes":0,"UpperBodyColor":[0,0,0,0],"UpperPattern":', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIP\xdc^,f\x08\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10439,"EventSeq":224,"FrameSequence":3114692,"GroupID":224,"LocaleTime":"2022-01-25 16:40:57","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIP\xdc^,f\x08\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10441,"EventSeq":226,"FrameSequence":3117357,"GroupID":226,"LocaleTime":"2022-01-25 16:46:25","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox"', error: substring not found, Line: 348
I am experiencing the same error(?). Started after lasted upgrade of Home Assistant. Occurs once per hour. Thanks.
2022-01-24 18:43:26 ERROR (Thread-4) [custom_components.dahua] Failed to read data: b' \x00\x00\x00DHIPl]\xbdi\x08\x00\x00\x00\xe3\x04\x00\x00\x00\x00\x00\x00\xe3\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[2338.351948699059,3869.337464522073],[66.66072136059142,3994.116611940465],[73.66132867824264,8189.818548146599],[8191,8191],[8191,4000],[7438.281406045658,3705.564706311552]],"EventID":10001,"EventSeq":0,"FrameSequence":265275,"GroupID":0,"LocaleTime":"2022-01-24 18:43:26","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":[6696,3800,7176,4824],"CarrierBag":0,"Center":[6936,4312],"Confidence":0,"DownClothes":0,"Express":0,"FaceFlag":0,"FaceRect":[0,0,0,0],"FrameSequence":265275,"Gender":0,"Glass":0,"HairStyle":0,"HasHat":0,"Helmet":0,"HumanRect":[0,0,0,0],"LowerBodyColor":[0,0,0,0],"MainColor":[0,0,0,0],"MessengerBag":0,"ObjectID":20,"ObjectType":"Human","Phone":0,"RelativeID":0,"SerialUUID":"","ShoulderBag":0,"So', error: substring not found, Line: 348
I'm actually also seeing others whichI don't know if I should include in this issue or not but i'll add them here and if you want a new issue, I can move them.
This seems like a timeout. I would think this just retries?
Failed to sync device state
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('10.100.1.143', 80)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/dahua/__init__.py", line 285, in _async_update_data
light_v2 = await self.client.async_get_lighting_v2()
File "/config/custom_components/dahua/client.py", line 147, in async_get_lighting_v2
return await self.get(url)
File "/config/custom_components/dahua/client.py", line 671, in get
raise exception
File "/config/custom_components/dahua/client.py", line 656, in get
response = await auth.request("GET", url)
File "/config/custom_components/dahua/digest.py", line 46, in request
response = await self.session.request(method, url, headers=headers, **kwargs)
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.100.1.143:80 ssl:default [Connect call failed ('10.100.1.143', 80)]
After the above timeout, I see this which is most likely related but again I hope this retries.
Logger: custom_components.dahua
Source: helpers/update_coordinator.py:219
Integration: Dahua (documentation, issues)
First occurred: 3:27:38 PM (1 occurrences)
Last logged: 3:27:38 PM
Error fetching dahua data:
Then I received the 'failed to read data' at some point after but it may be a completely different issue and likely unrelated:
Failed to read data: b' \x00\x00\x00DHIPTwdn\x08\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10477,"EventSeq":262,"FrameSequence":3703249,"GroupID":262,"LocaleTime":"2022-01-26 15:29:19","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIPTwdn\x08\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10479,"EventSeq":264,"FrameSequence":3704194,"GroupID":264,"LocaleTime":"2022-01-26 15:31:23","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox"', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIPTwdn\x08\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00s\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10479,"EventSeq":264,"FrameSequence":3704194,"GroupID":264,"LocaleTime":"2022-01-26 15:31:55","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIPTwdn\x08\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00t\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10481,"EventSeq":266,"FrameSequence":3711143,"GroupID":266,"LocaleTime":"2022-01-26 15:49:11","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox"', error: substring not found, Line: 348
Failed to read data: b' \x00\x00\x00DHIPTwdn\x08\x00\x00\x00r\x04\x00\x00\x00\x00\x00\x00r\x04\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":10483,"EventSeq":268,"FrameSequence":3711209,"GroupID":268,"LocaleTime":"2022-01-26 15:49:53","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":[744,2832,3496,8160],"CarrierBag":0,"Center":[2120,5496],"Confidence":0,"DownClothes":0,"Express":0,"FaceFlag":0,"FaceRect":[0,0,0,0],"FrameSequence":3711209,"Gender":0,"Glass":0,"HairStyle":0,"HasHat":0,"Helmet":0,"HumanRect":[0,0,0,0],"LowerBodyColor":[0,0,0,0],"MainColor":[0,0,0,0],"MessengerBag":0,"ObjectID":667,"ObjectType":"Human","Phone":0,"RelativeID":0,"SerialUUID":"","ShoulderBag":0,"Source":0.0,"Speed":0,"SpeedTypeInternal":0,"Umbrella":0,"UpClothes":0,"UpperBodyColor":[0,0,0,0],"UpperPattern":0}', error: Expecting ',' delimiter: line 1 column 993 (char 992), Line: 350
I setup a ping monitor in HA to understand if the device is having connection issues but in the past 24 hours, there were zero issues. Signal is strong. After some time, I find my bell and motion is no longer alerting HA and I have a job to restart the integration to get it fixed up again.
Another comment. When the errors appear above, the integration motion detection and doorbell presses are non-functional. I need to restart the integration to get it working again.
action:
- service: homeassistant.reload_config_entry
data:
entry_id: 37a185xxxxxxxxxxxxxxx049d9xxxxxed1
target:
entity_id: binary_sensor.front_doorbell_button_pressed
For others experiencing this, this is now what I've added to an automation to restart it.
configuration.yaml:
system_log:
fire_event: true
automation:
alias: Dahua Reload
description: ''
trigger:
- platform: event
event_type: system_log_event
condition:
- condition: template
value_template: >-
{{ "Error fetching dahua data" in trigger.event.data.message[0] or
"TimeoutError fetching information from http" in
trigger.event.data.message[0] }}
- condition: template
value_template: >-
{{ (as_timestamp(now(),0) -
as_timestamp(state_attr('automation.dahua_reload','last_triggered'),200) )
> 180 }}
action:
- service: homeassistant.reload_config_entry
data:
entry_id: 37a185eaaaaaaaaaaa9d9cffed1
target:
entity_id: binary_sensor.front_doorbell_button_pressed
mode: single
Are you on the latest version of the integration?
Sorry, I see that you are. 0.9.34
I'm going to see if I can reproduce this. Thanks for the report.
I was able to reproduce this and found the bug with the parsing of the AD410 events.
It's fixed in 0.9.35
https://github.com/rroller/dahua/releases/tag/0.9.35
That didn't seem to fully fix this issue. I'm still digging in.
I've made some better handling of the event data in https://github.com/rroller/dahua/releases/tag/0.9.37
I thought I could reproduce this issue, but I can't. I let mine run for days :/
I'll install the latest, stop by auto-restarting automation and see if I can capture something.
This is still happening to me. At some point motion detection stops, the ringing of the bell stops alerting and functioning and I see these errors in the logs.
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"RtspSessionState","Data":{"Device":"10.100.1.183","LocaleTime":"2022-02-25 10:12:45","Port":44394,"SessionId":"1741237864''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":15369,"EventSeq":5154,"FrameSequence":21293825,"GroupID":5154,"LocaleTime":"2022-02-25 10:13:51","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingB''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","C''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"NTPAdjustTime","Data":{"Address":"200.160.0.8","Before":"2022-02-25 11:22:21","LocaleTime":"2022-02-25 11:22:22","UTC":16''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"TimeChange","Data":{"BeforeModifyTime":"2022-02-25 11:37:22","LocaleTime":"2022-02-25 11:37:22","ModifiedTime":"2022-02-2''
Failed to read data: b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-02-25 09:44:40","State":4,"UTC":1645800280.0},"Index":-1}]},"session":1832205550', error: Expecting ',' delimiter: line 1 column 204 (char 203), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-02-25 09:44:55","State":4,"UTC":1645800295.0},"Index":-1}]},"session":1832205550', error: Expecting ',' delimiter: line 1 column 204 (char 203), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe8\x00\x00\x00\x00\x00\x00\x00\xe8\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"IntelliFrame","Data":{"Action":"Start","LocaleTime":"2022-02-25 09:45:23","UTC":1645800323.0},"Index":0}]},"session":1832', error: Expecting ',' delimiter: line 1 column 210 (char 209), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe8\x00\x00\x00\x00\x00\x00\x00\xe8\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"IntelliFrame","Data":{"Action":"Start","LocaleTime":"2022-02-25 10:13:51","UTC":1645802031.0},"Index":0}]},"session":1832', error: Expecting ',' delimiter: line 1 column 210 (char 209), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CallNoAnswered","Data":{"CallID":"3","LocaleTime":"2022-02-25 10:18:56","UTC":1645802336.0},"Index":0}]},"session":183220', error: Expecting ',' delimiter: line 1 column 208 (char 207), Line: 356
All seems well for like hours.
2022-02-25 05:32:54 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.395 seconds (success: True)
2022-02-25 05:33:09 DEBUG (Thread-1332) [custom_components.dahua] Keep alive
2022-02-25 05:33:09 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m~\x02\x00\x00F\x00\x00\x00\x00\x00\x00\x00F\x00\x00\x00\x00\x00\x00\x00{"id":638,"params":{"timeout":55},"result":true,"session":1832205550}\n''
2022-02-25 05:33:26 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 2.274 seconds (success: True)
2022-02-25 05:34:04 DEBUG (Thread-1333) [custom_components.dahua] Keep alive
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xea\x00\x00\x00\x00\x00\x00\x00\xea\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","''
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'Code":"APConnect","Data":{"LocaleTime":"2022-02-25 05:33:58","Type":"Timerconnect","UTC":1645785238.0},"Index":0}]},"session":1832205550}\n \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.n
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Actio''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'n":"Start","Code":"NetAbort","Data":{"Interface":"eth2","LocaleTime":"2022-02-25 05:34:03","UTC":1645785243.0},"Index":2}]},"session":1832205550}\n \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xd8\x00\x00\x00\x00\x00\x00\x00\xd8\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'"Action":"Pulse","Code":"NetworkChange","Data":{"LocaleTime":"2022-02-25 05:34:04","UTC":1645785244.0},"Index":0}]},"session":1832205550}\n \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.n
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action"''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b':"Pulse","Code":"NetChangeNotifyCenter","Data":{"LocaleTime":"2022-02-25 05:34:04","UTC":1645785244.0},"Index":0}]},"session":1832205550}\n \x00\x00\x00DHIP\xee<5m\x7f\x02\x00\x00F\x00\x00\x00\x00\x00\x00\x00F\x00\x00\x00\x00\x00\x00\x00{"id":639,"params":{"timeout":55
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe5\x00\x00\x00\x00\x00\x00\x00\xe5\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","C''
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","C''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'ode":"NetAbort","Data":{"Interface":"eth2","LocaleTime":"2022-02-25 05:34:09","UTC":1645785249.0},"Index":2}]},"session":1832205''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'550}\n \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00d\x01\x00\x00\x00\x00\x00\x00d\x01\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"DHCPv4Success","Data":{"DefaultGateway":"10.100.1.1","DnsServe
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"DHCPv4Success","Data":{"DefaultGateway":"10.100.1.1","DnsServers":["10.100.1.1","0.0.0.0"],"IPAddress":"10.100.1.143''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'","Interface":"eth2","LocaleTime":"2022-02-25 05:34:10","NetMask":"255.255.255.0","UTC":1645785250.0},"Index":0}]},"session":1832205550}\n \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xf2\x00\x00\x00\x00\x00\x00\x00\xf2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.no
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'"Stop","Code":"APConnect","Data":{"LocaleTime":"2022-02-25 05:34:10","Result":true,"SSID":"xxxx-2","UTC":1645785250.0},"Index":''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'0}]},"session":1832205550}\n''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xd8\x00\x00\x00\x00\x00\x00\x00\xd8\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"NetworkChange","Data":{"LocaleTime":"2022-02-25 05:34:10","UTC
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] VTO Data received: {'Action': 'Pulse', 'Code': 'NetworkChange', 'Data': {'LocaleTime': '2022-02-25 05:34:10', 'UTC': 1645785250.0}, 'Index': 0, 'deviceType': 'AD410', 'serialNumber': 'Z177F78A1BBFC', 'DeviceName': 'Front Doorbell'}
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x08\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","''
2022-02-25 05:34:10 ERROR (Thread-4) [custom_components.dahua] Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","''
2022-02-25 05:34:10 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b'Code":"NetChangeNotifyCenter","Data":{"LocaleTime":"2022-02-25 05:34:10","UTC":1645785250.0},"Index":0}]},"session":1832205550}\n''
2022-02-25 05:34:13 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 17.631 seconds (success: True)
2022-02-25 05:34:44 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.781 seconds (success: True)
2022-02-25 05:35:05 DEBUG (Thread-1336) [custom_components.dahua] Keep alive
2022-02-25 05:35:05 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x80\x02\x00\x00F\x00\x00\x00\x00\x00\x00\x00F\x00\x00\x00\x00\x00\x00\x00{"id":640,"params":{"timeout":55},"result":true,"session":1832205550}\n''
2022-02-25 05:35:15 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.273 seconds (success: True)
2022-02-25 05:35:46 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.784 seconds (success: True)
2022-02-25 05:36:00 DEBUG (Thread-1337) [custom_components.dahua] Keep alive
2022-02-25 05:36:00 DEBUG (Thread-4) [custom_components.dahua] Event data 10.100.1.143: 'b' \x00\x00\x00DHIP\xee<5m\x81\x02\x00\x00F\x00\x00\x00\x00\x00\x00\x00F\x00\x00\x00\x00\x00\x00\x00{"id":641,"params":{"timeout":55},"result":true,"session":1832205550}\n''
2022-02-25 05:36:17 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.811 seconds (success: True)
2022-02-25 05:36:48 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.820 seconds (success: True)
Note the 'keep alives' still function. But on events like human detection or dellbell, it spits the errors. Once this happens, I can simply restart the integration and it works perfectly again until it stops. Note the camera itself is always accessible.
service: homeassistant.reload_config_entry
data:
entry_id: xxxxxxxxxxxxxxxxxx9d9cffed1
target:
entity_id: binary_sensor.front_doorbell_button_pressed
I actually wonder if part of the issue here is that we're not enabling all the events the AD410 requires. I can see in the list of events that most are available not no one knows what to select for a particular device. Such as 'BackKeyLight, IntelliFrame, CallNoAnswered are called out above. I deleted the integration today and selected ALL events. Yes that leaves quite a bit of useless entities but I'm going to see what errors I receive now. I assume quite a bit of the noise above will go away but more importantly, I wonder if it will stabilize the integration.
I see no way to actually 'know' which ones are important.
I'm seeing far less errors in the logs. Today it stopped detecting motion and these are the events in my logs:
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Start","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":16131,"EventSeq":5916,"FrameSequence":23212202,"GroupID":5916,"LocaleTime":"2022-02-28 15:42:26","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingB''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4093],[0,8191],[8191,8191],[8191,4093],[8191,0]],"EventID":16131,"EventSeq":5916,"FrameSequence":23212202,"GroupID":5916,"LocaleTime":"2022-02-28 15:42:57","Mark":0,"Name":"IVS-1","Object":{"Action":"Appear","Age":0,"Angle":0,"Bag":0,"BagType":0,"BoundingBox":
Failed to read data: b' \x00\x00\x00DHIP\xde\xc6\x1a2\x08\x00\x00\x00\xe1\x00\x00\x00\x00\x00\x00\x00\xe1\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-02-28 14:41:46","State":4,"UTC":1646077306.0},"Index":-1}]},"session":840615646}\n \x00\x00\x00DHIP\xde\xc6\x1a2\x08\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"IntelliFrame","Data":{"Action":"Stop","LocaleTime":"2022-02-28 14:41:49","UTC":1646077309.0},"Index":0}]},"session":8406', error: Expecting ',' delimiter: line 1 column 209 (char 208), Line: 356
The doorbell button is still functioning just fine but person motion isn't.
Failed to read data: b' \x00\x00\x00DHIP\xde\xc6\x1a2\x08\x00\x00\x00\xe1\x00\x00\x00\x00\x00\x00\x00\xe1\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-02-28 14:41:46","State":4,"UTC":1646077306.0},"Index":-1}]},"session":840615646}\n \x00\x00\x00DHIP\xde\xc6\x1a2\x08\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00\xe6\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"IntelliFrame","Data":{"Action":"Stop","LocaleTime":"2022-02-28 14:41:49","UTC":1646077309.0},"Index":0}]},"session":8406', error: Expecting ',' delimiter: line 1 column 209 (char 208), Line: 356
The doorbell button is still functioning just fine but person motion isn't.
I'm experiencing the same. It seems the second message it receives is not correct json. It seems to be missing the last '}' ?
I am getting this
2022-04-18 17:26:03 DEBUG (Thread-336) [custom_components.dahua] Event data 192.168.1.110: 'b' \x00\x00\x00DHIP\xe2\xfe\xff\x7f\x08\x00\x00\x00\x0f\x01\x00\x00\x00\x00\x00\x00\x0f\x01\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"APConnect","Data":{"Error":"SSIDNotValid","LocaleTime":"2022-04-18 17:26:03","Result":false,"Type":"Timerconnect","UTC":1650291963.0},"Index":0}]},"session":2147483362}\n'' 2022-04-18 17:26:03 DEBUG (Thread-336) [custom_components.dahua] VTO Data received: {'Action': 'Stop', 'Code': 'APConnect', 'Data': {'Error': 'SSIDNotValid', 'LocaleTime': '2022-04-18 17:26:03', 'Result': False, 'Type': 'Timerconnect', 'UTC': 1650291963.0}, 'Index': 0, 'serialNumber': '4G03F5CAAZ2E22A', 'deviceType': 'VTO2111D', 'DeviceName': 'Doorbell'}
This continues to be an issue and makes it VERY unreliable. There is no way to tell that the doorbell push and human detection is no longer working without pushing it. I am finding even re-loading the integtation doesn't fix it. Rebooting HA does though which is interesting.
Posted this to the wrong issue before. Incase you need it here:
Since this is unstable for AD410, I switched for now to the HA native integration and setup events for button, human, motion and this is now working pretty well for those having trouble. I prefer this integration because it has more features but stability is THE concern. I can't have people ringing the bell with the integration not detecting it and requiring me to restart HA.
Config:
amcrest:
- host: 10.100.1.143
username: admin
password: xxxxxx
name: Front Door Bell
resolution: high
stream_source: rtsp
scan_interval: 15
binary_sensors:
- online
switches:
- privacy_mode
- host: 10.100.1.143
username: admin
password: xxxxxxx
name: Front Door Bell Sub
resolution: low
stream_source: rtsp
scan_interval: 305
Template Triggers:
template:
- trigger:
- platform: event
event_type: amcrest
id: start
event_data:
camera: "Front Door Bell"
event: CrossRegionDetection
payload:
code: CrossRegionDetection
action: Start
data:
Action: Appear
object:
ObjectType: Human
- platform: event
event_type: amcrest
id: stop
event_data:
camera: "Front Door Bell"
event: CrossRegionDetection
payload:
code: CrossRegionDetection
action: Stop
data:
Action: Appear
object:
ObjectType: Human
binary_sensor:
- name: Front Door Bell Human
icon: mdi:motion-sensor
state: >-
{{ 'on' if trigger.id == 'start' else 'off' }}
- trigger:
- platform: event
event_type: amcrest
id: start
event_data:
camera: "Front Door Bell"
event: CallNoAnswered
payload:
code: CallNoAnswered
action: Start
- platform: event
event_type: amcrest
id: stop
event_data:
camera: "Front Door Bell"
event: CallNoAnswered
payload:
code: CallNoAnswered
action: Stop
binary_sensor:
- name: Front Door Bell Ring
icon: mdi:doorbell-video
state: >-
{{ 'on' if trigger.id == 'start' else 'off' }}
- trigger:
- platform: event
event_type: amcrest
id: start
event_data:
camera: "Front Door Bell"
event: VideoMotion
payload:
code: VideoMotion
action: Start
data:
Action: Appear
object:
- platform: event
event_type: amcrest
id: stop
event_data:
camera: "Front Door Bell"
event: VideoMotion
payload:
code: VideoMotion
action: Stop
data:
Action: Appear
binary_sensor:
- name: Front Door Bell Motion
icon: mdi:motion
state: >-
{{ 'on' if trigger.id == 'start' else 'off' }}
I'm also getting this:
This error originated from a custom integration.
Logger: custom_components.dahua
Source: custom_components/dahua/vto.py:358
Integration: Dahua (documentation, issues)
First occurred: 6:29:32 AM (86 occurrences)
Last logged: 7:56:40 AM
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"NewFile","Data":{"File":"\\/mnt\\/sd\\/2022-06-30\\/001\\/jpg\\/07\\/54\\/58[M][0@0][1].jpg","LocaleTime":"2022-06-30 07:54:59","''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"TimeChange","Data":{"BeforeModifyTime":"2022-06-30 07:55:21","LocaleTime":"2022-06-30 07:55:21","ModifiedTime":"2022-06-3''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"NTPAdjustTime","Data":{"Address":"200.160.0.8","Before":"2022-06-30 07:55:20","LocaleTime":"2022-06-30 07:55:21","UTC":16''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"CrossRegionDetection","Data":{"Action":"Appear","CfgRuleId":1,"Class":"Normal","CountInGroup":0,"DetectRegion":[[0,0],[0,4''
Malformed or truncated message returned from device '{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"NewFile","Data":{"File":"\\/mnt\\/sd\\/2022-06-30\\/001\\/jpg\\/07\\/56\\/39[F][0@0][0].jpg","LocaleTime":"2022-06-30 07:56:39","''
and:
This error originated from a custom integration.
Logger: custom_components.dahua
Source: custom_components/dahua/vto.py:361
Integration: Dahua (documentation, issues)
First occurred: 6:29:32 AM (18 occurrences)
Last logged: 7:54:58 AM
Failed to read data: b' \x00\x00\x00DHIP\xb9\xb4\xcd?\x08\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-06-30 07:36:45","State":4,"UTC":1656596205.0},"Index":-1}]},"session":1070445753', error: Expecting ',' delimiter: line 1 column 204 (char 203), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xab|\xb6u\x08\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-06-30 07:36:45","State":4,"UTC":1656596205.0},"Index":-1}]},"session":1974893739', error: Expecting ',' delimiter: line 1 column 204 (char 203), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xab|\xb6u\x08\x00\x00\x00\xf7\x00\x00\x00\x00\x00\x00\x00\xf7\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"VideoMotion","Data":{"Id":[0],"LocaleTime":"2022-06-30 07:37:25","RegionName":["Region1"],"UTC":1656596245.0},"Index":0}]}', error: Expecting ',' delimiter: line 1 column 225 (char 224), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xb9\xb4\xcd?\x08\x00\x00\x00\xf7\x00\x00\x00\x00\x00\x00\x00\xf7\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Stop","Code":"VideoMotion","Data":{"Id":[0],"LocaleTime":"2022-06-30 07:37:25","RegionName":["Region1"],"UTC":1656596245.0},"Index":0}]}', error: Expecting ',' delimiter: line 1 column 225 (char 224), Line: 356
Failed to read data: b' \x00\x00\x00DHIP\xb9\xb4\xcd?\x08\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00\xe2\x00\x00\x00\x00\x00\x00\x00{"id":8,"method":"client.notifyEventStream","params":{"SID":513,"eventList":[{"Action":"Pulse","Code":"BackKeyLight","Data":{"LocaleTime":"2022-06-30 07:54:58","State":4,"UTC":1656597298.0},"Index":-1}]},"session":1070445753', error: Expecting ',' delimiter: line 1 column 204 (char 203), Line: 356
Can you please try the latest version 0.9.43?
I added a better JSON extractor that will handle extracting multiple JSON elements from a string and handle multi line elements
https://github.com/rroller/dahua/releases/tag/0.9.43