xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
366 stars 39 forks source link

[Bug]: Camera TSL-CAM-B200 keeps rebooting when added #314

Closed pduchnovsky closed 1 week ago

pduchnovsky commented 1 month ago

LocalTuya Version

2024.7.0

Home Assistant Version

2024.7.3

Environment

What happened?

When this camera is added to localtuya, it goes in to reboot loop it seems, this started happening with version 2024.6.0 but does not happen with version 2024.5.0.

Steps to reproduce.

Add the camera to localtuya via autodiscovery or just use existing camera and upgrade the localtuya from 2024.5.0 to 2024.6.0 or 2024.7.0

Relevant log output

2024-07-25 13:39:02.643 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:02.725 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Success: connected to: 10.10.56.15
2024-07-25 13:39:02.729 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Reconnect succeeded on attempt: 8
2024-07-25 13:39:03.413 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bfa...suu - Pestúnka (cam)] Connection lost: [Errno 104] Connection reset by peer
2024-07-25 13:39:03.418 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:03.433 WARNING (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Connection failed: [Errno 111] Connect call failed ('10.10.56.15', 6668)
2024-07-25 13:39:06.418 INFO (SyncWorker_48) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Disconnected due to: [Errno 104] Connection reset by peer
2024-07-25 13:39:08.434 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:13.448 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:18.465 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:23.489 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:28.507 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:33.521 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:36.522 WARNING (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Connection failed: [Errno 113] Host is unreachable ('10.10.56.15', '6668')
2024-07-25 13:39:41.523 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:49.526 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:49.624 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Success: connected to: 10.10.56.15
2024-07-25 13:39:49.628 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Reconnect succeeded on attempt: 8
2024-07-25 13:39:50.333 DEBUG (MainThread) [custom_components.localtuya.core.pytuya] [bfa...suu - Pestúnka (cam)] Connection lost: [Errno 104] Connection reset by peer
2024-07-25 13:39:50.334 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...
2024-07-25 13:39:50.349 WARNING (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Connection failed: [Errno 111] Connect call failed ('10.10.56.15', 6668)
2024-07-25 13:39:53.336 INFO (SyncWorker_2) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Disconnected due to: [Errno 104] Connection reset by peer
2024-07-25 13:39:55.351 DEBUG (MainThread) [custom_components.localtuya.coordinator] [bfa...suu - Pestúnka (cam)] Trying to connect to: 10.10.56.15...

Diagnostics information.

No response

xZetsubou commented 1 month ago

can you post the device diagnostics

github-actions[bot] commented 1 month ago

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

pduchnovsky commented 1 month ago

So I tried it again, updated version to newest and tried adding the camera again, now it even fails to configure at all.

Began adding the cam, defined manual DPSs, gathered from tuya portal using this guide https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html#_8-find-your-data-point:

101,103,104,105,106,108,109,110,111,115,116,117,119,134,136,138,139,140,141,142,143,150,151,154,160,161,167,168,169,185,212,231,232,233,234,235,236,237,238,239,240,253,254,255

After confirming discovery it gets in to error

image

no device is added and tuyalocal can no longer be started, debug log:

2024-08-11 13:06:36.437 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry localtuya for localtuya
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/__init__.py", line 362, in async_setup_entry
    await setup_entities(entry.data[CONF_DEVICES])
  File "/config/custom_components/localtuya/__init__.py", line 327, in setup_entities
    if check_if_device_disabled(hass, entry, dev_id):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/__init__.py", line 464, in check_if_device_disabled
    return dr.async_get(hass).async_get(ha_device_id).disabled
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'disabled'

The device is also not visible (should be 5th device, only shows 4), can not be removed and thus entire tuyalocal becomes stuck,broken

Btw, full list of DP IDs:

{
  "101": "Indicator",
  "103": "Vision Flip",
  "104": "OSD Watermark",
  "105": "Private Mode",
  "106": "Motion Sensitivity",
  "108": "Night Vision",
  "109": "Get Memory Card Capacity",
  "110": "Memory Card Status",
  "111": "Format Memory Card",
  "115": "Motion Detected",
  "116": "PTZ Stop",
  "117": "Formatted State",
  "119": "PTZ Direction",
  "134": "Motion Alert",
  "136": "Doorbell Active",
  "138": "Light Switch",
  "139": "Sound Detection Switch",
  "140": "Sound Sensitivity",
  "141": "Sound Detected",
  "142": "Temperature",
  "143": "Humidity",
  "150": "Record Switch",
  "151": "Recording Mode",
  "154": "Doorbell Snapshot",
  "160": "Device Volume Control",
  "161": "Motion Tracking Switch",
  "167": "Cry Detection Switch",
  "168": "Motion Area Switch",
  "169": "Motion Area",
  "185": "Alarm Report",
  "212": "Message",
  "231": "摇篮曲",
  "232": "摇篮曲模式",
  "233": "摇篮曲音量",
  "234": "摇篮曲控制",
  "235": "music 1",
  "236": "摇篮曲播放指令",
  "237": "检测到婴儿哭声",
  "238": "彩光控制",
  "239": "light mode",
  "240": "floodlight mode",
  "253": "密码修改",
  "254": "onvif IP上报",
  "255": "onvif switch"
}
pduchnovsky commented 1 month ago

Meanwhile I've resolved my problem, took the config from version 2024.5 and just removed all the DPS entries I was not utilizing, leaving only few, seems some of those were causing the problem, now it runs fine with newest version and I can control what I want on the camera via localtuya. (most important for me is enabling onvif and PTZ control)

{
    "101": "Indicator",
    "104": "OSD Watermark",
    "105": "Private Mode",
    "108": "Night Vision",
    "116": "PTZ Stop",
    "119": "PTZ Direction",
    "139": "Sound Detection Switch",
    "255": "onvif switch"
}
xZetsubou commented 1 month ago

for now you can fix this manually by going to custom_integrations/localtuya/__init__.py and remove the two lines 327 and 328

github-actions[bot] commented 1 week ago

This issue was closed because it was resolved on the release: 2024.9.0