amcrest2mqtt icon indicating copy to clipboard operation
amcrest2mqtt copied to clipboard

Error on Human detected

Open anacozero opened this issue 3 years ago • 10 comments

Getting an error on latest version when a human is detected by amcrest doorbell.

25/03/2022 22:06:09 [INFO] App Version: 1.0.16
25/03/2022 22:06:09 [INFO] Fetching camera details...
25/03/2022 22:06:14 [INFO] Device type: AD410
25/03/2022 22:06:14 [INFO] Serial number: REDACTED
25/03/2022 22:06:14 [INFO] Software version: 1.000.0000000.7.R (2021-02-20)
25/03/2022 22:06:14 [INFO] Device name: Front Door
25/03/2022 22:06:15 [INFO] Writing Home Assistant discovery config...
25/03/2022 22:06:15 [INFO] Fetching storage sensors...
25/03/2022 22:06:15 [INFO] Listening for events...
25/03/2022 22:08:46 [INFO] {'Code': 'TimeChange', 'action': 'Pulse', 'index': '0', 'data': {'BeforeModifyTime': '2022-03-25 05:08:46', 'ModifiedTime': '2022-03-25 05:08:46'}}
25/03/2022 22:08:46 [INFO] {'Code': 'NTPAdjustTime', 'action': 'Pulse', 'index': '0', 'data': {'Address': '200.160.0.8', 'Before': '2022-03-25 05:08:45', 'result': True}}
25/03/2022 22:09:41 [INFO] {'Code': 'VideoMotionInfo', 'action': 'State', 'index': '0'}
25/03/2022 22:09:41 [INFO] {'Code': 'VideoMotion', 'action': 'Start', 'index': '0', 'data': {'Id': [0], 'RegionName': ['Region1']}}
25/03/2022 22:09:42 [INFO] {'Code': 'NewFile', 'action': 'Pulse', 'index': '0', 'data': {'File': '/mnt/sd/2022-03-25/001/jpg/17/09/42[M][0@0][0].jpg', 'Size': 39803, 'StoragePoint': 'NULL'}}
an error occurred during closing of asynchronous generator <async_generator object AsyncClient.stream at 0x7f9eb4040820>
asyncgen: <async_generator object AsyncClient.stream at 0x7f9eb4040820>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/amcrest2mqtt.py", line 426, in main
    elif code == "CrossRegionDetection" and payload["data"]["ObjectType"] == "Human":
KeyError: 'ObjectType'

During handling of the above exception, another exception occurred:

RuntimeError: aclose(): asynchronous generator is already running
an error occurred during closing of asynchronous generator <async_generator object Http.async_stream_command at 0x7f9eb3c9e4c0>
asyncgen: <async_generator object Http.async_stream_command at 0x7f9eb3c9e4c0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/amcrest2mqtt.py", line 426, in main
    elif code == "CrossRegionDetection" and payload["data"]["ObjectType"] == "Human":
KeyError: 'ObjectType'

During handling of the above exception, another exception occurred:

RuntimeError: aclose(): asynchronous generator is already running
an error occurred during closing of asynchronous generator <async_generator object Http._async_stream_command at 0x7f9eb4040790>
asyncgen: <async_generator object Http._async_stream_command at 0x7f9eb4040790>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/amcrest2mqtt.py", line 426, in main
    elif code == "CrossRegionDetection" and payload["data"]["ObjectType"] == "Human":
KeyError: 'ObjectType'

During handling of the above exception, another exception occurred:

RuntimeError: aclose(): asynchronous generator is already running
Traceback (most recent call last):
  File "/app/amcrest2mqtt.py", line 440, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/amcrest2mqtt.py", line 426, in main
    elif code == "CrossRegionDetection" and payload["data"]["ObjectType"] == "Human":
KeyError: 'ObjectType'

anacozero avatar Mar 25 '22 22:03 anacozero

I'm getting the exact same error since yesterday. Same versions, same doorbell. I don't know what changed.

frustreermeneer avatar Mar 26 '22 10:03 frustreermeneer

Same, reverting to previous version of container fixes the issue.

tehbra1n avatar Mar 29 '22 19:03 tehbra1n

image: dchesterton/amcrest2mqtt:1.0.15 is the version I'm running

On Thu, May 5, 2022 at 10:48 AM SMAW @.***> wrote:

Same, reverting to previous version of container fixes the issue.

@tehbra1n https://github.com/tehbra1n To which version did you revert? I have the same issue...

— Reply to this email directly, view it on GitHub https://github.com/dchesterton/amcrest2mqtt/issues/67#issuecomment-1118647692, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEATPH3PZCDA3C3D7ZUESLVIPNU5ANCNFSM5RVN3TAA . You are receiving this because you were mentioned.Message ID: @.***>

tehbra1n avatar May 05 '22 15:05 tehbra1n

Just ran into this as well on 1.0.16, downgrading to 1.0.15 now

rb2k avatar May 06 '22 14:05 rb2k

I had a very similar issue and contacted Amcrest for the current firmware. ...R.20210712 is current for the AD110 and solves these issues. I understood from them that the phone app has a bug and will not show the current firmware, so it has to be manually pushed.

DayRunner131 avatar Aug 05 '22 22:08 DayRunner131

I changed this line in the Docker Container in /app/amcrest2mqtt.py (Not the Image... not really a Docker Guru or a Python Programmer for that matter) (I know if I do another pull it'll overwrite it)

           elif code == "CrossRegionDetection" and payload["data"]["Object"]["ObjectType"] == "Human":

added the ["Object"] and that seems to keep it from crashing. I think the JSON that comes from the Device might have changed in a Firmware update on the AD410

I had to move the Debugger line < log(str(payload)) > that Dumps the JSON to before the above line so I could Parse it and figured out they lump all the info about the "Object" in the camera into an Object Array Object:{ ... } which has the ObjectType Node

Hope that Helps

jweston2112 avatar Aug 05 '22 23:08 jweston2112

I'm seeing the same thing with my Amcrest 410

amcrest2mqtt    | an error occurred during closing of asynchronous generator <async_generator object Http._async_stream_command at 0x7fa9d3adee50>
amcrest2mqtt    | asyncgen: <async_generator object Http._async_stream_command at 0x7fa9d3adee50>
amcrest2mqtt    | Traceback (most recent call last):
amcrest2mqtt    |   File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
amcrest2mqtt    |     return loop.run_until_complete(main)
amcrest2mqtt    |   File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
amcrest2mqtt    |     return future.result()
amcrest2mqtt    |   File "/app/amcrest2mqtt.py", line 426, in main
amcrest2mqtt    |     elif code == "CrossRegionDetection" and payload["data"]["ObjectType"] == "Human":
amcrest2mqtt    | KeyError: 'ObjectType'
amcrest2mqtt    |
amcrest2mqtt    | During handling of the above exception, another exception occurred:
amcrest2mqtt    |
amcrest2mqtt    | RuntimeError: aclose(): asynchronous generator is already running

And thanks btw for publishing a multi-architecture docker image, I'll be able to run it in k3s without restricting it to specific nodes.

unixorn avatar Sep 29 '22 23:09 unixorn

I changed this line in the Docker Container in /app/amcrest2mqtt.py (Not the Image... not really a Docker Guru or a Python Programmer for that matter) (I know if I do another pull it'll overwrite it)

           elif code == "CrossRegionDetection" and payload["data"]["Object"]["ObjectType"] == "Human":

added the ["Object"] and that seems to keep it from crashing. I think the JSON that comes from the Device might have changed in a Firmware update on the AD410

I had to move the Debugger line < log(str(payload)) > that Dumps the JSON to before the above line so I could Parse it and figured out they lump all the info about the "Object" in the camera into an Object Array Object:{ ... } which has the ObjectType Node

Hope that Helps

Thanks ! this worked perfectly.

carefulcomputer avatar Oct 30 '22 16:10 carefulcomputer

Thanks to jweston2112 , i just created a pull request..

https://github.com/dchesterton/amcrest2mqtt/pull/91

carefulcomputer avatar Oct 30 '22 17:10 carefulcomputer