SecKatie / ha-wyzeapi

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

[Bug] PlugIn should wrap error to native HomeAssistant error to support 'continue_on_error' #559

Open Abba- opened 3 months ago

Abba- commented 3 months ago

Describe the bug

Without being able to dive into the code, I'm making a bit of an assumption here. I'm assuming that this plugin throws a generic error (vs a HomeAssistant specific error) when something isnt as expected.

HomeAssistant continue_on_error only handles HomeAsssistant specific errors. Sample discussion and 2.

So if any error happens (which can be a separate report, I seem to sometime get an error even though an action was successful), currently the whole script stops instead of being able to be 'caught' by HomeAssistant and continuing.

Sample error:

2024-03-20 14:38:41.564 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140589164157248] {'code': '3005', 'ts': 1710959921516, 'msg': 'property only set by main user', 'data': {}, 'traceId': 'aae52bcd55cf61a9a334226aa00c2c6d'}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2319, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 905, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/wyzeapi/switch.py", line 334, in async_turn_on
    await self._service.turn_on_notifications(self._device)
  File "/usr/local/lib/python3.12/site-packages/wyzeapy/services/camera_service.py", line 123, in turn_on_notifications
    await self._set_property(camera, PropertyIDs.NOTIFICATION.value, "1")
  File "/usr/local/lib/python3.12/site-packages/wyzeapy/services/base_service.py", line 359, in _set_property
    check_for_errors_standard(response_json)
  File "/usr/local/lib/python3.12/site-packages/wyzeapy/utils.py", line 84, in check_for_errors_standard
    raise UnknownApiError(response_json)

### (There is currently workaround by calling things script.turn_on)

neilbrookins commented 3 months ago

I’ve run into this too. It causes problems when the failure is minor and non fatal, and the automation then fails to run the next step in a sequence that may be a very critical important step. So, I’m agreeing this is an important improvement.

github-actions[bot] commented 2 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.

Abba- commented 2 months ago

Voting for this to be kept open...

github-actions[bot] commented 1 month 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 1 month ago

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

Abba- commented 1 month ago

Can we unstale ?

brg468 commented 1 month ago

I’ll reopen, it would be a nice improvement. Can’t say anyone will get to it anytime soon but it’s worth keeping as a a feature request/enhancement IMHO.

github-actions[bot] commented 3 days 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.

kaovilai commented 3 days ago

unstale