JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
1.07k stars 85 forks source link

Siren on TAPO C225 not working #641

Open biopixen opened 1 month ago

biopixen commented 1 month ago

Description

When installed and configured in Home Assistant Core 2024.7.3 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240710.0 Running Tapo: Cameras Control version 5.5.4

Clicking the Siren Button generates the following errormessage: _Failed to call service siren/turnon. argument of type 'bool' is not iterable

No Siren noise is heard.

Reproduction Steps

1: Go to Settings 2: Click in Devices & services 3: Click on Tapo: Cameras Control 4: Click on the device 5: Click on the toggle button to the right of the Siren icon under Controls

Expected behavior

Expected the sirent to start from the camera.

If applicable, add error logs.

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/commands.py:241 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 15:59:09 (8 occurrences) Last logged: 16:30:27

[139916973195472] Unexpected exception [139916777598992] Unexpected exception [139916775776336] Unexpected exception [139917640346800] Unexpected exception [139916861052320] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/siren/init.py", line 121, in async_handle_turn_on_service await siren.async_turn_on( File "/config/custom_components/tapo_control/siren.py", line 115, in async_turn_on if result_has_error(result) and result_has_error(result2): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/siren.py", line 174, in result_has_error "result" in result TypeError: argument of type 'bool' is not iterable

Device Firmware

1.0.4 Build 230901 Rel.66926n

Integration Version

5.5.4

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Running on a Dedicated Linux Laptop

Search for similar issues

Yes

Additional information

Developer Tools

Tapo_C225_D8AB Siren | off | friendly_name: Tapo_C225_D8AB Siren supported_features: 19 I have tried Reconfigured the device and enabled Webhooks but with same result and errormessage.
JurajNyiri commented 1 month ago

Could you please enable debug logs and post the log here?

biopixen commented 1 month ago

Hi! Thank you for a quick reply. I have uploaded the debug log and am pasting in the last information that might be of interest:

_2024-07-23 20:30:09.265 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] New request: 2024-07-23 20:30:09.265 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] {'data': {'method': 'do', 'msg_alarm': {'manual_msg_alarm': {'action': 'start'}}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 2024-07-23 20:30:09.419 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] 200 2024-07-23 20:30:09.419 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] {'error_code': -40106} 2024-07-23 20:30:09.420 DEBUG (MainThread) [custom_components.tapo_control] Error: Parameter to get/do does not exist, Response: {"error_code": -40106} 2024-07-23 20:30:09.421 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] New request: 2024-07-23 20:30:09.421 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] {'data': {'method': 'multipleRequest', 'params': {'requests': [{'method': 'setSirenStatus', 'params': {'msg_alarm': {'status': 'on'}}}]}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8'}, 'verify': False} 2024-07-23 20:30:09.545 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] 200 2024-07-23 20:30:09.546 DEBUG (SyncWorker_25) [custom_components.tapo_control] [pytapo] {'result': {'responses': [{'method': 'setSirenStatus', 'result': {}, 'error_code': -40210}]}, 'error_code': 0} 2024-07-23 20:30:09.547 DEBUG (MainThread) [custom_components.tapo_control] Error: Function not supported, Response: {"method": "setSirenStatus", "result": {}, "error_code": -40210} 2024-07-23 20:30:09.547 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139916632345040] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/siren/init.py", line 121, in async_handle_turn_on_service await siren.async_turn_on( File "/config/custom_components/tapo_control/siren.py", line 115, in async_turn_on if result_has_error(result) and result_has_error(result2): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/siren.py", line 174, in result_haserror "result" in result TypeError: argument of type 'bool' is not iterable

home-assistant_tapo_control_2024-07-23T18-30-10.857Z.log

JurajNyiri commented 1 month ago

Thank you, 2 more questions:

biopixen commented 1 month ago

Hi! Sure! 1: Unclear. I have not used a previous version of the integration. I got two cameras 2 days ago a 225 and a 120. Installed the latest versions etc. The only think i have NOT done is to upgrade the firmware on the camera as I'm cautions to do that in case there are anything that breaks. Internet access for/to the cameras have been blocked.

2: Yes. But there is no "click here and trigger the siren". I played with the app and i believe the app requires two things to trigger a siren alert.

In my testing i turned the motion detection ON and then the alarm ON. After moving in front of the camera the siren rang.

JurajNyiri commented 1 month ago

I checked the logs, there is nothing different about it that I can see that would help me determine whether the camera supports the trigger or not. Officially it is not supported on any cameras, but it does work on some.

Please download https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/tree/5.6.1 manually, it should behave similarly, but now go to disabled state for a while once clicked and throw a nicer meaningful error message.

@biopixen Please let me know if it works and I can release this.

JurajNyiri commented 3 weeks ago

Hi @biopixen any luck testing this?

biopixen commented 3 weeks ago

HI @JurajNyiri back from an extended vacation. Unfortunately i had to return the camera and am not able to continue the testing and verification. Thank you again for your support and commitment to solving the issue.

IzzIsHOr commented 3 weeks ago

Issue still exists on C225 by TP-Link Firmware: 1.0.29 Build 240522 Rel.74568n

Failed to perform the action siren/turn_on. argument of type 'bool' is not iterable

JurajNyiri commented 3 weeks ago

@IzzIsHOr make sure to update to the latest version and post full error message please from logs

KlumzyKlein commented 3 weeks ago

I get the same error as @IzzIsHOr - "Failed to perform the action siren/turn_on. argument of type 'bool' is not iterable".

On Version 5.6.1 Camera is 1.0.29 Build 240123 Rel.74249n

Log shows:

[140443684190768] Unexpected exception [140443683350432] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/siren/__init__.py", line 121, in async_handle_turn_on_service await siren.async_turn_on( File "/config/custom_components/tapo_control/siren.py", line 115, in async_turn_on if result_has_error(result) and result_has_error(result2): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/siren.py", line 186, in result_has_error if "error_code" not in result or result["error_code"] == 0: ^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'bool' is not iterable

Removing the line

`#if "error_code" not in result or result["error_code"] == 0:

return False`

gives me the error:

File "/usr/src/homeassistant/homeassistant/components/siren/__init__.py", line 121, in async_handle_turn_on_service await siren.async_turn_on( File "/config/custom_components/tapo_control/siren.py", line 117, in async_turn_on raise Exception("Camera does not support triggering the siren.") Exception: Camera does not support triggering the siren.

To make sure, I manually tested the alarm in the Tapo App and seems to work fine.

Changing the Alarm Type in the App changes the Siren Type correctly in Home Assistant. Same for the Siren Volume.

I have a similar issue with my C120 (1.1.15 Build 240516 Rel.68711n). Changing the Alarm Type / Alarm Volume in the App changes the relevant values in Home Assistant, however in this case there is no toggle exposed in Home Assistant to trigger the Siren. Let me know if you want me to raise a separate bug for that one.

masfernandez commented 1 week ago

Same error here, all details below:

Core 2024.8.3 Supervisor 2024.08.0 Operating System 13.1 Frontend 20240809.0 Tapo: 5.6.1 Camera: C520WS 1.0, firmware 1.2.8 build 240606 rel 39146n

Logs:

2024-08-25 19:05:45.836 DEBUG (SyncWorker_20) [custom_components.tapo_control] [pytapo] New request: 2024-08-25 19:05:45.836 DEBUG (SyncWorker_20) [custom_components.tapo_control] [pytapo] {'data': {'method': 'securePassthrough', 'params': {'request': '<deleted for security, if needed please tell me>'}}, 'headers': {'Host': 'REDACTED', 'Referer': 'REDACTED', 'Accept': 'application/json', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Tapo CameraClient Android', 'Connection': 'close', 'requestByApp': 'true', 'Content-Type': 'application/json; charset=UTF-8', 'Seq': '383', 'Tapo_tag': 'REDACTED'}, 'verify': False} 2024-08-25 19:05:46.069 DEBUG (SyncWorker_20) [custom_components.tapo_control] [pytapo] 200 2024-08-25 19:05:46.069 DEBUG (SyncWorker_20) [custom_components.tapo_control] [pytapo] {'seq': 383, 'result': {'response': '<deleted for security, if needed please tell me>'}, 'error_code': 0} 2024-08-25 19:05:46.070 DEBUG (MainThread) [custom_components.tapo_control] Error: Function not supported, Response: {"method": "setSirenStatus", "result": {}, "error_code": -40210} 2024-08-25 19:05:46.071 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140238171157504] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/siren/__init__.py", line 121, in async_handle_turn_on_service await siren.async_turn_on( File "/config/custom_components/tapo_control/siren.py", line 115, in async_turn_on if result_has_error(result) and result_has_error(result2): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/tapo_control/siren.py", line 186, in result_has_error if "error_code" not in result or result["error_code"] == 0: ^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: argument of type 'bool' is not iterable

Siren enabled from Tap App working OK. Don't know if siren was working on other versions, just installed everything

Regards. MA