JurajNyiri / HomeAssistant-Tapo-Control

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

Event entity is not created #676

Open tomasbedrich opened 1 month ago

tomasbedrich commented 1 month ago

Description

Event entity is not created

Reproduction Steps

Setup according to default install procedure with C325WB.

Event integration using Webhook / long-polling: doesn't matter - the same result.

Expected behavior

Event entity should be automatically created when motion is detected for the first time (as per README)

If applicable, add error logs.

2024-09-16 12:02:32.201 DEBUG (MainThread) [custom_components.tapo_control] [initOnvifEvents] Creating onvif connection...
2024-09-16 12:02:32.252 DEBUG (MainThread) [custom_components.tapo_control] [initOnvifEvents] Connection estabilished.
2024-09-16 12:02:32.253 DEBUG (MainThread) [custom_components.tapo_control] [initOnvifEvents] Getting device information...
2024-09-16 12:02:32.274 DEBUG (MainThread) [custom_components.tapo_control] [initOnvifEvents] Got device information.
2024-09-16 12:02:32.274 DEBUG (MainThread) [custom_components.tapo_control] setupOnvif - entry
2024-09-16 12:02:32.274 DEBUG (MainThread) [custom_components.tapo_control] Setting up onvif...
2024-09-16 12:02:32.274 DEBUG (MainThread) [custom_components.tapo_control] setupEvents - entry
2024-09-16 12:02:32.275 DEBUG (MainThread) [custom_components.tapo_control] Detected base_url schema: http
2024-09-16 12:02:32.275 DEBUG (MainThread) [custom_components.tapo_control] Detected base_url schema: http
2024-09-16 12:02:32.276 DEBUG (MainThread) [custom_components.tapo_control] Using HTTPS: False
2024-09-16 12:02:32.276 DEBUG (MainThread) [custom_components.tapo_control] Webhook enabled: True
2024-09-16 12:02:32.276 DEBUG (MainThread) [custom_components.tapo_control] Using Webhooks: True
2024-09-16 12:02:32.276 DEBUG (MainThread) [custom_components.tapo_control] Setting up events...
2024-09-16 12:02:32.276 DEBUG (MainThread) [custom_components.tapo_control] WSPullPointSupport: True
...
2024-09-16 12:02:36.893 DEBUG (MainThread) [custom_components.tapo_control] Creating binary sensor entity.
2024-09-16 12:02:36.897 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/tapo_control/utils.py", line 1374, in update_listener
    await setupOnvif(hass, entry)
  File "/config/custom_components/tapo_control/utils.py", line 1431, in setupOnvif
    hass.data[DOMAIN][entry.entry_id]["eventsSetup"] = await setupEvents(
                                                       ^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo_control/utils.py", line 1467, in setupEvents
    ].createBinarySensor()
      ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo_control/binary_sensor.py", line 188, in createBinarySensor
    for event in events.get_platform("binary_sensor")
                 ^^^^^^^^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'get_platform'

Device Firmware

1.1.17 build 240529 rel.57938n

Integration Version

5.6.1

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Home Assistant Green

Search for similar issues

Yes

Additional information

Cam IP: 192.168.1.190, Home Assistant IP: 192.168.1.2, local HTTP without TLS, on the same subnet

JurajNyiri commented 2 days ago

The code outputing this error should be impossible to reach as the events is checked previously before this function is executed. It might happen if just before this function is executed the camera ends a connection in theory.

Is the onvif connection used by any other service - is there anything else interacting with camera apart from one HA instance?

tomasbedrich commented 2 days ago

Only the official Tapo app + Home Assistant. In Home Assistant, there are two integrations interacting with the camera: WebRTC and this integration. The WebRTC integration is set up using tapo:// protocol (docs).