tuya-local icon indicating copy to clipboard operation
tuya-local copied to clipboard

Button and Scene Switch Randomly detecting events

Open arthurperezbessa opened this issue 2 months ago • 1 comments

Description

Since my issue was closed with no response, I'm opening a new one.

Here is my issue: https://github.com/make-all/tuya-local/issues/3822

And I just realized something — when I set up only one Scene Switch, it works fine. But as soon as I add a second device (or more), it starts detecting this random event. See the log below.

I saw another issue that this happens with a motion sensor from another user.

Something caught my attettion in the log: Recieved async update for wrong CID cc86ecfffe5d6c0c while looking for CID cc86ecfffe0d8c97, trying again

Steps to reproduce

No response

Expected behaviour

No response

Additional context

Device Info:

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2025.8.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.13.3",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Sao_Paulo",
    "os_name": "Linux",
    "os_version": "6.12.34-haos-raspi",
    "container_arch": "aarch64",
    "supervisor": "2025.10.0",
    "host_os": "Home Assistant OS 16.1",
    "docker_version": "28.3.3",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "documentation": "https://hacs.xyz/docs/use/",
      "version": "2.0.5",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "tuya_smart_ir_ac": {
      "documentation": "https://github.com/EnzoD86/tuya-smart-ir-ac",
      "version": "2025.9.2",
      "requirements": []
    },
    "climate_template": {
      "documentation": "https://github.com/jcwillox/hass-template-climate",
      "version": "1.2.0",
      "requirements": []
    },
    "browser_mod": {
      "documentation": "https://github.com/thomasloven/hass-browser_mod/blob/master/README.md",
      "version": "2.5.0",
      "requirements": []
    },
    "climate_group": {
      "documentation": "https://github.com/bjrnptrsn/climate_group",
      "version": "1.0.7",
      "requirements": []
    },
    "localtuya": {
      "documentation": "https://github.com/xZetsubou/hass-localtuya/",
      "version": "2025.7.0",
      "requirements": []
    },
    "ui_lovelace_minimalist": {
      "documentation": "https://ui-lovelace-minimalist.github.io/UI/",
      "version": "v1.3.18",
      "requirements": [
        "aiofiles>=0.8.0",
        "aiogithubapi>=22.2.4"
      ]
    },
    "tuya_local": {
      "documentation": "https://github.com/make-all/tuya-local",
      "version": "2025.9.1",
      "requirements": [
        "tinytuya==1.17.4",
        "tuya-device-sharing-sdk~=0.2.1"
      ]
    },
    "samsungtv_smart": {
      "documentation": "https://github.com/ollo69/ha-samsungtv-smart",
      "version": "0.14.5",
      "requirements": [
        "websocket-client!=1.4.0,>=0.58.0",
        "wakeonlan>=2.0.0",
        "aiofiles>=0.8.0",
        "casttube>=0.2.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "tuya_local",
    "name": "Tuya Local",
    "codeowners": [
      "make-all"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/make-all/tuya-local",
    "integration_type": "device",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/make-all/tuya-local/issues",
    "loggers": [
      "tuya_local",
      "tinytuya"
    ],
    "requirements": [
      "tinytuya==1.17.4",
      "tuya-device-sharing-sdk~=0.2.1"
    ],
    "version": "2025.9.1",
    "is_built_in": false,
    "overwrites_built_in": false
  },
  "setup_times": {
    "null": {
      "setup": 7.155502680689096e-05
    },
    "01K720TF4N3BCTW4FPDZ4Q4R80": {
      "wait_import_platforms": -9.535208735032938,
      "config_entry_setup": 9.684338342980482
    },
    "01K72110ZX49N8MFFX5Z7R8PG4": {
      "config_entry_setup": 21.198600093019195
    },
    "01K7215CVNT65HW7WCBS1P3YB8": {
      "config_entry_setup": 26.41111909900792
    },
    "01K7213M5G5VDYXASD1Q28SV4Y": {
      "config_entry_setup": 31.496232338016853
    },
    "01K7217ZRQFZWBBV3M1TCC508Y": {
      "config_entry_setup": 31.64667421102058
    }
  },
  "data": {
    "name": "Teclado Vladmir",
    "type": "loratap_zigbee_six_switch",
    "device_id": "**REDACTED**",
    "device_cid": "**REDACTED**",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": 3.3,
    "tinytuya_version": "1.17.4",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": true,
    "status": {},
    "cached_state": {
      "updated_at": 1760042206.0426526,
      "1": "single_click",
      "2": "single_click",
      "3": "double_click",
      "4": "single_click",
      "10": 100
    },
    "pending_state": {},
    "connected": true,
    "force_dps": [],
    "home_assistant": {
      "name": "Teclado Vladmir",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_1",
            "state": "2025-10-09T20:26:11.023+00:00",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": "single_click",
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 1"
            },
            "last_changed": "2025-10-09T20:26:11.024961+00:00",
            "last_reported": "2025-10-09T20:29:54.502507+00:00",
            "last_updated": "2025-10-09T20:26:11.024961+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_2",
            "state": "2025-10-09T18:58:08.805+00:00",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": "single_click",
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 2"
            },
            "last_changed": "2025-10-09T18:58:08.807369+00:00",
            "last_reported": "2025-10-09T18:59:43.526743+00:00",
            "last_updated": "2025-10-09T18:58:08.807369+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_3",
            "state": "2025-10-09T18:58:08.805+00:00",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": "double_click",
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 3"
            },
            "last_changed": "2025-10-09T18:58:08.807806+00:00",
            "last_reported": "2025-10-09T18:59:43.526991+00:00",
            "last_updated": "2025-10-09T18:58:08.807806+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_4",
            "state": "2025-10-09T18:58:08.805+00:00",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": "single_click",
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 4"
            },
            "last_changed": "2025-10-09T18:58:08.808301+00:00",
            "last_reported": "2025-10-09T18:59:43.527227+00:00",
            "last_updated": "2025-10-09T18:58:08.808301+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_5",
            "state": "unknown",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": null,
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 5"
            },
            "last_changed": "2025-10-09T18:56:26.990984+00:00",
            "last_reported": "2025-10-09T18:59:43.527435+00:00",
            "last_updated": "2025-10-09T18:56:26.990984+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "button",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "event.teclado_vladmir_button_6",
            "state": "unknown",
            "attributes": {
              "event_types": [
                "single_click",
                "long_press",
                "double_click"
              ],
              "event_type": null,
              "device_class": "button",
              "friendly_name": "Teclado Vladmir Button 6"
            },
            "last_changed": "2025-10-09T18:56:26.993658+00:00",
            "last_reported": "2025-10-09T18:59:43.527637+00:00",
            "last_updated": "2025-10-09T18:56:26.993658+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "battery",
          "icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.teclado_vladmir_battery",
            "state": "100",
            "attributes": {
              "unit_of_measurement": "%",
              "device_class": "battery",
              "friendly_name": "Teclado Vladmir Battery"
            },
            "last_changed": "2025-10-09T18:56:26.946617+00:00",
            "last_reported": "2025-10-09T20:36:46.044540+00:00",
            "last_updated": "2025-10-09T18:56:26.946617+00:00"
          }
        }
      ]
    }
  },
  "issues": []
}

Log:

2025-10-09 15:57:25.680 DEBUG (MainThread) [custom_components.tuya_local.device] Teclado Vladmir persistant connection set to False
2025-10-09 15:57:25.682 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] status() entry (dev_type is default)
2025-10-09 15:57:25.683 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] building command 10 payload=b'{"t":1760036245,"cid":"cc86ecfffe0d8ca2"}'
2025-10-09 15:57:25.688 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:25.689 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013a9c0000000a000000382286da1b430146127d0eee496f74a3a8180d9a9469039ee40e536b950916f398a391cc8703dc5e93cdad1e844dd2e9f47c02666a0000aa55'
2025-10-09 15:57:25.700 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] received data=b'000055aa00013a9c0000000a0000008c0000000008b338dd1390a1609005cc27840d238090acc6942edbdb038d419aa330575fe0eb4bf9ededa5217c1bd9601d712532a5c82d1fa30b1fb2f28e510213939b27b70a20314edd8a30f4dc7ea7ee5ce2794288c98ca380d7faa65bbe494fc120d748d98455d710020b960cf259524c8324786725acf494489eaf2d2d62cd50cd171be26c5af40000aa55'
2025-10-09 15:57:25.701 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] received message=TuyaMessage(seqno=80540, cmd=10, retcode=0, payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xebK\xf9\xed\xed\xa5!|\x1b\xd9`\x1dq%2\xa5\xc8-\x1f\xa3\x0b\x1f\xb2\xf2\x8eQ\x02\x13\x93\x9b'\xb7\n 1N\xdd\x8a0\xf4\xdc~\xa7\xee\\\xe2yB\x88\xc9\x8c\xa3\x80\xd7\xfa\xa6[\xbeIO\xc1 \xd7H\xd9\x84U\xd7\x10\x02\x0b\x96\x0c\xf2YRL\x83$xg%\xac\xf4\x94H\x9e\xaf--b\xcdP\xcd\x17\x1b", crc=3798751988, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:25.704 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] raw unpacked message = TuyaMessage(seqno=80540, cmd=10, retcode=0, payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xebK\xf9\xed\xed\xa5!|\x1b\xd9`\x1dq%2\xa5\xc8-\x1f\xa3\x0b\x1f\xb2\xf2\x8eQ\x02\x13\x93\x9b'\xb7\n 1N\xdd\x8a0\xf4\xdc~\xa7\xee\\\xe2yB\x88\xc9\x8c\xa3\x80\xd7\xfa\xa6[\xbeIO\xc1 \xd7H\xd9\x84U\xd7\x10\x02\x0b\x96\x0c\xf2YRL\x83$xg%\xac\xf4\x94H\x9e\xaf--b\xcdP\xcd\x17\x1b", crc=3798751988, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:25.704 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] decode payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xebK\xf9\xed\xed\xa5!|\x1b\xd9`\x1dq%2\xa5\xc8-\x1f\xa3\x0b\x1f\xb2\xf2\x8eQ\x02\x13\x93\x9b'\xb7\n 1N\xdd\x8a0\xf4\xdc~\xa7\xee\\\xe2yB\x88\xc9\x8c\xa3\x80\xd7\xfa\xa6[\xbeIO\xc1 \xd7H\xd9\x84U\xd7\x10\x02\x0b\x96\x0c\xf2YRL\x83$xg%\xac\xf4\x94H\x9e\xaf--b\xcdP\xcd\x17\x1b"
2025-10-09 15:57:25.704 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] decrypting=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xebK\xf9\xed\xed\xa5!|\x1b\xd9`\x1dq%2\xa5\xc8-\x1f\xa3\x0b\x1f\xb2\xf2\x8eQ\x02\x13\x93\x9b'\xb7\n 1N\xdd\x8a0\xf4\xdc~\xa7\xee\\\xe2yB\x88\xc9\x8c\xa3\x80\xd7\xfa\xa6[\xbeIO\xc1 \xd7H\xd9\x84U\xd7\x10\x02\x0b\x96\x0c\xf2YRL\x83$xg%\xac\xf4\x94H\x9e\xaf--b\xcdP\xcd\x17\x1b"
2025-10-09 15:57:25.705 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] decrypted 3.x payload=b'{"dps":{"1":"single_click","2":"single_click","3":"double_click","4":"single_click","10":100},"cid":"cc86ecfffe0d8ca2"}'
2025-10-09 15:57:25.705 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] payload type = <class 'bytes'>
2025-10-09 15:57:25.705 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] decoded results='{"dps":{"1":"single_click","2":"single_click","3":"double_click","4":"single_click","10":100},"cid":"cc86ecfffe0d8ca2"}'
2025-10-09 15:57:25.706 DEBUG (SyncWorker_10) [tinytuya.core.XenonDevice] status() received data={'dps': {'1': 'single_click', '2': 'single_click', '3': 'double_click', '4': 'single_click', '10': 100}, 'cid': 'cc86ecfffe0d8ca2', 'device': Device( 'cc86ecfffe0d8ca2', address=None, local_key='', dev_type='default', connection_timeout=5, version=3.3, persist=False, cid='cc86ecfffe0d8ca2', parent='eb98615f91f1ba752fadkz', children={} )}
2025-10-09 15:57:25.709 DEBUG (MainThread) [custom_components.tuya_local.device] Teclado Vladmir received {"1": "single_click", "2": "single_click", "3": "double_click", "4": "single_click", "10": 100, "full_poll": true}
2025-10-09 15:57:25.711 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 1 value from single_click to single_click
2025-10-09 15:57:25.711 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 1 value from single_click to single_click
2025-10-09 15:57:25.712 DEBUG (MainThread) [custom_components.tuya_local.event] loratap_zigbee_six_switch.yaml/Button 1 triggering event for value single_click
2025-10-09 15:57:25.713 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 2 value from single_click to single_click
2025-10-09 15:57:25.714 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 2 value from single_click to single_click
2025-10-09 15:57:25.714 DEBUG (MainThread) [custom_components.tuya_local.event] loratap_zigbee_six_switch.yaml/Button 2 triggering event for value single_click
2025-10-09 15:57:25.715 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 3 value from double_click to double_click
2025-10-09 15:57:25.716 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 3 value from double_click to double_click
2025-10-09 15:57:25.716 DEBUG (MainThread) [custom_components.tuya_local.event] loratap_zigbee_six_switch.yaml/Button 3 triggering event for value double_click
2025-10-09 15:57:25.717 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 4 value from single_click to single_click
2025-10-09 15:57:25.718 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Six button remote: Mapped dps 4 value from single_click to single_click
2025-10-09 15:57:25.718 DEBUG (MainThread) [custom_components.tuya_local.event] loratap_zigbee_six_switch.yaml/Button 4 triggering event for value single_click
2025-10-09 15:57:25.822 DEBUG (MainThread) [custom_components.tuya_local.device] Teclado Vladmir persistant connection set to True
2025-10-09 15:57:25.824 DEBUG (SyncWorker_28) [tinytuya.core.XenonDevice] building command 9 payload=b'{"gwId":"eb98615f91f1ba752fadkz","devId":"cc86ecfffe0d8ca2","cid":"cc86ecfffe0d8ca2"}'
2025-10-09 15:57:25.881 DEBUG (SyncWorker_28) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:25.882 DEBUG (SyncWorker_28) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013a9d00000009000000687bf71739744b223e3ecc8f0ffa8f8d88d961fd878a95b465cbfe81b647f3b29cfd4ca976bd8881ea968b5cd47c7a6edc2907c387b966baf37d86e61e1bee15a5e5468f306ecb9bbe7929df72b983efaf410e52011a3265e98c8f4a45c5c783e30fb6e8260000aa55'
2025-10-09 15:57:25.894 DEBUG (SyncWorker_28) [tinytuya.core.Device] heartbeat received data=None
2025-10-09 15:57:25.900 DEBUG (SyncWorker_21) [tinytuya.core.XenonDevice] received data=b'000055aa00000000000000090000000c00000000b051ab030000aa55'
2025-10-09 15:57:25.901 DEBUG (SyncWorker_21) [tinytuya.core.XenonDevice] received null payload (TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1
2025-10-09 15:57:25.971 DEBUG (SyncWorker_6) [tinytuya.core.XenonDevice] Timeout in _send_receive() - retry 2 / 1
2025-10-09 15:57:25.971 DEBUG (SyncWorker_6) [tinytuya.core.XenonDevice] Exceeded tinytuya retry limit (1)
2025-10-09 15:57:25.972 DEBUG (SyncWorker_6) [tinytuya.core.error_helper] ERROR Check device key or version - 914 - payload: null
2025-10-09 15:57:25.972 DEBUG (SyncWorker_6) [tinytuya.core.XenonDevice] status() received data={'Error': 'Check device key or version', 'Err': '914', 'Payload': None}
2025-10-09 15:57:25.976 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception AttributeError Check device key or version (0/3)
2025-10-09 15:57:25.982 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] status() entry (dev_type is default)
2025-10-09 15:57:25.983 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] building command 10 payload=b'{"t":1760036245,"cid":"cc86ecfffe5d6c0c"}'
2025-10-09 15:57:25.979 DEBUG (SyncWorker_12) [tinytuya.core.XenonDevice] Network connection error in _send_receive() - retry 1/1
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 572, in _send_receive
    rmsg = self._receive()
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 444, in _receive
    data = self._recv_all( min_len )
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 418, in _recv_all
    newdata = self.socket.recv(length)
OSError: [Errno 9] Bad file descriptor
2025-10-09 15:57:26.085 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:26.086 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013a9e0000000a000000382286da1b430146127d0eee496f74a3a8180d9a9469039ee40e536b950916f3981fb820902ac6b7eb96e71304553deacdba31ae750000aa55'
2025-10-09 15:57:26.104 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] Network connection error in _send_receive() - retry 1/1
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 572, in _send_receive
    rmsg = self._receive()
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 444, in _receive
    data = self._recv_all( min_len )
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 418, in _recv_all
    newdata = self.socket.recv(length)
ConnectionResetError: [Errno 104] Connection reset by peer
2025-10-09 15:57:26.105 DEBUG (SyncWorker_12) [tinytuya.core.XenonDevice] Network connection error in _send_receive() - retry 2/1
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 572, in _send_receive
    rmsg = self._receive()
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 444, in _receive
    data = self._recv_all( min_len )
  File "/usr/local/lib/python3.13/site-packages/tinytuya/core/XenonDevice.py", line 418, in _recv_all
    newdata = self.socket.recv(length)
OSError: [Errno 9] Bad file descriptor
2025-10-09 15:57:26.111 DEBUG (SyncWorker_12) [tinytuya.core.XenonDevice] Exceeded tinytuya retry limit (1)
2025-10-09 15:57:26.111 DEBUG (SyncWorker_12) [tinytuya.core.XenonDevice] Unable to connect to device 
2025-10-09 15:57:26.111 DEBUG (SyncWorker_12) [tinytuya.core.error_helper] ERROR Network Error: Unable to Connect - 901 - payload: null
2025-10-09 15:57:26.113 DEBUG (MainThread) [custom_components.tuya_local.device] Teclado Closet error reading: Network Error: Unable to Connect
2025-10-09 15:57:26.183 DEBUG (SyncWorker_9) [tinytuya.core.XenonDevice] building command 9 payload=b'{"gwId":"eb98615f91f1ba752fadkz","devId":"cc86ecfffe5d6f5d","cid":"cc86ecfffe5d6f5d"}'
2025-10-09 15:57:26.209 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:26.210 DEBUG (SyncWorker_22) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013a9f0000000a000000382286da1b430146127d0eee496f74a3a8180d9a9469039ee40e536b950916f3981fb820902ac6b7eb96e71304553deacda29b7c110000aa55'
2025-10-09 15:57:26.215 DEBUG (SyncWorker_18) [tinytuya.core.XenonDevice] building command 9 payload=b'{"gwId":"eb98615f91f1ba752fadkz","devId":"cc86ecfffe0d8c97","cid":"cc86ecfffe0d8c97"}'
2025-10-09 15:57:26.216 DEBUG (SyncWorker_18) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:26.216 DEBUG (SyncWorker_18) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013aa000000009000000687bf71739744b223e3ecc8f0ffa8f8d88d961fd878a95b465cbfe81b647f3b29cfd4ca976bd8881ea968b5cd47c7a6edc64744d6195aa15502e59b9d16b2bfa1fe5468f306ecb9bbe7929df72b983efaf091c79b421713d2f95d92ec856cc29800cc030500000aa55'
2025-10-09 15:57:27.345 DEBUG (SyncWorker_9) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:27.346 DEBUG (SyncWorker_9) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013aa100000009000000687bf71739744b223e3ecc8f0ffa8f8d88d961fd878a95b465cbfe81b647f3b29cfd4ca976bd8881ea968b5cd47c7a6edcd8c771ac38037b641b1826fc2c085da09e1fbe0a8d8bf65a1f8dd27057898b77a8d1cbe67c4271f08327e83d1be543ffcdaa16090000aa55'
2025-10-09 15:57:27.357 DEBUG (SyncWorker_9) [tinytuya.core.Device] heartbeat received data=None
2025-10-09 15:57:27.358 DEBUG (SyncWorker_18) [tinytuya.core.Device] heartbeat received data=None
2025-10-09 15:57:27.425 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received data=b'000055aa00000000000000090000000c00000000b051ab030000aa55'
2025-10-09 15:57:27.426 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received null payload (TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1
2025-10-09 15:57:27.432 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received data=b'000055aa00013a9f0000000a0000006c0000000008b338dd1390a1609005cc27840d238090acc6942edbdb038d419aa330575fe0e50c1ab5c3217b26393e5ca49a12e8ec976e58ba974108b6cd47e31da15e54eb415a8e7899717e29f57be6674c6da0a700f8991496b6b924a612773f5044a0239616126c0000aa55'
2025-10-09 15:57:27.432 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received message=TuyaMessage(seqno=80543, cmd=10, retcode=0, payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xe5\x0c\x1a\xb5\xc3!{&9>\\\xa4\x9a\x12\xe8\xec\x97nX\xba\x97A\x08\xb6\xcdG\xe3\x1d\xa1^T\xebAZ\x8ex\x99q~)\xf5{\xe6gLm\xa0\xa7\x00\xf8\x99\x14\x96\xb6\xb9$\xa6\x12w?PD\xa0#", crc=2518028908, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:27.432 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] raw unpacked message = TuyaMessage(seqno=80543, cmd=10, retcode=0, payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xe5\x0c\x1a\xb5\xc3!{&9>\\\xa4\x9a\x12\xe8\xec\x97nX\xba\x97A\x08\xb6\xcdG\xe3\x1d\xa1^T\xebAZ\x8ex\x99q~)\xf5{\xe6gLm\xa0\xa7\x00\xf8\x99\x14\x96\xb6\xb9$\xa6\x12w?PD\xa0#", crc=2518028908, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:27.433 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] decode payload=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xe5\x0c\x1a\xb5\xc3!{&9>\\\xa4\x9a\x12\xe8\xec\x97nX\xba\x97A\x08\xb6\xcdG\xe3\x1d\xa1^T\xebAZ\x8ex\x99q~)\xf5{\xe6gLm\xa0\xa7\x00\xf8\x99\x14\x96\xb6\xb9$\xa6\x12w?PD\xa0#"
2025-10-09 15:57:27.433 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] decrypting=b"\x08\xb38\xdd\x13\x90\xa1`\x90\x05\xcc'\x84\r#\x80\x90\xac\xc6\x94.\xdb\xdb\x03\x8dA\x9a\xa30W_\xe0\xe5\x0c\x1a\xb5\xc3!{&9>\\\xa4\x9a\x12\xe8\xec\x97nX\xba\x97A\x08\xb6\xcdG\xe3\x1d\xa1^T\xebAZ\x8ex\x99q~)\xf5{\xe6gLm\xa0\xa7\x00\xf8\x99\x14\x96\xb6\xb9$\xa6\x12w?PD\xa0#"
2025-10-09 15:57:27.433 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] decrypted 3.x payload=b'{"dps":{"1":"single_click","2":"single_click","10":100},"cid":"cc86ecfffe5d6c0c"}'
2025-10-09 15:57:27.433 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] payload type = <class 'bytes'>
2025-10-09 15:57:27.434 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] decoded results='{"dps":{"1":"single_click","2":"single_click","10":100},"cid":"cc86ecfffe5d6c0c"}'
2025-10-09 15:57:27.434 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] Recieved async update for wrong CID cc86ecfffe5d6c0c while looking for CID cc86ecfffe0d8c97, trying again
2025-10-09 15:57:27.440 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received data=b'000055aa00000000000000090000000c00000000b051ab030000aa55'
2025-10-09 15:57:27.440 DEBUG (SyncWorker_34) [tinytuya.core.XenonDevice] received null payload (TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1
2025-10-09 15:57:27.842 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] status() entry (dev_type is default)
2025-10-09 15:57:27.842 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] building command 10 payload=b'{"t":1760036247,"cid":"cc86ecfffe5d6eb8"}'
2025-10-09 15:57:27.843 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:27.843 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00004d890000000a00000038b063df09d74c24e35b056ac9fe3d7f9759a025bd157beb2119116274778c5791d7b9c50e742f23a9fea74ac4abe707f0f235843b0000aa55'
2025-10-09 15:57:27.856 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] received data=b'000055aa00004d890000000a0000003c000000003caf09121cf3aa8c2442fc981c7f824730fbc2b18507ac7859cbc5b1bfb792faf1c12e24da2d63e7c171a0f5be418aa75808706c0000aa55'
2025-10-09 15:57:27.856 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] received message=TuyaMessage(seqno=19849, cmd=10, retcode=0, payload=b'<\xaf\t\x12\x1c\xf3\xaa\x8c$B\xfc\x98\x1c\x7f\x82G0\xfb\xc2\xb1\x85\x07\xacxY\xcb\xc5\xb1\xbf\xb7\x92\xfa\xf1\xc1.$\xda-c\xe7\xc1q\xa0\xf5\xbeA\x8a\xa7', crc=1476948076, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:27.856 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] raw unpacked message = TuyaMessage(seqno=19849, cmd=10, retcode=0, payload=b'<\xaf\t\x12\x1c\xf3\xaa\x8c$B\xfc\x98\x1c\x7f\x82G0\xfb\xc2\xb1\x85\x07\xacxY\xcb\xc5\xb1\xbf\xb7\x92\xfa\xf1\xc1.$\xda-c\xe7\xc1q\xa0\xf5\xbeA\x8a\xa7', crc=1476948076, crc_good=True, prefix=21930, iv=None)
2025-10-09 15:57:27.857 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] decode payload=b'<\xaf\t\x12\x1c\xf3\xaa\x8c$B\xfc\x98\x1c\x7f\x82G0\xfb\xc2\xb1\x85\x07\xacxY\xcb\xc5\xb1\xbf\xb7\x92\xfa\xf1\xc1.$\xda-c\xe7\xc1q\xa0\xf5\xbeA\x8a\xa7'
2025-10-09 15:57:27.857 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] decrypting=b'<\xaf\t\x12\x1c\xf3\xaa\x8c$B\xfc\x98\x1c\x7f\x82G0\xfb\xc2\xb1\x85\x07\xacxY\xcb\xc5\xb1\xbf\xb7\x92\xfa\xf1\xc1.$\xda-c\xe7\xc1q\xa0\xf5\xbeA\x8a\xa7'
2025-10-09 15:57:27.857 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] decrypted 3.x payload=b'{"dps":{"10":91},"cid":"cc86ecfffe5d6eb8"}'
2025-10-09 15:57:27.858 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] payload type = <class 'bytes'>
2025-10-09 15:57:27.858 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] decoded results='{"dps":{"10":91},"cid":"cc86ecfffe5d6eb8"}'
2025-10-09 15:57:27.858 DEBUG (SyncWorker_5) [tinytuya.core.XenonDevice] status() received data={'dps': {'10': 91}, 'cid': 'cc86ecfffe5d6eb8', 'device': Device( 'cc86ecfffe5d6eb8', address=None, local_key='', dev_type='default', connection_timeout=5, version=3.3, persist=True, cid='cc86ecfffe5d6eb8', parent='eb7834dbfa6e46eb422kew', children={} )}
2025-10-09 15:57:27.864 DEBUG (MainThread) [custom_components.tuya_local.device] Teclado Corredor received {"10": 91, "full_poll": true}
2025-10-09 15:57:27.969 DEBUG (SyncWorker_1) [tinytuya.core.XenonDevice] building command 9 payload=b'{"gwId":"eb7834dbfa6e46eb422kew","devId":"cc86ecfffe5d6eb8","cid":"cc86ecfffe5d6eb8"}'
2025-10-09 15:57:27.970 DEBUG (SyncWorker_1) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:27.970 DEBUG (SyncWorker_1) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00004d8a00000009000000683868e6455ec8c8c3ccd1b401ee3395049d1a77d4911a722532978e980ea9566a46cbb7b07fe7fae4b7e476e21405b233c8ad780554829a3936b8078392b2dc80caed3ae0c0a82c79f118861e41045875d7f29b454757a724fc97da929e6880fb3d56a2800000aa55'
2025-10-09 15:57:27.981 DEBUG (SyncWorker_1) [tinytuya.core.Device] heartbeat received data=None
2025-10-09 15:57:28.041 DEBUG (SyncWorker_31) [tinytuya.core.XenonDevice] received data=b'000055aa00000000000000090000000c00000000b051ab030000aa55'
2025-10-09 15:57:28.041 DEBUG (SyncWorker_31) [tinytuya.core.XenonDevice] received null payload (TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1
2025-10-09 15:57:31.008 DEBUG (SyncWorker_4) [tinytuya.core.XenonDevice] building command 9 payload=b'{"gwId":"eb98615f91f1ba752fadkz","devId":"cc86ecfffe0d8ca2","cid":"cc86ecfffe0d8ca2"}'
2025-10-09 15:57:31.009 DEBUG (SyncWorker_4) [tinytuya.core.XenonDevice] sending payload
2025-10-09 15:57:31.009 DEBUG (SyncWorker_4) [tinytuya.core.XenonDevice] payload encrypted=b'000055aa00013aa200000009000000687bf71739744b223e3ecc8f0ffa8f8d88d961fd878a95b465cbfe81b647f3b29cfd4ca976bd8881ea968b5cd47c7a6edc2907c387b966baf37d86e61e1bee15a5e5468f306ecb9bbe7929df72b983efaf410e52011a3265e98c8f4a45c5c783e3697558bc0000aa55'
2025-10-09 15:57:31.021 DEBUG (SyncWorker_4) [tinytuya.core.Device] heartbeat received data=None
2025-10-09 15:57:31.125 DEBUG (SyncWorker_35) [tinytuya.core.XenonDevice] received data=b'000055aa00000000000000090000000c00000000b051ab030000aa55'
2025-10-09 15:57:31.125 DEBUG (SyncWorker_35) [tinytuya.core.XenonDevice] received null payload (TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1

Confirmation

  • [x] I am sure this is a bug or improvement, that is well enough described that it can be implemented.

  • [x] This report is for tuya-local, not for localtuya.

  • [x] If this is for a specific device, the device config filename is mentioned above, or diagnostics are included.

  • [x] Log messages or diagnostics relevant to the issue are included.

  • [x] This is not requesting addition of a new device.

arthurperezbessa avatar Oct 09 '25 20:10 arthurperezbessa

This seems related to hub issues such as #1323 and #1054, and is possibly a bug in the hub itself, or in tinytuya. I will leave this one open, as it has debug logs showing the sequence of events leading up to it, but I do not expect to be able to fix this in the short term, at least until tinytuya 2.0.0 is released and the connection handling can be rewritten from scratch to better support hubs.

make-all avatar Oct 09 '25 23:10 make-all