SecKatie / ha-wyzeapi

Home Assistant Integration for Wyze devices.
733 stars 112 forks source link

[Bug] AttributeError: 'Camera' object has no attribute 'motion' - On Wyze CAM OG #496

Closed dinan5 closed 11 months ago

dinan5 commented 1 year ago

Describe the bug I installed two Wyze Cam OG cameras, restarted HA and these cameras throw the follow error: AttributeError: 'Camera' object has no attribute 'motion' 2023-07-26 09:47:59.171 ERROR (MainThread) [homeassistant.util.logging] Exception in handle_camera_update when dispatching 'wyzeapi.camera_updated-GW_GC1_D03F277F46F0': (<Device: DeviceTypes.CAMERA, GW_GC1_D03F277F46F0>,) Traceback (most recent call last): File "/config/custom_components/wyzeapi/switch.py", line 455, in handle_camera_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1233, in state if (is_on := self.is_on) is None: ^^^^^^^^^^ File "/config/custom_components/wyzeapi/switch.py", line 444, in is_on return self._device.motion

To Reproduce Steps to reproduce the behavior:

  1. Install OG camera
  2. Restart HA

Expected behavior Normal camera activation

System configuration System: HA Version: WyzeApi Version:

home-assistant.log

AttributeError: 'Camera' object has no attribute 'motion'
2023-07-26 09:47:59.171 ERROR (MainThread) [homeassistant.util.logging] Exception in handle_camera_update when dispatching 'wyzeapi.camera_updated-GW_GC1_D03F277F46F0': (<Device: DeviceTypes.CAMERA, GW_GC1_D03F277F46F0>,)
Traceback (most recent call last):
File "/config/custom_components/wyzeapi/switch.py", line 455, in handle_camera_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1233, in state
if (is_on := self.is_on) is None:
^^^^^^^^^^
File "/config/custom_components/wyzeapi/switch.py", line 444, in is_on
return self._device.motion
brg468 commented 1 year ago

Probably a duplicate of https://github.com/SecKatie/ha-wyzeapi/issues/488.

I’m guessing the OG cams don’t support motion detection so they need to be excluded like the doorbell cams are. Can you tell me the model number of the camera from the device info in HA?

dinan5 commented 1 year ago

Probably a duplicate of #488.

I’m guessing the OG cams don’t support motion detection so they need to be excluded like the doorbell cams are. Can you tell me the model number of the camera from the device info in HA?

GW_CG1. it supports motion detection. I'm guessing #488 is also a OG cam. Looks like these devices aren't supported yet.

brg468 commented 1 year ago

It must use a different property to indicate motion detection than the rest of the cameras, they always have to do something annoying. Without having one of these cameras I’m not sure how I can easily fix it other than disabling motion detection on those cams, which is more of a bandage than a fix.

dinan5 commented 1 year ago

If there is any log / debug data I can provide, I'm happy to collaborate.

brg468 commented 1 year ago

I was going to look into sharing your cam with my account, but until the auth issue gets resolved I can’t even log into my dev account to try anything. Hopefully that’s resolved soon and then I’ll see what can be done about this.

dinan5 commented 1 year ago

or if you tell me what to look for I can help. Im a retired CIO.

brg468 commented 1 year ago

Basically if you reference the code here, we are looking to find which property reflects motion detection on the camera. There are probably different ways of accomplishing it, my lazy way has been using breakpoints as we poll the data and see what changes when I toggle the switch in the app.

All that being said, motion detection has been pretty unreliable in my experience, except on the V3 cams.

https://github.com/SecKatie/wyzeapy/blob/3dac073d5ae62adf58fe32226bd9a45aa779b88e/src/wyzeapy/types.py#L91

dinan5 commented 1 year ago

Ok will take a look tonight. Thanks

On Jul 26, 2023, at 11:52, Brian Rogers @.***> wrote:



Basically if you reference the code here, we are looking to find which property reflects motion detection on the camera. There are probably different ways of accomplishing it, my lazy way has been using breakpoints as we poll the data and see what changes when I toggle the switch in the app.

https://github.com/SecKatie/wyzeapy/blob/3dac073d5ae62adf58fe32226bd9a45aa779b88e/src/wyzeapy/types.py#L91

— Reply to this email directly, view it on GitHubhttps://github.com/SecKatie/ha-wyzeapi/issues/496#issuecomment-1652090626, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAH6EDNWU5OCF4XD37SIKTXSE4LRANCNFSM6AAAAAA2YUV5EQ. You are receiving this because you authored the thread.Message ID: @.***>

github-actions[bot] commented 12 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 11 months ago

This issue was closed because it has been stalled for 5 days with no activity.

jgibson02 commented 7 months ago

Same issue, here's my error log

2024-01-12 11:45:41.094 ERROR (MainThread) [homeassistant.util.logging] Exception in handle_camera_update when dispatching 'wyzeapi.camera_updated-AN_RSCW_D03F2767BF6A': (<Device: DeviceTypes.CAMERA, AN_RSCW_D03F2767BF6A>,)
Traceback (most recent call last):
  File "/config/custom_components/wyzeapi/switch.py", line 455, in handle_camera_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 999, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 947, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1553, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/wyzeapi/switch.py", line 444, in is_on
    return self._device.motion
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Camera' object has no attribute 'motion'