dchesterton / amcrest2mqtt

Expose all events from an Amcrest device to an MQTT broker
https://hub.docker.com/r/dchesterton/amcrest2mqtt
MIT License
150 stars 36 forks source link

Error on Human detected #67

Open anacozero opened 2 years ago

anacozero commented 2 years ago

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'
frustreermeneer commented 2 years ago

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

tehbra1n commented 2 years ago

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

tehbra1n commented 2 years ago

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: @.***>

rb2k commented 2 years ago

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

DayRunner131 commented 2 years ago

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.

jweston2112 commented 2 years ago

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

unixorn commented 2 years ago

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.

carefulcomputer commented 2 years ago

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 commented 2 years ago

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

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

MYeager1967 commented 5 months ago

If anyone cares, I've updated this and added an option to capture IVS events. The image is available at myeager1967/amcrest2mqtt:1.0.17.

I also updated the amcrest library and slugify. The mqtt client (paho) is a bit more involved. I will eventually put this up on my GitHub page.