leeyuentuen / localtuya

local handling for Tuya devices
GNU General Public License v3.0
79 stars 19 forks source link

Problem with bluetooth gateway and tuya bluetooth led lights #39

Open mariustt opened 1 year ago

mariustt commented 1 year ago

The problem

We have 20 Tuya bluetooth led lemps, which we want to manage with Localtuya. Regarding the fact that they only work on bluetooth, we got even several BLE gateways:

With both of the gateways we have the same issue - it seems to be impossible to assign the BLE led lemps to any of gateways. With each gateway we get different errors.

Environment

Steps to reproduce

First scenario

Adding a gateway information configuration.yaml

localtuya:
  - host: "192.168.20.68"
    device_id: "bfb579e80851f0d1b3clcg"
    local_key: "<gateway_local_key>
    friendly_name: "Bluetooth Gateway"
    protocol_version: "3.3"
    is_gateway: true

Restarting the homeassistant and trying to assign a sub device through Devices & Services in homeassistant. The result:

image

2023-02-16 22:27:06.925 ERROR (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Failed to get status for cid bf2ade721acadf57c6f8lm: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 684, in detect_available_dps
    status = await self.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 598, in status
    status = await self.exchange(ACTION_STATUS, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 576, in exchange
    payload = self._decode_payload(msg.payload)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 788, in _decode_payload
    return json.loads(payload)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Then Light 1is tried to be added in configuration.yaml:

localtuya:
  - host: "192.168.20.68"
    device_id: "bfb579e80851f0d1b3clcg"
    local_key: <gateway_local_key>
    friendly_name: "Bluetooth Gateway"
    protocol_version: "3.3"
    is_gateway: true
  - parent_gateway: "bfb579e80851f0d1b3clcg"
    device_id: "bf2ade721acadf57c6f8lm"
    friendly_name: "Light 1"
    entities:
      - platform: "light"
        friendly_name: "Light 1"
        id: 1
        brightness: 3
        brightness_lower: 29
        brightness_upper: 1000

The result after the restart of homeassistant:

2023-02-16 22:43:00.777 ERROR (MainThread) [homeassistant.util.logging] Exception in _handle_sub_device_request when dispatching 'localtuya_gateway_bfb579e80851f0d1b3clcg': ({'request': 'request_add', 'cid': 'bf2ade721acadf57c6f8lm', 'content': {'dps': {1: None, 3: None}}},)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 403, in _handle_sub_device_request
    await self._get_sub_device_status(cid)
  File "/config/custom_components/localtuya/common.py", line 439, in _get_sub_device_status
    status = await self._interface.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 598, in status
    status = await self.exchange(ACTION_STATUS, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 576, in exchange
    payload = self._decode_payload(msg.payload)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 788, in _decode_payload
    return json.loads(payload)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Second scenario

Adding a gateway information configuration.yaml

localtuya:
  - host: "192.168.20.126"
    device_id: "bf5417442785995d41uqyc"
    local_key: "<gateway_local_key>
    friendly_name: "Bluetooth Gateway"
    protocol_version: "3.4"
    is_gateway: true

Restarting the homeassistant and trying to assign a sub device through Devices & Services in homeassistant. The result:

2023-02-16 23:15:11.105 ERROR (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Failed to get status for cid bfd2bbd961fa06e3bep2aj: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 958, in detect_available_dps
    status = await self.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 871, in status
    status = await self.exchange(DP_QUERY_NEW, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 824, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 504, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
2023-02-16 23:15:11.116 ERROR (MainThread) [custom_components.localtuya.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 289, in validate_input
    detected_dps = await interface.detect_available_dps(data[CONF_DEVICE_ID])
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 958, in detect_available_dps
    status = await self.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 871, in status
    status = await self.exchange(DP_QUERY_NEW, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 824, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 504, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 457, in async_step_basic_sub_device_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 306, in validate_input
    await interface.close()
KeyError: (-100, <asyncio.locks.Semaphore object at 0x7f2c5bb34460 [locked]>)

image

Then Light 1is tried to be added in configuration.yaml:

localtuya:
  - host: "192.168.20.126"
    device_id: "bf5417442785995d41uqyc"
    local_key: <gateway_local_key>
    friendly_name: "Bluetooth Gateway"
    protocol_version: "3.4"
    is_gateway: true
  - parent_gateway: "bf5417442785995d41uqyc"
    device_id: "bfd2bbd961fa06e3bep2aj"
    friendly_name: "Light 1"
    entities:
      - platform: "light"
        friendly_name: "Light 1"
        id: 1
        brightness: 3
        brightness_lower: 29
        brightness_upper: 1000

The result after the restart of homeassistant:

2023-02-16 23:20:01.163 ERROR (MainThread) [homeassistant.util.logging] Exception in _handle_sub_device_request when dispatching 'localtuya_gateway_bf5417442785995d41uqyc': ({'request': 'request_add', 'cid': 'bfd2bbd961fa06e3bep2aj', 'content': {'dps': {1: None, 3: None}}},)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 403, in _handle_sub_device_request
    await self._get_sub_device_status(cid)
  File "/config/custom_components/localtuya/common.py", line 440, in _get_sub_device_status
    status = await self._interface.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 871, in status
    status = await self.exchange(DP_QUERY_NEW, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 824, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 504, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

The information of led light device:

  "result": {
    "category": "dj",
    "functions": [
      {
        "code": "switch_led",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "dp_id": 2,
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "dp_id": 3,
        "type": "Integer",
        "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_value_v2",
        "dp_id": 4,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "scene_data_v2",
        "dp_id": 6,
        "type": "Json",
        "values": "{\"scene_num\":{\"min\":1,\"scale\":0,\"max\":8,\"step\":1},\"scene_units\": {\"unit_change_mode\":{\"range\":[\"static\",\"jump\",\"gradient\"]},\"unit_switch_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"unit_gradient_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"bright\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"temperature\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}}"
      },
      {
        "code": "countdown_1",
        "dp_id": 7,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "power_memory",
        "dp_id": 33,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "do_not_disturb",
        "dp_id": 34,
        "type": "Boolean",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "switch_led",
        "dp_id": 1,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "dp_id": 2,
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "dp_id": 3,
        "type": "Integer",
        "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_value_v2",
        "dp_id": 4,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "scene_data_v2",
        "dp_id": 6,
        "type": "Json",
        "values": "{\"scene_num\":{\"min\":1,\"scale\":0,\"max\":8,\"step\":1},\"scene_units\": {\"unit_change_mode\":{\"range\":[\"static\",\"jump\",\"gradient\"]},\"unit_switch_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"unit_gradient_duration\":{\"min\":0,\"scale\":0,\"max\":100,\"step\":1},\"bright\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"temperature\":{\"min\":0,\"scale\":0,\"max\":1000,\"step\":1},\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}}"
      },
      {
        "code": "countdown_1",
        "dp_id": 7,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "power_memory",
        "dp_id": 33,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "do_not_disturb",
        "dp_id": 34,
        "type": "Boolean",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1676582541991,
  "tid": "fff97f0cae3f11ed838e2a0aa76353ad"
}

THANKS FOR ALL THE HELP IN ADVANCE! Cause it feels like throughout those two days all possible scenarios are tested and I dont have anything else to try.

weihongloke commented 1 year ago

I'm also having the same issue with the Linkoze Gateway and ZigBee Downlights https://www.linkoze.com/products/smart-gateway?variant=44110718042385

VinceDu66 commented 1 year ago

Same issue with Fingerbot on MOES Zigbee Smart Gateway : https://fr.moeshouse.com/products/moes-gateway-zhub-ms

mariustt commented 1 year ago

@leeyuentuen maybe you have recomendacions what specific bluetooh gateway should work in this situation? If you have the device that works, please just name it, I'll buy one for myself too. That would be the easiest solution.

alexualbu commented 1 year ago

@mariustt , @VinceDu66 - did you folks test the latest 3.7.0 beta?

VinceDu66 commented 1 year ago

I think , i have an issue because of the "cid", i put the device_id of my device because i don't kown how and where to retrieve it "cid" (sorry for my poor english) ;) [ { "device_id": "bfxxxxxxxxxxxxx", "device_name": "Fingerbot", "product_id": "5xxxxxxxxx", "product_name": "Fingerbot ", "category": "szjqr", "uuid": "tuyaxxxxxxxxxxx", "local_key": "7e8xxxxxxxxxxx", "mac_address": "Dxxxxxxxxxxxxxx" }, { "device_id": "bfxxxxxxxxxxxxx", "device_name": "Bluetooth Gateway", "product_id": "csvxxxxxxxxxxxxx", "product_name": "Bluetooth Gateway", "category": "cz", "uuid": "13db2xxxxxxxxxx", "local_key": "7e8xxxxxxxxxxxxx", "mac_address": "cxxxxxxxxxxx" },

alexualbu commented 1 year ago

@VinceDu66 , easiest way is from tuya developer console in the api explorer image

mariustt commented 1 year ago

@alexualbu we have a progress!

home-assistant.log now is empty with the release localtuya-3.7.0-beta. But light is unavailable. Home assistant version: 2023.3.6

image

VinceDu66 commented 1 year ago

Thank you @alexualbu very much for your answer, but i have already use API explorer but no "cid" for finger bot or bluetooth gateway :-(

Capture d’écran du 2023-04-08 18-04-59

Capture d’écran du 2023-04-08 18-05-20

leeyuentuen commented 1 year ago

Thank you @alexualbu very much for your answer, but i have already use API explorer but no "cid" for finger bot or bluetooth gateway :-(

Capture d’écran du 2023-04-08 18-04-59

Capture d’écran du 2023-04-08 18-05-20

try de node_id of the fingerbot as cid

alexualbu commented 1 year ago

@mariustt, thanks for the update! empty log sounds strange - there should at least be debug info on the heartbeat, and if the devices is unavailable there has to be some sort of indication. how are you looking at the logs?

VinceDu66 commented 1 year ago

Thanks @leeyuentuen , i have tried your advice, but two errors on logs when i try to add fingerbot.

Logger: custom_components.localtuya.config_flow Source: custom_components/localtuya/pytuya/init.py:1348 Integration: LocalTuya integration (documentation, issues) First occurred: 06:59:13 (1 occurrences) Last logged: 06:59:13

Unexpected exception Traceback (most recent call last): File "/config/custom_components/localtuya/config_flow.py", line 457, in async_step_basic_sub_device_info self.dps_strings = await validate_input(self.hass, user_input) File "/config/custom_components/localtuya/config_flow.py", line 289, in validate_input detected_dps = await interface.detect_available_dps(data[CONF_DEVICE_ID]) File "/config/custom_components/localtuya/pytuya/init.py", line 971, in detect_available_dps status = await self.status(cid) File "/config/custom_components/localtuya/pytuya/init.py", line 893, in status self._update_dps_cache(status) File "/config/custom_components/localtuya/pytuya/init.py", line 1348, in _update_dps_cache if cid not in self.sub_devices: UnboundLocalError: local variable 'cid' referenced before assignment


Logger: custom_components.localtuya.pytuya Source: custom_components/localtuya/pytuya/init.py:1348 Integration: LocalTuya integration (documentation, issues) First occurred: 06:59:13 (1 occurrences) Last logged: 06:59:13

[bf9...gef] Failed to get status for cid tuyafxxxxxxxxxxxxxxx: local variable 'cid' referenced before assignment Traceback (most recent call last): File "/config/custom_components/localtuya/pytuya/init.py", line 971, in detect_available_dps status = await self.status(cid) File "/config/custom_components/localtuya/pytuya/init.py", line 893, in status self._update_dps_cache(status) File "/config/custom_components/localtuya/pytuya/init.py", line 1348, in _update_dps_cache if cid not in self.sub_devices: UnboundLocalError: local variable 'cid' referenced before assignment

mariustt commented 1 year ago

@alexualbu sorry, my logging has been disabled. I turn it on and see the results I get below. I'am not sure what protocol version is for my gateway, so I made four scenarios (two for one gateway). The result in HA is the same - lights are unavailable.

########## Tuya Gateway (Nous 3.3)
  - host: "192.168.20.68"
    device_id: "bfb579e80851f0d1b3clcg"
    local_key: "<local_key>"
    friendly_name: "Bluetooth Gateway (Nous 3.3)"
    protocol_version: "3.3"
    is_gateway: true
  - parent_gateway: "bfb579e80851f0d1b3clcg"
    device_id: "bf9f1498b35526274bmrul"
    friendly_name: "Light 2 (Nous 3.3)"
    protocol_version: "3.3"
    entities:
      - platform: "light"
        friendly_name: "Light 2 (Nous 3.3)"
        id: 1
2023-04-08 22:25:27.430 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-08 22:25:27.580 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connecting to gateway 192.168.20.68
2023-04-08 22:25:28.117 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connected to gateway 192.168.20.68 successfully
2023-04-08 22:25:28.117 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Attempting to reconnect 0 subdevices
2023-04-08 22:25:28.157 DEBUG (MainThread) [custom_components.localtuya.light] [bf9...rul] Adding light.light_2_nous_3_3 with configuration: OrderedDict([('platform', 'light'), ('friendly_name', 'Light 2 (Nous 3.3)'), ('id', 1), ('brightness_upper', 1000), ('color_temp_max_kelvin', 6500), ('music_mode', False), ('brightness_lower', 29), ('color_temp_min_kelvin', 2700), ('color_temp_reverse', False)])
2023-04-08 22:25:30.319 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...rul] Connecting to sub-device bf9f1498b35526274bmrul via bfb579e80851f0d1b3clcg
2023-04-08 22:25:30.319 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...rul] Dispatching request request_add to gateway with content {'dps': {1: None}}
2023-04-08 22:25:30.498 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Received request request_add from bf9f1498b35526274bmrul with content {'dps': {1: None}}
2023-04-08 22:25:30.498 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatching event event_connected to sub-device bf9f1498b35526274bmrul with data None
2023-04-08 22:25:30.498 INFO (MainThread) [custom_components.localtuya.common] [bfb...lcg] Getting status for bf9f1498b35526274bmrul
2023-04-08 22:25:30.498 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending command 16 (device type: type_0d)
2023-04-08 22:25:30.498 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending payload: b'{"cid":"bf9f1498b35526274bmrul"}'
2023-04-08 22:25:30.499 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [bf9...rul] Received event event_connected from gateway with data None
2023-04-08 22:25:30.504 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 1
2023-04-08 22:25:30.504 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] payload b'\x00\x00U\xaa\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x008\xad\x99E@\xf2\xe0g\x96\xf1c\xf2Y!\xc8\xa9\x08\xef\x96\xcc?\xe6.g\x88\x0b\xd2}\xac_\xee\xc3]\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83D\xefv\xf2\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"bf9f1498b35526274bmrul"}')
2023-04-08 22:25:30.506 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 16 waiting for sequence number 1
2023-04-08 22:25:30.659 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 16 TuyaMessage(seqno=1, cmd=16, retcode=1, payload=b'\x83\xf6$\xa0\x07\x9c\xae\xd8&\xd0+\xddY\xd9d\x9b', crc=64401439, crc_good=True)
2023-04-08 22:25:30.659 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 1
2023-04-08 22:25:30.700 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Deciphered data = 'devid not found'
2023-04-08 22:25:30.700 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Invalid JSON Response from Device - 900 - payload: "devid not found"
2023-04-08 22:25:31.895 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\xbf\xe6\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98\'\xf0\x0e\xa1j\xbb\xf0\xae\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9=\x8b\x15\x19\xa2\xd0k\x0f\x98\xe0\xe6\x9e\xde\xa5@\xe6', crc=3866915959, crc_good=True)
2023-04-08 22:25:31.898 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:25:31.900 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Deciphered data = '{"dps":{"1":false},"cid":"0398","t":14792}'
2023-04-08 22:25:31.900 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sub-device status update ignored because cid 0398 is not added
2023-04-08 22:25:31.900 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Re-add subdevice cid 0398
2023-04-08 22:25:34.135 WARNING (MainThread) [homeassistant.components.netatmo] Webhook not registered - https and port 443 is required to register the webhook
2023-04-08 22:25:36.807 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b'3.3\x00\x00\x00\x00\x00\x00\xbf\xe7\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98\'\xf0\x0e\xa1j\xbb\xf0\xae\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\xec\x94\xc1.y%\x88\x87\'\x9ew\x89\xcf\x99\xee\x87', crc=3642765233, crc_good=True)
2023-04-08 22:25:36.807 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:25:36.809 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Deciphered data = '{"dps":{"1":false},"cid":"0398","t":14797}'
2023-04-08 22:25:36.809 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatching event event_status_updated to sub-device 0398 with data {'1': False}
  ########## Tuya Gateway (Nous 3.4)
  - host: "192.168.20.68"
    device_id: "bfb579e80851f0d1b3clcg"
    local_key: "<local_key>"
    friendly_name: "Bluetooth Gateway (Nous 3.4)"
    protocol_version: "3.4"
    is_gateway: true
  - parent_gateway: "bfb579e80851f0d1b3clcg"
    device_id: "bf9f1498b35526274bmrul"
    friendly_name: "Light 2 (Nous 3.4)"
    protocol_version: "3.4"
    entities:
      - platform: "light"
        friendly_name: "Light 2 (Nous 3.4)"
        id: 1
2023-04-08 22:30:11.413 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-08 22:30:12.048 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connecting to gateway 192.168.20.68
2023-04-08 22:30:13.747 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'0994a788c173c78d97557638771a27049c0b06dfd67c1470b011d0537d7a8c5e' != b'81583d88e022db0bd59ba7f9c192af2c124262e018cf26b9617662f3291772af'
2023-04-08 22:30:13.748 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x04\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\xc1\x92\xaf,\x12Bb\xe0\x18\xcf&\xb9avb\xf3)\x17r\xaf', crc_good=False)
2023-04-08 22:30:13.748 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:13.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x04\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:13.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:13.946 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connected to gateway 192.168.20.68 successfully
2023-04-08 22:30:13.947 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Attempting to reconnect 0 subdevices
2023-04-08 22:30:14.212 DEBUG (MainThread) [custom_components.localtuya.light] [bf9...rul] Adding light.light_2_nous_3_4 with configuration: OrderedDict([('platform', 'light'), ('friendly_name', 'Light 2 (Nous 3.4)'), ('id', 1), ('color_temp_min_kelvin', 2700), ('brightness_upper', 1000), ('brightness_lower', 29), ('color_temp_reverse', False), ('music_mode', False), ('color_temp_max_kelvin', 6500)])
2023-04-08 22:30:14.364 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...rul] Connecting to sub-device bf9f1498b35526274bmrul via bfb579e80851f0d1b3clcg
2023-04-08 22:30:14.365 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...rul] Dispatching request request_add to gateway with content {'dps': {1: None}}
2023-04-08 22:30:14.369 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Received request request_add from bf9f1498b35526274bmrul with content {'dps': {1: None}}
2023-04-08 22:30:14.369 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatching event event_connected to sub-device bf9f1498b35526274bmrul with data None
2023-04-08 22:30:14.369 INFO (MainThread) [custom_components.localtuya.common] [bfb...lcg] Getting status for bf9f1498b35526274bmrul
2023-04-08 22:30:14.369 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] 3.4 device: negotiating a new session key
2023-04-08 22:30:14.369 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] final payload for cmd 3: b'0123456789abcdef'
2023-04-08 22:30:14.370 DEBUG (SyncWorker_3) [custom_components.localtuya.common] [bf9...rul] Received event event_connected from gateway with data None
2023-04-08 22:30:14.372 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 3 waiting for sequence number -102
2023-04-08 22:30:14.549 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'07ba78393f3cc2e309ded5de6192a173f74df2b048494c1117c851a0fc9f4201' != b'5485184e83114feded9d1e7eda13034ae964eb1c30ceece128ea65832645c87f'
2023-04-08 22:30:14.549 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 3 TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83&E\xc8\x7f', crc_good=False)
2023-04-08 22:30:14.549 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got message type 3 for unknown listener 1: TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83&E\xc8\x7f', crc_good=False)
2023-04-08 22:30:17.599 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'558b7660333d18793f6172e5c1ea1e78406c711e19ba2268c8b1e7f6b00d88ae' != b'81583d88e022db0bd59ba7f9100c9634290ad42a09eaebfef6f3593452cac1c5'
2023-04-08 22:30:17.599 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x05\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x10\x0c\x964)\n\xd4*\t\xea\xeb\xfe\xf6\xf3Y4R\xca\xc1\xc5', crc_good=False)
2023-04-08 22:30:17.599 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:17.602 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x05\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:17.602 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:19.374 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] received null payload (None), fetch new one - 1 retries remaining
2023-04-08 22:30:19.374 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 3 waiting for sequence number -102
2023-04-08 22:30:22.607 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'415ebfb8ca48e48dc8b5a75867ed1cabd8c88f25203d783c4579bfbed39a8840' != b'81583d88e022db0bd59ba7f90dbace4aa831ae6c09b0ff3fb8b2698cad663f66'
2023-04-08 22:30:22.607 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x06\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\r\xba\xceJ\xa81\xael\t\xb0\xff?\xb8\xb2i\x8c\xadf?f', crc_good=False)
2023-04-08 22:30:22.607 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:22.610 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x06\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:22.611 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:24.376 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] received null payload (None) but out of recv retries, giving up
2023-04-08 22:30:24.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] session key negotiation failed on step 1
2023-04-08 22:30:24.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending command 16 (device type: v3.4)
2023-04-08 22:30:24.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending payload: b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982224"}'
2023-04-08 22:30:24.378 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] final payload for cmd 16: b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982224"}'
2023-04-08 22:30:24.381 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-08 22:30:24.381 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] payload b'\x00\x00U\xaa\x00\x00\x00\x02\x00\x00\x00\x10\x00\x00\x00\x84(T\x8e\xb6\xcb\x18\xf8\x95\x0bo\xbc?\xa0;\xf6\xcc\x9b\x90\xad\r\xbf\xccOx\xcb\x0e4@\xedc\xdf\xd8\x90\x15\x9e35\xbf\xfc\xc2\xb5]\x0fq8b\x01\xc8I/\x82\xf2I\x06\x92l\xb7R\x97\x88n\x94D\xa0;\xaf\xe9k\xab\x8d\x14\xe3\xd4\x7f\x05\x14h\xa5xG\xea\xc0\xbaw\xdc\xa98\x03v\xdd\x0e\x93\x05\xfd\xcd]\xa5\xae\xd3v;\xde\xe2\xb15\xa7\xe8CL\x03\xd5\xd7\xd2\xc4\xd0\xd1\x14\xdd\x13\xd1Z\xacQP\x03\x86\xfe\x0c\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982224"}')
2023-04-08 22:30:24.383 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 16 waiting for sequence number 2
2023-04-08 22:30:24.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'd852a05a22cab2fe64af60625b603debaa5081538a4a68bf1f242440ef21654d' != b'5485184e83114feded9d1e7eda13034ae964eb1c30ceece128ea6583a0363950'
2023-04-08 22:30:24.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 16 TuyaMessage(seqno=2, cmd=16, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83\xa069P', crc_good=False)
2023-04-08 22:30:24.449 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-08 22:30:24.452 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b'F\xcf\x1a\xc8' (len:4)
2023-04-08 22:30:24.452 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:24.481 WARNING (MainThread) [homeassistant.components.netatmo] Webhook not registered - https and port 443 is required to register the webhook
2023-04-08 22:30:27.623 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'97a741dbd1b9ed335903776318c3d921aaf9bef81eb7dc2940761ae1fa76d067' != b'81583d88e022db0bd59ba7f9d2f5e4a97887bed298e1701ff57fbaaad7b716d5'
2023-04-08 22:30:27.624 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x07\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\xd2\xf5\xe4\xa9x\x87\xbe\xd2\x98\xe1p\x1f\xf5\x7f\xba\xaa\xd7\xb7\x16\xd5', crc_good=False)
2023-04-08 22:30:27.624 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:27.625 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x07\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:27.625 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:32.642 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'3c08ebf7dc1f39d5f537f954123e871d652db66c6469bec0de362c6fa23703f4' != b'81583d88e022db0bd59ba7f9aad13efbd811033ab67b1714444e14ee323acd8a'
2023-04-08 22:30:32.642 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x08\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\xaa\xd1>\xfb\xd8\x11\x03:\xb6{\x17\x14DN\x14\xee2:\xcd\x8a', crc_good=False)
2023-04-08 22:30:32.643 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:32.644 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x08\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:32.645 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:37.673 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'9d10edb8063860425392c26e9cb4b712b83347a3f6fb45299830b0cbbb8a9441' != b'81583d88e022db0bd59ba7f9449197f9cc84fa21e5b3e6300062bd3a3326ba07'
2023-04-08 22:30:37.673 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\t\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9D\x91\x97\xf9\xcc\x84\xfa!\xe5\xb3\xe60\x00b\xbd:3&\xba\x07', crc_good=False)
2023-04-08 22:30:37.673 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:37.674 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\t\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:37.674 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:42.691 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'b83bae803e4cd861a1f699c7292b90731efe304c7806cb1bd6e8790c4421f40b' != b'81583d88e022db0bd59ba7f994330ae87cb5698b47715419e5e3414c9f993197'
2023-04-08 22:30:42.692 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\n\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x943\n\xe8|\xb5i\x8bGqT\x19\xe5\xe3AL\x9f\x991\x97', crc_good=False)
2023-04-08 22:30:42.692 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:42.693 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\n\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:42.694 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:47.694 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'90c10bf56a5f4d5cd4c7a818e7cb35696ddb79cb6e6064acb9c158f8107ff559' != b'81583d88e022db0bd59ba7f94e8ab23842434a096bb5502fdcead323884cfc02'
2023-04-08 22:30:47.694 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0b\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9N\x8a\xb28BCJ\tk\xb5P/\xdc\xea\xd3#\x88L\xfc\x02', crc_good=False)
2023-04-08 22:30:47.695 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:47.695 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0b\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:47.695 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:52.711 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'2c64a8094954dc38add1710fcf9777f65c52867ae80fe1c8f3e2042ab9743ee2' != b'81583d88e022db0bd59ba7f99f9205342617903271c1b4a99b20e1175ab71ad5'
2023-04-08 22:30:52.711 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0c\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x9f\x92\x054&\x17\x902q\xc1\xb4\xa9\x9b \xe1\x17Z\xb7\x1a\xd5', crc_good=False)
2023-04-08 22:30:52.711 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:30:52.712 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0c\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:30:52.713 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:30:54.556 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Connection lost: [Errno 104] Connection reset by peer
2023-04-08 22:30:54.557 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Sending event_disconnected to 1 subdevices
2023-04-08 22:30:54.557 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatching event event_disconnected to sub-device bf9f1498b35526274bmrul with data None
2023-04-08 22:30:54.557 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-04-08 22:30:54.557 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-04-08 22:30:54.558 DEBUG (SyncWorker_3) [custom_components.localtuya.common] [bf9...rul] Received event event_disconnected from gateway with data None
2023-04-08 22:30:54.558 DEBUG (SyncWorker_3) [custom_components.localtuya.common] [bf9...rul] Disconnected TuyaSubDevice: localtuya_bf9f1498b35526274bmrul
2023-04-08 22:31:11.416 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connecting to gateway 192.168.20.68
2023-04-08 22:31:11.467 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Connected to gateway 192.168.20.68 successfully
2023-04-08 22:31:11.467 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Attempting to reconnect 1 subdevices
2023-04-08 22:31:11.467 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Parsing subdevice ('bf9f1498b35526274bmrul', {'dps': {1: None}, 'retry_status': False})
2023-04-08 22:31:11.467 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatching event event_connected to sub-device bf9f1498b35526274bmrul with data None
2023-04-08 22:31:11.467 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Dispatch Event GW_EVT_CONNECTED bf9f1498b35526274bmrul
2023-04-08 22:31:11.467 INFO (MainThread) [custom_components.localtuya.common] [bfb...lcg] Getting status for bf9f1498b35526274bmrul
2023-04-08 22:31:11.468 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] 3.4 device: negotiating a new session key
2023-04-08 22:31:11.468 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] final payload for cmd 3: b'0123456789abcdef'
2023-04-08 22:31:11.468 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [bf9...rul] Received event event_connected from gateway with data None
2023-04-08 22:31:11.471 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 3 waiting for sequence number -102
2023-04-08 22:31:11.492 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'07ba78393f3cc2e309ded5de6192a173f74df2b048494c1117c851a0fc9f4201' != b'5485184e83114feded9d1e7eda13034ae964eb1c30ceece128ea65832645c87f'
2023-04-08 22:31:11.493 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 3 TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83&E\xc8\x7f', crc_good=False)
2023-04-08 22:31:11.493 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got message type 3 for unknown listener 1: TuyaMessage(seqno=1, cmd=3, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83&E\xc8\x7f', crc_good=False)
2023-04-08 22:31:12.783 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'502845c26a8d080fe5d4f8fc4aaefb5f92da23c5b34d8fd6322171bb89799bd4' != b'81583d88e022db0bd59ba7f994c75fbc0ed87f4cfa7d25981e6e4bffe75e3785'
2023-04-08 22:31:12.784 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\r\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x94\xc7_\xbc\x0e\xd8\x7fL\xfa}%\x98\x1enK\xff\xe7^7\x85', crc_good=False)
2023-04-08 22:31:12.784 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:31:12.784 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\r\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:31:12.785 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:31:16.475 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] received null payload (None), fetch new one - 1 retries remaining
2023-04-08 22:31:16.475 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 3 waiting for sequence number -102
2023-04-08 22:31:17.712 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'42cc0aee107a89a254384caeb58f4c800d25fa1e704d0c4b33a9e61a1f4964dd' != b'81583d88e022db0bd59ba7f99e3a9a7a0357c8870ad77ae7b5e941ed1e988a99'
2023-04-08 22:31:17.712 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0e\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x9e:\x9az\x03W\xc8\x87\n\xd7z\xe7\xb5\xe9A\xed\x1e\x98\x8a\x99', crc_good=False)
2023-04-08 22:31:17.712 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:31:17.714 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0e\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:31:17.714 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:31:21.478 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] received null payload (None) but out of recv retries, giving up
2023-04-08 22:31:21.478 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] session key negotiation failed on step 1
2023-04-08 22:31:21.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending command 16 (device type: v3.4)
2023-04-08 22:31:21.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending payload: b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982281"}'
2023-04-08 22:31:21.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] final payload for cmd 16: b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982281"}'
2023-04-08 22:31:21.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-08 22:31:21.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] payload b'\x00\x00U\xaa\x00\x00\x00\x02\x00\x00\x00\x10\x00\x00\x00\x84(T\x8e\xb6\xcb\x18\xf8\x95\x0bo\xbc?\xa0;\xf6\xcc\x9b\x90\xad\r\xbf\xccOx\xcb\x0e4@\xedc\xdf\xd8\x90\x15\x9e35\xbf\xfc\xc2\xb5]\x0fq8b\x01\xc8I/\x82\xf2I\x06\x92l\xb7R\x97\x88n\x94D\xa0\x15\x08o\xf3\x10\xfa!\xec Vq&\xe24@\xf3\xea\xc0\xbaw\xdc\xa98\x03v\xdd\x0e\x93\x05\xfd\xcd]\x16\xaa\xe9\x11\xac]o\xfc\x1e\x92\xf7\xd1\x05\xb4k\xc6\xd6\x814\xb4\xbdM\x02\r\x08\x95\xc2(89\xd2\xce\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1680982281"}')
2023-04-08 22:31:21.482 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 16 waiting for sequence number 2
2023-04-08 22:31:21.588 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'd852a05a22cab2fe64af60625b603debaa5081538a4a68bf1f242440ef21654d' != b'5485184e83114feded9d1e7eda13034ae964eb1c30ceece128ea6583a0363950'
2023-04-08 22:31:21.589 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 16 TuyaMessage(seqno=2, cmd=16, retcode=1, payload=b'F\xcf\x1a\xc8', crc=b'T\x85\x18N\x83\x11O\xed\xed\x9d\x1e~\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83\xa069P', crc_good=False)
2023-04-08 22:31:21.589 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-08 22:31:21.592 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b'F\xcf\x1a\xc8' (len:4)
2023-04-08 22:31:21.592 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:31:22.730 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'8281e37362e5c1bb70137a42eff0fa228d8b5b96d6b523c93494f8aef44a37a3' != b'81583d88e022db0bd59ba7f91d2a5335cd34a0b41777c28ecc3614d1b8b627c5'
2023-04-08 22:31:22.731 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0f\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\x1d*S5\xcd4\xa0\xb4\x17w\xc2\x8e\xcc6\x14\xd1\xb8\xb6\'\xc5', crc_good=False)
2023-04-08 22:31:22.731 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:31:22.733 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x0f\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:31:22.734 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:31:27.747 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'03c9868f9e36ec0161a8bc656bb1d98a0cf0ecd8746b81e6b8c0233bd309f139' != b'81583d88e022db0bd59ba7f9ad5dcb362d945612f8851ad5e123a593864c148a'
2023-04-08 22:31:27.748 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x10\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9\xad]\xcb6-\x94V\x12\xf8\x85\x1a\xd5\xe1#\xa5\x93\x86L\x14\x8a', crc_good=False)
2023-04-08 22:31:27.748 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:31:27.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x10\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:31:27.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
2023-04-08 22:31:32.767 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] HMAC checksum wrong! b'd36608dea104be336d3b985fb0095db1abb9fc72a13e997c3a1e5ce7543f698b' != b'81583d88e022db0bd59ba7f94e5367e5567e4a55e0f6fb8db09a5b6e69d0823e'
2023-04-08 22:31:32.767 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 8 TuyaMessage(seqno=0, cmd=8, retcode=0, payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x11\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae", crc=b'\x81X=\x88\xe0"\xdb\x0b\xd5\x9b\xa7\xf9NSg\xe5V~JU\xe0\xf6\xfb\x8d\xb0\x9a[ni\xd0\x82>', crc_good=False)
2023-04-08 22:31:32.768 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Got status update
2023-04-08 22:31:32.770 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] incomplete payload=b"3.3\x00\x00\x00\x00\x00\x00\xc0\x11\x00\x00\x00\x0118\xd7\xf2~\xb1\xbb\xbd\xffS\xae\x98'\xf0\x0e\xa1j\xbb\xf0\xae" (len:35)
2023-04-08 22:31:32.770 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ERROR Unexpected Payload from Device - 904 - payload: null
  ########## Tuya Gateway (Moes 3.3)
  - host: "192.168.20.126"
    device_id: "bf5417442785995d41uqyc"
    local_key: "<local_key>"
    friendly_name: "Bluetooth Gateway (Moes 3.3)"
    protocol_version: "3.3"
    is_gateway: true
  - parent_gateway: "bf5417442785995d41uqyc"
    device_id: "bfd2bbd961fa06e3bep2aj"
    friendly_name: "Light 1 (Moes 3.3)"
    protocol_version: "3.3"
    entities:
      - platform: "light"
        friendly_name: "Light 1 (Moes 3.3)"
2023-04-08 22:34:33.692 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-08 22:34:34.292 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connecting to gateway 192.168.20.126
2023-04-08 22:34:34.431 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connected to gateway 192.168.20.126 successfully
2023-04-08 22:34:34.431 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Attempting to reconnect 0 subdevices
2023-04-08 22:34:34.450 DEBUG (MainThread) [custom_components.localtuya.light] [bfd...2aj] Adding light.light_1_moes_3_3 with configuration: OrderedDict([('platform', 'light'), ('friendly_name', 'Light 1 (Moes 3.3)'), ('id', 1), ('color_temp_max_kelvin', 6500), ('color_temp_reverse', False), ('brightness_lower', 29), ('music_mode', False), ('brightness_upper', 1000), ('color_temp_min_kelvin', 2700)])
2023-04-08 22:34:36.331 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...2aj] Connecting to sub-device bfd2bbd961fa06e3bep2aj via bf5417442785995d41uqyc
2023-04-08 22:34:36.331 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...2aj] Dispatching request request_add to gateway with content {'dps': {1: None}}
2023-04-08 22:34:36.346 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_add from bfd2bbd961fa06e3bep2aj with content {'dps': {1: None}}
2023-04-08 22:34:36.346 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_connected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:34:36.346 INFO (MainThread) [custom_components.localtuya.common] [bf5...qyc] Getting status for bfd2bbd961fa06e3bep2aj
2023-04-08 22:34:36.347 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 16 (device type: type_0d)
2023-04-08 22:34:36.347 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"cid":"bfd2bbd961fa06e3bep2aj"}'
2023-04-08 22:34:36.347 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [bfd...2aj] Received event event_connected from gateway with data None
2023-04-08 22:34:36.350 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 1
2023-04-08 22:34:36.350 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x008\xa3:\xd6\x86lV\xfc`\xdc\xb6\xfc\x9eqPP\xe0czJ\xa6,Y\x18\x0f\xa2\xc7\x14\xa9\x9e\x18B\xbb\x96\x8f\xa9\xe5\x95\xc9\xa1\x03\x00Q\xb6,\xa2~R;\t\xe3\\\x02\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"bfd2bbd961fa06e3bep2aj"}')
2023-04-08 22:34:36.351 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 16 waiting for sequence number 1
2023-04-08 22:34:36.626 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Connection lost: [Errno 104] Connection reset by peer
2023-04-08 22:34:36.627 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Sending event_disconnected to 1 subdevices
2023-04-08 22:34:36.627 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_disconnected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:34:36.629 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-04-08 22:34:36.629 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-04-08 22:34:36.629 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [bfd...2aj] Received event event_disconnected from gateway with data None
2023-04-08 22:34:36.630 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [bfd...2aj] Disconnected TuyaSubDevice: localtuya_bfd2bbd961fa06e3bep2aj
2023-04-08 22:34:41.358 ERROR (MainThread) [homeassistant.util.logging] Exception in _handle_sub_device_request when dispatching 'localtuya_gateway_bf5417442785995d41uqyc': ({'request': 'request_add', 'cid': 'bfd2bbd961fa06e3bep2aj', 'content': {'dps': {1: None}}},)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 410, in _handle_sub_device_request
    await self._get_sub_device_status(cid)
  File "/config/custom_components/localtuya/common.py", line 447, in _get_sub_device_status
    status = await self._interface.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 884, in status
    status = await self.exchange(DP_QUERY_NEW, cid=cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 837, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 516, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

2023-04-08 22:35:33.696 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connecting to gateway 192.168.20.126
2023-04-08 22:35:33.717 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connected to gateway 192.168.20.126 successfully
2023-04-08 22:35:33.717 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Attempting to reconnect 1 subdevices
2023-04-08 22:35:33.717 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Parsing subdevice ('bfd2bbd961fa06e3bep2aj', {'dps': {1: None}, 'retry_status': False})
2023-04-08 22:35:33.717 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_connected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:35:33.718 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatch Event GW_EVT_CONNECTED bfd2bbd961fa06e3bep2aj
2023-04-08 22:35:33.718 INFO (MainThread) [custom_components.localtuya.common] [bf5...qyc] Getting status for bfd2bbd961fa06e3bep2aj
2023-04-08 22:35:33.718 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 16 (device type: type_0d)
2023-04-08 22:35:33.718 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"cid":"bfd2bbd961fa06e3bep2aj"}'
2023-04-08 22:35:33.720 DEBUG (SyncWorker_1) [custom_components.localtuya.common] [bfd...2aj] Received event event_connected from gateway with data None
2023-04-08 22:35:33.722 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 1
2023-04-08 22:35:33.722 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x008\xa3:\xd6\x86lV\xfc`\xdc\xb6\xfc\x9eqPP\xe0czJ\xa6,Y\x18\x0f\xa2\xc7\x14\xa9\x9e\x18B\xbb\x96\x8f\xa9\xe5\x95\xc9\xa1\x03\x00Q\xb6,\xa2~R;\t\xe3\\\x02\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"bfd2bbd961fa06e3bep2aj"}')
2023-04-08 22:35:33.725 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 16 waiting for sequence number 1
2023-04-08 22:35:33.733 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Connection lost: [Errno 104] Connection reset by peer
2023-04-08 22:35:33.733 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Sending event_disconnected to 1 subdevices
2023-04-08 22:35:33.733 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_disconnected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:35:33.733 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-04-08 22:35:33.733 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-04-08 22:35:33.734 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [bfd...2aj] Received event event_disconnected from gateway with data None
2023-04-08 22:35:33.734 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [bfd...2aj] Disconnected TuyaSubDevice: localtuya_bfd2bbd961fa06e3bep2aj
2023-04-08 22:35:38.727 WARNING (MainThread) [custom_components.localtuya.common] [bf5...qyc] Adding subdevice bfd2bbd961fa06e3bep2aj failed with exception
  ########## Tuya Gateway (Moes 3.4)
  - host: "192.168.20.126"
    device_id: "bf5417442785995d41uqyc"
    local_key: "<local_key>"
    friendly_name: "Bluetooth Gateway (Moes 3.4)"
    protocol_version: "3.4"
    is_gateway: true
  - parent_gateway: "bf5417442785995d41uqyc"
    device_id: "bfd2bbd961fa06e3bep2aj"
    friendly_name: "Light 1 (Moes 3.4)"
    protocol_version: "3.4"
    entities:
      - platform: "light"
        friendly_name: "Light 1 (Moes 3.4)"
        id: 1
2023-04-08 22:37:37.858 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-08 22:37:37.997 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connecting to gateway 192.168.20.126
2023-04-08 22:37:38.092 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connected to gateway 192.168.20.126 successfully
2023-04-08 22:37:38.092 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Attempting to reconnect 0 subdevices
2023-04-08 22:37:39.845 DEBUG (MainThread) [custom_components.localtuya.light] [bfd...2aj] Adding light.light_1_moes_3_4 with configuration: OrderedDict([('platform', 'light'), ('friendly_name', 'Light 1 (Moes 3.4)'), ('id', 1), ('color_temp_max_kelvin', 6500), ('brightness_upper', 1000), ('color_temp_reverse', False), ('brightness_lower', 29), ('music_mode', False), ('color_temp_min_kelvin', 2700)])
2023-04-08 22:37:40.409 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...2aj] Connecting to sub-device bfd2bbd961fa06e3bep2aj via bf5417442785995d41uqyc
2023-04-08 22:37:40.409 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...2aj] Dispatching request request_add to gateway with content {'dps': {1: None}}
2023-04-08 22:37:40.427 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_add from bfd2bbd961fa06e3bep2aj with content {'dps': {1: None}}
2023-04-08 22:37:40.427 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_connected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:37:40.428 INFO (MainThread) [custom_components.localtuya.common] [bf5...qyc] Getting status for bfd2bbd961fa06e3bep2aj
2023-04-08 22:37:40.428 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] 3.4 device: negotiating a new session key
2023-04-08 22:37:40.428 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 3: b'0123456789abcdef'
2023-04-08 22:37:40.428 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [bfd...2aj] Received event event_connected from gateway with data None
2023-04-08 22:37:40.430 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 3 waiting for sequence number -102
2023-04-08 22:37:40.588 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 4 TuyaMessage(seqno=27167, cmd=4, retcode=0, payload=b']\xcaF\xa5m?\x96\x8d\x13u\xc1\x9e\xe2\xd9\xa0]\xae\xe6 \x9fd\xb1B\xf7\x03n&S\x03\xd4\x93\x85\xfd\xe5=P\x97\x1990F\x9a\x16\xfc\nM$\xb3\x96\x8f\xa9\xe5\x95\xc9\xa1\x03\x00Q\xb6,\xa2~R;', crc=b"\x1ae\x17\xe9Kv\xb0P'\xf2^N_\x05@>x\xb9\x9fMd\xf4W\xa0\xdf>f\xaaM\xf1\xadD", crc_good=True)
2023-04-08 22:37:40.589 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got key negotiation response
2023-04-08 22:37:40.637 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] decrypted session key negotiation step 2: payload=b'42b4382ac40db6b3\x1dt.\xb3\xd1hU\xf1w\x86\xca\xf0\xfbG\xabj&\x04M\x95\xd3g\x13\tK\xb14\x85\xc9\x1c\xe8S'
2023-04-08 22:37:40.637 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 5: b"\xb4'\xf2\xd2\xb1g\xceT\xd6\xff\xbd@ \xa9\x92\x85[\x8f\xed\x07\xb6\x8dfq\xfc\xea_\x9c\n\xd1\x96\xab"
2023-04-08 22:37:40.638 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Session key negotiate success! session key: b'\xdeB\x81\x15B\xfb\xf4I\x96\x02sa\xf3}Z\xf8'
2023-04-08 22:37:40.639 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 16 (device type: v3.4)
2023-04-08 22:37:40.639 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"devId":"bf5417442785995d41uqyc","uid":"bf5417442785995d41uqyc","t":"1680982660"}'
2023-04-08 22:37:40.639 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 16: b'{"devId":"bf5417442785995d41uqyc","uid":"bf5417442785995d41uqyc","t":"1680982660"}'
2023-04-08 22:37:40.639 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 27168
2023-04-08 22:37:40.640 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b"\x00\x00U\xaa\x00\x00j \x00\x00\x00\x10\x00\x00\x00\x84$\xe4\xd4\xa6\xe1B\xf1\xcf %\xc1W%L\x14\xa9\xc8\xf7\xf5gYB\xbb\t\x9fmc=\xdf\xb3\x91,\x04\xe3\x08\x95\x1e\x88\xc0[O\x8aa\xa0\x82>}\xcd\x98\xa2\xf1gm\x15\x9d\xa6Sn\xb8\xb3:F\xca\xeckF\x05\x84X\xf15as\x8d\xdf.iVi\x8a\x16\x93\xe2(\xf7\xa6'\x90\xbbI\xc6bsa;\xd7\x8d\xdaD\xc3\x13\x03G\xfc\x87\x7f\rn\xd7\xab\x1d=O\xb8\x87C\xf4\x87\xe05\x87\x97\xd3S\xa4M\xeeY\x00\x00\xaaU" - MessagePayload(cmd=16, payload=b'{"devId":"bf5417442785995d41uqyc","uid":"bf5417442785995d41uqyc","t":"1680982660"}')
2023-04-08 22:37:40.640 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 16 waiting for sequence number 27168
2023-04-08 22:37:40.775 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 16 TuyaMessage(seqno=27168, cmd=16, retcode=0, payload=b'\xc2\x91\x9at\x07\x93`\x97[r\xe1H\xd8\xcb\x9b\xa0\xf0$\x18\xb8\x05\xc4c\xf8\x96\xa9\xa7\x04\xe4g$\xba', crc=b"'\x17f\\\xac\xc6\xd3\x1c\xbb\xec9\xa6\x95\xb6j\xca\xd8m\xa0T<$\xa3\x0e\x19\x87V\xce\xd5'\\F", crc_good=True)
2023-04-08 22:37:40.775 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 27168
2023-04-08 22:37:40.800 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Deciphered data = '{"dps":{"38":"memory"}}'
2023-04-08 22:37:40.805 ERROR (MainThread) [homeassistant.util.logging] Exception in _handle_sub_device_request when dispatching 'localtuya_gateway_bf5417442785995d41uqyc': ({'request': 'request_add', 'cid': 'bfd2bbd961fa06e3bep2aj', 'content': {'dps': {1: None}}},)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 410, in _handle_sub_device_request
    await self._get_sub_device_status(cid)
  File "/config/custom_components/localtuya/common.py", line 447, in _get_sub_device_status
    status = await self._interface.status(cid)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 893, in status
    self._update_dps_cache(status)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 1348, in _update_dps_cache
    if cid not in self.sub_devices:
UnboundLocalError: local variable 'cid' referenced before assignment

2023-04-08 22:38:10.710 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Connection lost: [Errno 104] Connection reset by peer
2023-04-08 22:38:10.712 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Sending event_disconnected to 1 subdevices
2023-04-08 22:38:10.712 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_disconnected to sub-device bfd2bbd961fa06e3bep2aj with data None
2023-04-08 22:38:10.712 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-04-08 22:38:10.712 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-04-08 22:38:10.712 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [bfd...2aj] Received event event_disconnected from gateway with data None
2023-04-08 22:38:10.713 DEBUG (SyncWorker_4) [custom_components.localtuya.common] [bfd...2aj] Disconnected TuyaSubDevice: localtuya_bfd2bbd961fa06e3bep2aj
2023-04-08 22:38:10.783 DEBUG (MainThread) [custom_components.localtuya.common] [bfd...2aj] Dispatching request request_remove to gateway with content None
2023-04-08 22:38:10.789 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_remove from bfd2bbd961fa06e3bep2aj with content None
2023-04-08 22:38:10.789 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_disconnected to sub-device bfd2bbd961fa06e3bep2aj with data None
alexualbu commented 1 year ago

@mariustt , thanks! Looks like your first gw is 3.3, but either the cid/node_id is wrong or there is something else amiss with your setup (it receives a status from cid 0398, but gets a devis not found for your light device_id ..rul). Do you have a device connected to it with cid 0398? Maybe you could try adding it via de the UI config flow after cleaning the yaml? The Moes gw seems to be 3.4 and the error is consistent with what @VinceDu66 - so this is very likely an issue with the 3.4 implementation which I'll try to look into. @VinceDu66 , any chance you can also provide debug logs as well?

VinceDu66 commented 1 year ago

Yes, a chance @alexualbu ;-) Here my configuration :

localtuya:
  - host: "192.168.xxxxxxxxx"
    device_id: "bf92cxxxxxxxxx"
    local_key: "7e889xxxxxxxxxxx"
    friendly_name: "Bluetooth Gateway"
    protocol_version: "3.4"
    is_gateway: true
  - parent_gateway: "bf92cxxxxxxxxxxxxx"
    device_id: "tuyafaxxxxxxxxxxx"
    friendly_name: "Fingerbot"
    entities:
      - platform: "binary_sensor"
        friendly_name: "Fingetbot Switch"
        id: 2   

I put 2 for id, but perhaps it's not the good thing to do, because of { "code": "switch", "dp_id": 2, "type": "Boolean", "values": "{}" },

Here my debug :


2023-04-09 11:42:16.637 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Connecting to gateway 192.168.xxxx
2023-04-09 11:42:16.657 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Connected to gateway 192.168.xxxx successfully
2023-04-09 11:42:16.658 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Attempting to reconnect 1 subdevices
2023-04-09 11:42:16.658 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Parsing subdevice ('tuyafaxxxxxxx', {'dps': {2: None}, 'retry_status': False})
2023-04-09 11:42:16.658 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_connected to sub-device tuyafaxxxxxxx with data None
2023-04-09 11:42:16.658 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatch Event GW_EVT_CONNECTED tuyafaxxxxxxxx
2023-04-09 11:42:16.658 INFO (MainThread) [custom_components.localtuya.common] [bf9...gef] Getting status for tuyafaxxxxxxxxx
2023-04-09 11:42:16.659 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] 3.4 device: negotiating a new session key
2023-04-09 11:42:16.659 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 3: b'0123456789abcdef'
2023-04-09 11:42:16.664 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [tuy...c29] Received event event_connected from gateway with data None
2023-04-09 11:42:16.680 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 3 waiting for sequence number -102
2023-04-09 11:42:16.747 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 4 TuyaMessage(seqno=21334, cmd=4, retcode=0, payload=b'\x8fu\x01\x0xxxxxxxxxxxxxxd8\xa4_\x81\xfc\xff\xf0\xxxxxxxxxxxxxxxxxxxxxxxxx\xf6\x90\xdcz5\xe7"\x9e\x00\x94Y#\xf0\xd3\x0cz\xae\xb7\xbbxxxxxxxxxxxxxxxxxxxxbd\xc9\x8a', crc=b'\x8fLxxxxxxxxxxxxxxxxxxx', crc_good=True)
2023-04-09 11:42:16.748 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Got key negotiation response
2023-04-09 11:42:16.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] decrypted session key negotiation step 2: payload=b'3abxxxxxxxxxx\xa6\xec\x0c\x11S\xabj\xcc{xxxxxxxxxxxxxxxx"m \xa3=\x83\xe0xxxxxxxx6'
2023-04-09 11:42:16.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 5: b'\xe0"\xd0Wb\xb3<\xxxxxxxxxxxf3cW\xee\xe4<\xe2\xe9xxxxxxxxxxxAY\x9fs7'
2023-04-09 11:42:16.753 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Session key negotiate success! session key: b'\x94@\x19\x19W\xc9\x15A\xefp .\x1d\xc4u.'
2023-04-09 11:42:16.753 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 16 (device type: v3.4)
2023-04-09 11:42:16.753 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"devId":"bf92ccxxxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxxxxx","t":"1681033336"}'
2023-04-09 11:42:16.753 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 16: b'{"devId":"bf92ccaxxxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxxxxxxxxx","t":"1681033336"}'
2023-04-09 11:42:16.756 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 21335
2023-04-09 11:42:16.756 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b'\x00\x00U\xaa\x00\x00SW\x00\x00\xxxxxxxxxxxxx?]\xae\xa4\xa3,=\x109\x03\xc1\xa1\xa6\r\xfd\r\x87d\xb4\xe8\x82\x15\xc6\xaa\xc7\x7f\x82\xa8\xabz\x8aC\xb0\xe2_\x84\x92o\x052\x95Yk\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxY\x17J\xc0\xc9\xad\xfa\xfb\x8es\xef\x1f?\xae\x1a\xe9Z\x8axxxxxxxxxxxxxxxxx96_\xb3\x8dv\x06\x83\xcc#M^\x05\x8b\n\xa7\xb5.g~\xfa\x83\x93\xd51\xa2&\x06\x9f\x1e\xd4j\xa1l\x04\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"devId":"bf92ccaxxxxxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxxxxxx","t":"1681033336"}')
2023-04-09 11:42:16.758 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 16 waiting for sequence number 21335
2023-04-09 11:42:16.766 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 16 TuyaMessage(seqno=21335, cmd=16, retcode=0, payload=b'\xe2\xac\xcdPYp8\x1ft\x9b\xxxxxxxxxxxxxxxxxx1b\xc3\xae\xcc\xa6\xa6@/\x0cq\x0c\xed', crc=b'n\xe0L\xe2Mu\xdd\xcf>\x83\x86\xc4\x9d&\xxxxxxxxxxxxxxxxxxxxxxf0\xf1<\xf8i\xa7', crc_good=True)
2023-04-09 11:42:16.766 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 21335
2023-04-09 11:42:16.768 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Deciphered data = '{"dps":{"38":"off"}}'
2023-04-09 11:42:16.768 WARNING (MainThread) [custom_components.localtuya.common] [bf9...gef] Adding subdevice tuyafaxxxxxxxxxxxx failed with exception
 local variable 'cid' referenced before assignment
mariustt commented 1 year ago

@alexualbu thank you for ideas! I changed device_id value to node_id value and it worked!!

  ########## Tuya Gateway (Nous) 3.3
  - host: "192.168.20.68"
    device_id: "bfb579e80851f0d1b3clcg"
    local_key: "<local_key>"
    friendly_name: "Bluetooth Gateway (Nous 3.3)"
    protocol_version: "3.3"
    is_gateway: true
  - parent_gateway: "bfb579e80851f0d1b3clcg"
    device_id: "0398" # device_id -> node_id
    friendly_name: "Light 2 (Nous 3.3)"
    protocol_version: "3.3"
    entities:
      - platform: "light"
        friendly_name: "Light 2 (Nous 3.3)"
        id: 1
        brightness: 3
        brightness_lower: 10
        brightness_upper: 1000
        color_temp: 4
        color_temp_min_kelvin: 3000 # Optional, default: 2700
        color_temp_max_kelvin: 6000 # Optional, default: 6500

Light 2 device info

{
  "result": {
    "active_time": 1677411672,
    "category": "dj",
    "category_name": "Light Source",
    "create_time": 1677411672,
    "gateway_id": "bfb579e80851f0d1b3clcg",
    "icon": "smart/icon/bay1590111448933PtAb/90c4dba03849963379ba267f46dd0f81.png",
    "id": "bf9f1498b35526274bmrul",
    "ip": "",
    "lat": "0.0000",
    "local_key": "<local_key>",
    "lon": "0.0000",
    "model": "CD-TY-WY05",
    "name": "Light #2",
    "node_id": "0398",
    "online": false,
    "owner_id": "64639911",
    "product_id": "ge0bfvco",
    "product_name": "CD",
    "sub": true,
    "time_zone": "+08:00",
    "update_time": 1677411687,
    "uuid": "f38f37d58aca9150"
  },
  "success": true,
  "t": 1681120984441,
  "tid": "e272dd4bd78611ed93dec2bd506f6b85"
}

But I still have one problem. If I change the light settings in home assistant nothing happens, the changes does not take the eefect. But if I change the light settings in tuya smart app I can see the newest changes in home assistant.

The log info when I triggered Light to ON from OFF.

2023-04-10 14:31:05.258 DEBUG (MainThread) [custom_components.localtuya.common] [039...398] Dispatching request request_set_dps to gateway with content {'dps': {1: True}}
2023-04-10 14:31:05.258 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...lcg] Received request request_set_dps from 0398 with content {'dps': {1: True}}
2023-04-10 14:31:05.259 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending command 7 (device type: type_0d)
2023-04-10 14:31:05.259 INFO (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Unknown dev_type 'type_0d', command 7, Load default json_data format
2023-04-10 14:31:05.259 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Sending payload: b'{"gwId":"bfb579e80851f0d1b3clcg","devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1681126265","cid":"0398","dps":{"1":true}}'
2023-04-10 14:31:05.264 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-10 14:31:05.264 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] payload b"\x00\x00U\xaa\x00\x00\x00\x02\x00\x00\x00\x07\x00\x00\x00\xb73.3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\x85\xf1\xb3\xac\xf2\xf38\xad\xf3\x1e<60\x84\x07I/\x82\xf2I\x06\x92l\xb7R\x97\x88n\x94D\xa0\xf3Q:\xc8\xb2]\xd1\x02\x90L\x9c\xe7\xa2\x8bY\r\x9b\x90\xad\r\xbf\xccOx\xcb\x0e4@\xedc\xdf\xd8\x90\x15\x9e35\xbf\xfc\xc2\xb5]\x0fq8b\x01\xc8I/\x82\xf2I\x06\x92l\xb7R\x97\x88n\x94D\xa0ct\x06\x90H\xd3d\xca\x8c\xabR\xce\xa4v^\xbc\x08KBB\x172<\xcdA\xb9B\xcc\x0b\xf8\xa3\xd1\xdfVo\xb7\x9d\xdc\x0e\x96\xd6mc\x9c\x12\xac\xc2\xd7\xda\x13\x03J\xe9d\xeb\x1c0\xce\xec\xe1(\xeae\x83\x87\xc2\xc1B\x00\x00\xaaU" - MessagePayload(cmd=7, payload=b'{"gwId":"bfb579e80851f0d1b3clcg","devId":"bfb579e80851f0d1b3clcg","uid":"bfb579e80851f0d1b3clcg","t":"1681126265","cid":"0398","dps":{"1":true}}')
2023-04-10 14:31:05.265 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Command 7 waiting for sequence number 2
2023-04-10 14:31:05.313 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching message CMD 7 TuyaMessage(seqno=2, cmd=7, retcode=0, payload=b'', crc=416269786, crc_good=True)
2023-04-10 14:31:05.313 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] Dispatching sequence number 2
2023-04-10 14:31:05.315 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...lcg] ACK received for command 7: ignoring it

Adding an info from UI

light-2

alexualbu commented 1 year ago

thank you both for the details! it's going to be tougher for me to get to the bottom of the 3.4 gw issues, but I'll look into them. @mariustt , did you try v 3.6.6 until now with the 3.3 gw? i would expect it works and this here is just a 3.7.0 beta issue.

alexualbu commented 1 year ago

Pushed a PR to tackle these 2 issues (@mariustt & @VinceDu66 ). Once @leeyuentuen pushes a new beta tag you can test.

leeyuentuen commented 1 year ago

https://github.com/leeyuentuen/localtuya/releases/tag/3.7.0-beta.6

VinceDu66 commented 1 year ago

I'll test that tomorrow evening, and give you my return. Thank you !

VinceDu66 commented 1 year ago

Some little things more than the previous version Capture d’écran du 2023-04-11 17-53-25

I have this specs for fingerbot


  "result": {
    "category": "szjqr",
    "functions": [
      {
        "code": "switch",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "mode",
        "dp_id": 8,
        "type": "Enum",
        "values": "{\"range\":[\"click\",\"switch\"]}"
      },
      {
        "code": "arm_down_percent",
        "dp_id": 9,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":51,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "click_sustain_time",
        "dp_id": 10,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":10,\"scale\":0,\"step\":1}"
      },
      {
        "code": "arm_up_percent",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":50,\"scale\":0,\"step\":1}"
      },
      {
        "code": "tap_enable",
        "dp_id": 17,
        "type": "Boolean",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "switch",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "mode",
        "dp_id": 8,
        "type": "Enum",
        "values": "{\"range\":[\"click\",\"switch\"]}"
      },
      {
        "code": "arm_down_percent",
        "dp_id": 9,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":51,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "click_sustain_time",
        "dp_id": 10,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":10,\"scale\":0,\"step\":1}"
      },
      {
        "code": "battery_percentage",
        "dp_id": 12,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "arm_up_percent",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":50,\"scale\":0,\"step\":1}"
      },
      {
        "code": "tap_enable",
        "dp_id": 17,
        "type": "Boolean",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1680947096431,
  "tid": "05288194d5f211ed99d6ea1895c2a2b1"
}

Then i had dp_id 2 (switch) and 12 (batterie_percentage) for testing The module ask me some things

Capture d’écran du 2023-04-11 17-56-09 (checkbox without label at the end !!)

Capture d’écran du 2023-04-11 18-12-39 (Protocol 3.3 ??)

But ... Capture d’écran du 2023-04-11 18-30-45

In the log

2023-04-11 18:12:47.962 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Connecting to gateway 192.168.xx.xx
2023-04-11 18:12:48.021 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Connected to gateway 192.168.xx.xx successfully
2023-04-11 18:12:48.021 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Attempting to reconnect 1 subdevices
2023-04-11 18:12:48.021 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Parsing subdevice ('tuyafxxxxxxxxxxx', {'dps': {2: None, 12: None}, 'retry_status': False})
2023-04-11 18:12:48.022 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_connected to sub-device tuyafxxxxxxxxxxx with data None
2023-04-11 18:12:48.022 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatch Event GW_EVT_CONNECTED tuyafxxxxxxxxxxx
2023-04-11 18:12:48.022 INFO (MainThread) [custom_components.localtuya.common] [bf9...gef] Getting status for tuyafxxxxxxxxxxx
2023-04-11 18:12:48.022 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] 3.4 device: negotiating a new session key
2023-04-11 18:12:48.022 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 3: b'0123456789abcdef'
2023-04-11 18:12:48.024 DEBUG (SyncWorker_5) [custom_components.localtuya.common] [tuy...c29] Received event event_connected from gateway with data None
2023-04-11 18:12:48.036 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 3 waiting for sequence number -102
2023-04-11 18:12:48.039 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 4 TuyaMessage(seqno=40086, cmd=4, retcode=0, payload=b'\xd6\x8di!\xd8\xc3\xd9\xaaL:\xd7\xea3C\xb0\x00_\x81\xfc\xff\xf0\xa2\xaba\x06\xb4\x94c\xf7\xf6\x90\xdcz5\xe7"\x9e\x00\x94Y#\xf0\xd3\x0cz\xae\xb7\xbbKV\xd2\x10;\xe1r\x82\xf3\xfb\xbd\xb5\xd0\xbd\xc9\x8a', crc=b'\x84\xea\x90p\xeb\x1fHg[\x1e\xd4\xa8\xe3!\x108/+x\xc7P\x9c\xd7\x8c\x0f\xf4M\xce\xd1\xae\xfd\xcc', crc_good=True)
2023-04-11 18:12:48.040 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Got key negotiation response
2023-04-11 18:12:48.040 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] decrypted session key negotiation step 2: payload=b'6b3058d9941f4a49\xa6\xec\x0c\x11S\xabj\xcc{\xfe\xac\x07\xef#\xdci}\x1f\xec\xf7\x81"m \xa3=\x83\xe0\x8b\xec9\xc6'
2023-04-11 18:12:48.041 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 5: b'% @\x18\x0c%\x84\x15\xd4\xf2\x13\xef\xc9i5\xe8\x84?\x8311\xf3f\xc45\x97\x12\x06\xb4\xc5\x7f\xd3'
2023-04-11 18:12:48.041 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Session key negotiate success! session key: b"\r\xfc;\x8a\xff\x16'\xa0\xb9\xd9\xeb<\xa6t\xecx"
2023-04-11 18:12:48.042 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 16 (device type: v3.4)
2023-04-11 18:12:48.042 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"devId":"bf92cca6xxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxx","t":"1681229568","cid":"tuyafxxxxxxxxxxx"}'
2023-04-11 18:12:48.042 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 16: b'{"devId":"bf92cca6xxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxx","t":"1681229568","cid":"tuyafxxxxxxxxxxx"}'
2023-04-11 18:12:48.042 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 40087
2023-04-11 18:12:48.043 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b"\x00\x00U\xaa\x00\x00\x9c\x97\x00\x00\x00\x10\x00\x00\x00\x94d\xd5\xcf\xad\xeam\x08\xb8\xea\x84XO\xca\x93'\xf8\xb6=\x85u0\xf6%\xec\xf3\xa5KA\x19\xddY\x90\xf4A\x15;_&&2\xcd\xecX6o\x1f\xb0\x04\x1a\xaf'T\x1e\x0b\xa0\xe6\xbd\xd3\xc5\xb9\xd7\xcf%e\x06\xc8\xa1\xb9\x86Z\xad\xfcY\x98\xab+B\xa4\xe7-\xd9)\xf4q\xa4*^\x1fF\xf2\xc6\xeb\xdd\xd7\x7f|\x10'{g=\x92h\x02\xdf7\x0cs\xed\xc3{\xf1(\xbd\xf0\xc6\xee)\x8al\xce\xe8\xef\xf7\xc1\xcc0\xdf\xee\xfc\xa7\xeb\xbd\x9dfrnD{\x16\xa3!N\xad\x00\x00\xaaU" - MessagePayload(cmd=16, payload=b'{"devId":"bf92cca6xxxxxxxxxxx","uid":"bf92cca6xxxxxxxxxxx","t":"1681229568","cid":"tuyafxxxxxxxxxxx"}')
2023-04-11 18:12:48.052 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 16 waiting for sequence number 40087
2023-04-11 18:12:48.125 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 16 TuyaMessage(seqno=40087, cmd=16, retcode=1, payload=b"\xc53\x0c[o;\xcd\x01\x1d\x8c\xfc\x18\xb6\xe84\tr\xdcQ\x9f\x1at@]:5/%'\xa0\x145", crc=b'\x87kgy\x9a\xfbGl\xc8\xb0L\xcc\r\xd8Vq\xdf.!\xfd\xa0\xea\xd5\xc3\x1eO#\xba\xe29\xd0\x8d', crc_good=True)
2023-04-11 18:12:48.126 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 40087
2023-04-11 18:12:48.127 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] 'data unvalid' error detected: switching to dev_type 'type_0d'
2023-04-11 18:12:48.127 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Re-send 16 due to device type change (v3.4 -> type_0d)
2023-04-11 18:12:48.127 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 16 (device type: type_0d)
2023-04-11 18:12:48.128 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"cid":"tuyafxxxxxxxxxxx"}'
2023-04-11 18:12:48.128 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 16: b'{"cid":"tuyafxxxxxxxxxxx"}'
2023-04-11 18:12:48.129 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 40088
2023-04-11 18:12:48.129 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b'\x00\x00U\xaa\x00\x00\x9c\x98\x00\x00\x00\x10\x00\x00\x00D\x9f\xb9\xd4\xcd\xbc\xc54\x0e\x00\xc0\xfd\x92X\xef\xee\xc5_\xe4<Z|\x94e\xa6\x85\x82\x0c\xc9\\;\xc2\xe3\xc6;\x1ey\xe2o\xf0O8n\xe0\xf4\xa1\xa7m\xa9\xf8\xa8\xe0\xacnSX\xb9\x9a\x1f\xea\xba\xa7\x92\xcb\xbd\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"tuyafxxxxxxxxxxx"}')
2023-04-11 18:12:48.139 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 16 waiting for sequence number 40088
2023-04-11 18:12:48.143 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 16 TuyaMessage(seqno=40088, cmd=16, retcode=1, payload=b"\xc53\x0c[o;\xcd\x01\x1d\x8c\xfc\x18\xb6\xe84\tr\xdcQ\x9f\x1at@]:5/%'\xa0\x145", crc=b'[\x81\xfb\xea\x11\xbd\xf6\xa7\xb8\x9f\x1d\xcf6\x11\xb1\xc8&\xfe\xb7^\xc4\xcd_\x87\x8f\xb9\xa7\xaa^#h\xbc', crc_good=True)
2023-04-11 18:12:48.143 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 40088
2023-04-11 18:12:48.144 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Deciphered data = 'nvalid'
2023-04-11 18:12:48.145 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] ERROR Invalid JSON Response from Device - 900 - payload: "nvalid"
alexualbu commented 1 year ago

thanks, @VinceDu66 ! as expected this is going to be a bumpy ride since I don't have a device to test with :( I'll do more digging. On a different note, @leeyuentuen - at this point this is a 3.4 issue so maybe we want to merge this into #35? I think the same goes for #29.

VinceDu66 commented 1 year ago

@alexualbu , de rien ... euh.. you're welcome ;) I understand that if you don't have the device, it's hard to test. I thought just all bluetooth Tuya device have same conception and if it's work for one, the others work too. But it's seems to not be this beautiful world ;)

alexualbu commented 1 year ago

@VinceDu66, it's the gateway with 3.4 version that I don't have - in the case of sub-devices you're right, it shouldn't matter if they're BT, Zigbee etc

alexualbu commented 1 year ago

@VinceDu66 , made another attempt. Once @leeyuentuen releases another beta, please feel free to test

alexualbu commented 1 year ago

@VinceDu66, whenever you can please try the new 3.7.0 beta

VinceDu66 commented 1 year ago

I've got always issues :( But thanks for all your works !! I use : https://github.com/leeyuentuen/localtuya , but i see @alexualbu that you have a fork .. perhaps i can switch ;)

2023-04-15 17:40:29.779 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Connected to gateway 192.168.xxxxx successfully
2023-04-15 17:40:29.779 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Attempting to reconnect 1 subdevices
2023-04-15 17:40:29.779 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Parsing subdevice ('tuyafxxxxxxxxxxx', {'dps': {2: None, 12: None}, 'retry_status': True})
2023-04-15 17:40:29.780 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_connected to sub-device tuyafxxxxxxxxxxx with data None
2023-04-15 17:40:29.780 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatch Event GW_EVT_CONNECTED tuyafxxxxxxxxxxx
2023-04-15 17:40:29.780 INFO (MainThread) [custom_components.localtuya.common] [bf9...gef] Getting status for tuyafxxxxxxxxxxx
2023-04-15 17:40:29.780 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] 3.4 device: negotiating a new session key
2023-04-15 17:40:29.780 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 3: b'0123456789abcdef'
2023-04-15 17:40:29.781 DEBUG (SyncWorker_7) [custom_components.localtuya.common] [tuy...c29] Received event event_connected from gateway with data None
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 3 waiting for sequence number -102
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Started heartbeat loop
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] 3.4 device: negotiating a new session key
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 3: b'0123456789abcdef'
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] received null payload (None), fetch new one - 1 retries remaining
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] received null payload (None) but out of recv retries, giving up
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] session key negotiation failed on step 1
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 9 (device type: v3.4)
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload_dict for 'bf92ccaxxxxxxxxxxx' ('v3.4'/'v3.4'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_override': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
2023-04-15 17:40:29.793 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"gwId":"bf92ccaxxxxxxxxxxx","devId":"bf92ccaxxxxxxxxxxx"}'
2023-04-15 17:40:29.795 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 9: b'{"gwId":"bf92ccaxxxxxxxxxxx","devId":"bf92ccaxxxxxxxxxxx"}'
2023-04-15 17:40:29.807 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number -100
2023-04-15 17:40:29.808 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b"\x00\x00U\xaa\x00\x00\x00\x03\x00\x00\x00\t\x00\x00\x00t\x18\xb4\xa8\x9b\xa7\xbd<\xb0\xa8vF\xb1\xee]\x825>\x16\rIi\xfc\x9bQ\xbd\xc7\x86\x1e9\xfck\x00\xe3\x0b\x95\xe4UQ\x1f\xa8k)\xe1X\x01\xb9\x8a&\xe6\xea,\xeb\x1bAjS\x18\x8f+s0\xaf\x10{\x81\xdc\x80\xeaZ('j\xbd@\x15{i\xb2\x93\xc1\xd9\x14\x94\xb1.P\xd6\x0cHH\x7f\xcbA\xda\xb2R\xc1.\x94W\xdf\xd2\x80\xbau\x06>\x940\x98\xf7\xbf\x00\x00\xaaU" - MessagePayload(cmd=9, payload=b'{"gwId":"bf92ccaxxxxxxxxxxx","devId":"bf92ccaxxxxxxxxxxx"}')
2023-04-15 17:40:29.809 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 9 waiting for sequence number -100
2023-04-15 17:40:30.318 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 4 TuyaMessage(seqno=47507, cmd=4, retcode=0, payload=b'\x0b\xf4\xee}\xe1\xa5`\x03@\xd7\xd4U_\xfd\xe5\x16_\x81\xfc\xff\xf0\xa2\xaba\x06\xb4\x94c\xf7\xf6\x90\xdcz5\xe7"\x9e\x00\x94Y#\xf0\xd3\x0cz\xae\xb7\xbbKV\xd2\x10;\xe1r\x82\xf3\xfb\xbd\xb5\xd0\xbd\xc9\x8a', crc=b'\x8d\xdf\x10\x14\xa9\x9eI\xc9Q\x80\xc5\xf2\xecYN^\xfc\x14\xa5QX\xa2\xc2\x95x<\x98C\xf8\\ur', crc_good=True)
2023-04-15 17:40:30.318 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Got key negotiation response
2023-04-15 17:40:30.322 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] decrypted session key negotiation step 2: payload=b'1c4ebb12d03ff85d\xa6\xec\x0c\x11S\xabj\xcc{\xfe\xac\x07\xef#\xdci}\x1f\xec\xf7\x81"m \xa3=\x83\xe0\x8b\xec9\xc6'
2023-04-15 17:40:30.323 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 5: b'\xce\xb8h5\x11\x0c\xf6t\xafB,\xce\xd7m\x08\x90_\xf4z<\xc4\xae<9\x9b\xec\xce\x90N\xb0\x1b&'
2023-04-15 17:40:30.326 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Session key negotiate success! session key: b'ZRV\xd6s:\xc2\x15\xaf\xb7\xa0\xe6~vhq'
2023-04-15 17:40:30.327 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 16 (device type: v3.4)
2023-04-15 17:40:30.327 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"cid":"tuyafxxxxxxxxxxx"}'
2023-04-15 17:40:30.327 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 16: b'{"cid":"tuyafxxxxxxxxxxx"}'
2023-04-15 17:40:30.331 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 47508
2023-04-15 17:40:30.332 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b'\x00\x00U\xaa\x00\x00\xb9\x94\x00\x00\x00\x10\x00\x00\x00D\xa96O\xb54x\xd0\xdbm&\x9c\x04\\<\xf81v\xfd\xbc;\x14\xb0\xe3[x\xbc\x8aK\x10\xa6?]P\xafov\xba\x85\x101\xaf5R\xcc\xd6\xc0\x00n\xddt\xc0Z\xd0\xc7\x83N`\x881\x8b\xb2\x92G\n\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"tuyafxxxxxxxxxxx"}')
2023-04-15 17:40:30.335 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 16 waiting for sequence number 47508
2023-04-15 17:40:31.531 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] HMAC checksum wrong! b'0357be0a54027dc475378c4877c7592678a0ca17621a84eee75acbddc4c8ebe7' != b'1a10f8814e34842cda481afd579adb6b564b486b8f857578394f44d1c2fb0464'
2023-04-15 17:40:31.532 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 4 TuyaMessage(seqno=47508, cmd=4, retcode=0, payload=b'C\xa8Z\xa6\xe4\xb2\x1a\xef\xaf\xe5\xb78K\xc2<._\x81\xfc\xff\xf0\xa2\xaba\x06\xb4\x94c\xf7\xf6\x90\xdcz5\xe7"\x9e\x00\x94Y#\xf0\xd3\x0cz\xae\xb7\xbbKV\xd2\x10;\xe1r\x82\xf3\xfb\xbd\xb5\xd0\xbd\xc9\x8a', crc=b'\x1a\x10\xf8\x81N4\x84,\xdaH\x1a\xfdW\x9a\xdbkVKHk\x8f\x85ux9OD\xd1\xc2\xfb\x04d', crc_good=False)
2023-04-15 17:40:31.532 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 47508
2023-04-15 17:40:31.539 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Connection lost: [Errno 104] Connection reset by peer
2023-04-15 17:40:31.540 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Sending event_disconnected to 1 subdevices
2023-04-15 17:40:31.541 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_disconnected to sub-device tuyafxxxxxxxxxxx with data None
2023-04-15 17:40:31.541 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Disconnected (TuyaGatewayDevice) - event dispatch event_disconnected
2023-04-15 17:40:31.541 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Disconnected (TuyaGatewayDevice) - waiting for discovery broadcast
2023-04-15 17:40:31.542 DEBUG (SyncWorker_6) [custom_components.localtuya.common] [tuy...c29] Received event event_disconnected from gateway with data None
2023-04-15 17:40:31.542 DEBUG (SyncWorker_6) [custom_components.localtuya.common] [tuy...c29] Disconnected TuyaSubDevice: localtuya_tuyafxxxxxxxxxxx
2023-04-15 17:40:31.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Deciphered data = ''
alexualbu commented 1 year ago

@VinceDu66 , If you want to do a very quick test now so I don't pollute this repo with too many blind changes you can take my 3.7.0 with the minor change I made. Otherwise there is no reason to use my fork, I contribute everything back to this.

VinceDu66 commented 1 year ago

@alexualbu , i switch with your version, but gateway is in 3.4, then there is an error . (i just replace xxxxxxxxxxxxxxxxx for the screenshot) ;) Capture d’écran du 2023-04-15 19-50-09

alexualbu commented 1 year ago

@VinceDu66, are you sure you used the 3.7.0 branch and not master?

VinceDu66 commented 1 year ago

Story without words for you @alexualbu ;-) Capture d’écran du 2023-04-16 07-10-46 Capture d’écran du 2023-04-16 07-12-05 Capture d’écran du 2023-04-16 07-14-22 Capture d’écran du 2023-04-16 07-15-38 Capture d’écran du 2023-04-16 07-15-58 Capture d’écran du 2023-04-16 07-19-02

[bf9...xxx] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 702, in detect_available_dps
    status = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 602, in status
    status = await self.exchange(ACTION_STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 563, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 325, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 390, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 386, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 292, in validate_input
    detected_dps = await interface.detect_available_dps()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 702, in detect_available_dps
    status = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 602, in status
    status = await self.exchange(ACTION_STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 563, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 325, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Voilà :)

alexualbu commented 1 year ago

@VinceDu66 , there's something very fishy going on then with my fork (but lovely seeing HA in French :) ). I opened a PR so we do it the normal way.

alexualbu commented 1 year ago

@VinceDu66, beta 8 is now available to test out.

VinceDu66 commented 1 year ago

I have installed https://github.com/leeyuentuen/localtuya/tree/3.7.0-beta.8 now, here the log :

2023-04-16 15:10:25.399 DEBUG (MainThread) [custom_components.localtuya.common] [tuy...c29] Dispatching request request_remove to gateway with content None
2023-04-16 15:10:25.411 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Received request request_remove from tuyafaxxxxxxxxxxx with content None
2023-04-16 15:10:25.412 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_disconnected to sub-device tuyafaxxxxxxxxxxx with data None
2023-04-16 15:10:25.425 DEBUG (MainThread) [custom_components.localtuya.switch] Initialized switch [Switch]
2023-04-16 15:10:25.436 DEBUG (MainThread) [custom_components.localtuya.sensor] [tuy...c29] Adding sensor.battery_percentage with configuration: {'id': 12, 'friendly_name': 'Battery percentage', 'unit_of_measurement': '%', 'device_class': 'battery', 'platform': 'sensor'}
2023-04-16 15:10:25.437 DEBUG (MainThread) [custom_components.localtuya.switch] [tuy...c29] Adding switch.switch with configuration: {'id': 2, 'friendly_name': 'Switch', 'restore_on_reconnect': True, 'current': 2, 'current_consumption': 12, 'platform': 'switch'}
2023-04-16 15:10:25.438 DEBUG (MainThread) [custom_components.localtuya.binary_sensor] [tuy...c29] Adding binary_sensor.tap_enable with configuration: {'id': 17, 'friendly_name': 'Tap enable', 'state_on': 'True', 'state_off': 'False', 'device_class': <BinarySensorDeviceClass.MOTION: 'motion'>, 'platform': 'binary_sensor'}
2023-04-16 15:10:25.452 DEBUG (MainThread) [custom_components.localtuya.common] [tuy...c29] Connecting to sub-device tuyafaxxxxxxxxxxx via bf92cxxxxxxxxxxx
2023-04-16 15:10:25.452 DEBUG (MainThread) [custom_components.localtuya.common] [tuy...c29] Dispatching request request_add to gateway with content {'dps': {2: None, 17: None, 12: None}}
2023-04-16 15:10:25.459 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Received request request_add from tuyafaxxxxxxxxxxx with content {'dps': {2: None, 17: None, 12: None}}
2023-04-16 15:10:25.459 DEBUG (MainThread) [custom_components.localtuya.common] [bf9...gef] Dispatching event event_connected to sub-device tuyafaxxxxxxxxxxx with data None
2023-04-16 15:10:25.460 INFO (MainThread) [custom_components.localtuya.common] [bf9...gef] Getting status for tuyafaxxxxxxxxxxx
2023-04-16 15:10:25.460 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 16 (device type: type_0d)
2023-04-16 15:10:25.461 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"cid":"tuyafaxxxxxxxxxxx"}'
2023-04-16 15:10:25.472 DEBUG (SyncWorker_7) [custom_components.localtuya.common] [tuy...c29] Received event event_connected from gateway with data None
2023-04-16 15:10:25.464 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 16: b'{"cid":"tuyafaxxxxxxxxxxx"}'
2023-04-16 15:10:25.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 25881
2023-04-16 15:10:25.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b"\x00\x00U\xaa\x00\x00e\x19\x00\x00\x00\x10\x00\x00\x00D\xf2Y\xa1o\x0c\xd3\xe9rS\xc98t\x0c\xb5\xe9^5\xc1\xfb\xcc_M\x12\xff\xbc\x0ei`\xf5\xcb\xc4'\x13\x85\xca\x9cYI\xa3B\xd8`\xc1\xf8\xb1\x80*\x16Jn@\x94W\xe6\xc3r+\xcf\x0f5-6<\x08\x00\x00\xaaU" - MessagePayload(cmd=16, payload=b'{"cid":"tuyafaxxxxxxxxxxx"}')
2023-04-16 15:10:25.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 16 waiting for sequence number 25881
2023-04-16 15:10:25.773 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 16 TuyaMessage(seqno=25881, cmd=16, retcode=1, payload=b"=\xafi\x95{\xf8k3\xd5\x91\xaef\xc4\x9c7\xc9h2\xa7\xab\xc6\xe8'\xeen\x8c\x99\r\x8c)\xd1\x8f", crc=b'\xcc\xa1\x15\x14\xe4\x84\xc1KE\x1c\xa1\x86\xc4\xf2\xa46|\x9c*\xcb.\x0clO\\\x9d,8\xc8\xd7\xa9\x8c', crc_good=True)
2023-04-16 15:10:25.773 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number 25881
2023-04-16 15:10:25.773 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Deciphered data = 'nvalid'
2023-04-16 15:10:25.774 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] ERROR Invalid JSON Response from Device - 900 - payload: "nvalid"
2023-04-16 15:10:26.858 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending command 9 (device type: type_0d)
2023-04-16 15:10:26.858 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Sending payload: b'{"gwId":"bf92cxxxxxxxxxxx","devId":"bf92cxxxxxxxxxxx"}'
2023-04-16 15:10:26.859 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] final payload for cmd 9: b'{"gwId":"bf92cxxxxxxxxxxx","devId":"bf92cxxxxxxxxxxx"}'
2023-04-16 15:10:26.867 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching sequence number -100
2023-04-16 15:10:26.867 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] payload b"\x00\x00U\xaa\x00\x00e\x1a\x00\x00\x00\t\x00\x00\x00t\xc81?\xc1\x15C<\x98\x92 \xf7\xcb\xb0\x8d\xcef\x1b\xb7{\x91\xc6\\{\xad\x17S\xc3\xc1Y\x8b\xeaO\xdb\xb1|\xf0c2S\x01\xe3\xcd\x95\x9e\xa3\\p\xd9\x17b\xd6\x8c'h\x1e\xd8M\xf8a\x02\xfa\xd8A\xb2]zu\xa1\x8c\x08\xbe\x1dC\xc3z\xef\xbe\xf8F\x0c 8\xab\x95\\\xf3\x9a\x19$\xe7a\xfb \xdd\x14\x02\x84kYu\xadh\xc9J\xa6U\x8f\xcd)\x04m\xac\x00\x00\xaaU" - MessagePayload(cmd=9, payload=b'{"gwId":"bf92cxxxxxxxxxxx","devId":"bf92cxxxxxxxxxxx"}')
2023-04-16 15:10:26.873 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Command 9 waiting for sequence number -100
2023-04-16 15:10:26.895 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Dispatching message CMD 9 TuyaMessage(seqno=25882, cmd=9, retcode=0, payload=b'', crc=b'\x19q\xfd\xee<\x85<o\xe5\xc3\\\xa3\xa57\xd7E\x8d\xab\xeb\x88}\x8d\xf8\t\x04\x85A\xd1(\x85\t%', crc_good=True)
2023-04-16 15:10:26.896 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] Got heartbeat response
2023-04-16 15:10:26.901 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf9...gef] ACK received for command 9: ignoring it
alexualbu commented 1 year ago

thanks, @VinceDu66 - i need the beginning of the log after HA starts, please. It should look something like this:

2023-04-16 13:32:35.803 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...x7p] Connected to gateway 192.168.33.xx successfully 2023-04-16 13:32:35.804 DEBUG (MainThread) [custom_components.localtuya.common] [bfb...x7p] Attempting to reconnect 0 subdevices 2023-04-16 13:32:35.837 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...x7p] Started heartbeat loop 2023-04-16 13:32:35.837 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...x7p] Sending command 9 (device type: default) 2023-04-16 13:32:35.837 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bfb...x7p] final payload_dict

VinceDu66 commented 1 year ago

Something happened after a full reboot of HA. I have automatic feedback from dp_id when I add the Fingerbot manually!!!! Capture d’écran du 2023-04-16 21-30-06 What's weird is that some dp_id's don't match what I got by API Explorer:

{
  "result": {
    "category": "szjqr",
    "functions": [
      {
        "code": "switch",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "mode",
        "dp_id": 8,
        "type": "Enum",
        "values": "{\"range\":[\"click\",\"switch\"]}"
      },
      {
        "code": "arm_down_percent",
        "dp_id": 9,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":51,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "click_sustain_time",
        "dp_id": 10,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":10,\"scale\":0,\"step\":1}"
      },
      {
        "code": "arm_up_percent",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":50,\"scale\":0,\"step\":1}"
      },
      {
        "code": "tap_enable",
        "dp_id": 17,
        "type": "Boolean",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "switch",
        "dp_id": 2,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "mode",
        "dp_id": 8,
        "type": "Enum",
        "values": "{\"range\":[\"click\",\"switch\"]}"
      },
      {
        "code": "arm_down_percent",
        "dp_id": 9,
        "type": "Integer",
        "values": "{\"unit\":\"\",\"min\":51,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "click_sustain_time",
        "dp_id": 10,
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":10,\"scale\":0,\"step\":1}"
      },
      {
        "code": "battery_percentage",
        "dp_id": 12,
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "arm_up_percent",
        "dp_id": 15,
        "type": "Integer",
        "values": "{\"min\":0,\"max\":50,\"scale\":0,\"step\":1}"
      },
      {
        "code": "tap_enable",
        "dp_id": 17,
        "type": "Boolean",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1680947096431,
  "tid": "05288194d5f211ed99d6ea1895c2a2b1"
}

I managed to configure the battery percentage feedback, and it works!! image

but I don't really understand what options to choose for the rest. I'm still a beginner with HA. And i try since 2 hours, and nothing work ! :( Maybe a little help would be appreciated. From the configuration.yaml file maybe. Here my config:

localtuya:
  - host: 192.168.xxx
    device_id: bf92ccaxxxxxxxxxxx
    local_key: 7e889xxxxxxxxxxxx
    friendly_name: Bluetooth Gateway
    protocol_version: "3.4"
    is_gateway: true
  - parent_gateway: bf92ccaxxxxxxxxxxx
    device_id: tuyafaxxxxxxxxxxx
    friendly_name: Fingerbot
    entities:
    - platform: switch
      friendly_name: Switch
      id: 2
    - platform: sensor
      friendly_name: Sensor Battery
      id: 12
      device_class: battery
alexualbu commented 1 year ago

Excellent, @VinceDu66 ! Thanks a bunch for testing. I'm not 100% sure, but what I understood from some threads is that some DPs don t appear even in the API explorer unless you switch to DP control mode. Easiest way I found was to use tuya-cli to get the status and fiddle with the settings from Smart Life then repeat.

mariustt commented 1 year ago

Hi guys! I was busy at work for those past two weeks, therefore I was not able to test the 3.4 version, however I see you have done a lot of good things in that time!

From my side, I immediately started testing with the latest version - localtuya-3.7.0-beta.10

When I start/restart home assistant my logs:

2023-04-22 19:39:16.679 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-22 19:39:18.165 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connecting to gateway 192.168.20.126
2023-04-22 19:39:18.737 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connected to gateway 192.168.20.126 successfully
2023-04-22 19:39:18.737 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Attempting to reconnect 0 subdevices
2023-04-22 19:39:18.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Started heartbeat loop
2023-04-22 19:39:18.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] 3.4 device: negotiating a new session key
2023-04-22 19:39:18.750 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 3: b'0123456789abcdef'
2023-04-22 19:39:18.753 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 3 waiting for sequence number -102
2023-04-22 19:39:18.765 DEBUG (MainThread) [custom_components.localtuya.light] [02f...2f8] Adding light.living_room_spotlight_7_1 with configuration: {'platform': 'light', 'friendly_name': 'Living-room-spotlight-7-1', 'id': 1, 'brightness': 3, 'brightness_lower': 10, 'brightness_upper': 1000, 'color_mode': 21, 'color_temp': 4, 'color_temp_min_kelvin': 3000, 'color_temp_max_kelvin': 6000, 'color_temp_reverse': False, 'music_mode': False}
2023-04-22 19:39:18.765 DEBUG (MainThread) [custom_components.localtuya.light] [02f...2f8] Restoring state for entity: Living-room-spotlight-7-1 - state: False
2023-04-22 19:39:18.961 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 4 TuyaMessage(seqno=23069, cmd=4, retcode=0, payload=b'\xb4/\xd7\xcf\xf3\x16\x01x\x08\xe9\xb7\x1bO\xb5xR\xae\xe6 \x9fd\xb1B\xf7\x03n&S\x03\xd4\x93\x85\xfd\xe5=P\x97\x1990F\x9a\x16\xfc\nM$\xb3\x96\x8f\xa9\xe5\x95\xc9\xa1\x03\x00Q\xb6,\xa2~R;', crc=b'\xd5\xa0\xc7\xda\x9e\xfb\x8c\xf0l\xfb\x9a\xc7\xa3\xf5\x12\xb8\r\xd3~\xf8\xf3"L\xddv\x86\xffW\xf8\xe3\xa8{', crc_good=True)
2023-04-22 19:39:18.961 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got key negotiation response
2023-04-22 19:39:18.999 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Connecting to sub-device 02f8 via bf5417442785995d41uqyc
2023-04-22 19:39:19.000 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Dispatching request request_add to gateway with content {'dps': {1: None, 3: None, 4: None, 21: None}}
2023-04-22 19:39:19.002 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] decrypted session key negotiation step 2: payload=b'695ff7f5b704beb9\x1dt.\xb3\xd1hU\xf1w\x86\xca\xf0\xfbG\xabj&\x04M\x95\xd3g\x13\tK\xb14\x85\xc9\x1c\xe8S'
2023-04-22 19:39:19.003 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 5: b'\x04\x1b\xb4\xc8}\xb8K\x8d\xc6\xa0\xc1\xb8\xdb\x00\x88\x05\xd6\x01\x9a.\x1b[Db\xf0\xf0\xac\x85\xdb\x0bh\x85'
2023-04-22 19:39:19.005 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Session key negotiate success! session key: b'\x93\x19\xcf\xb2\x85#Ls\x1aZ^\xd8\xfd\x1d)\xf7'
2023-04-22 19:39:19.005 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:39:19.005 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload_dict for 'bf5417442785995d41uqyc' ('v3.4'/'v3.4'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_override': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
2023-04-22 19:39:19.006 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:19.006 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:19.009 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:39:19.009 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z\x1e\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xa1\xd1<\xdc\x0b\x90z-\x1cd\xc2\xb9~\xe00\xe49)/\x9e?\xcbg\x7f\x92\xfe\xc3\x06\xff\xbd\xfe\xce\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:39:19.011 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:39:19.016 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_add from 02f8 with content {'dps': {1: None, 3: None, 4: None, 21: None}}
2023-04-22 19:39:19.016 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_connected to sub-device 02f8 with data None
2023-04-22 19:39:19.017 INFO (MainThread) [custom_components.localtuya.common] [bf5...qyc] Getting status for 02f8
2023-04-22 19:39:19.017 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 16 (device type: v3.4)
2023-04-22 19:39:19.017 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"cid":"02f8"}'
2023-04-22 19:39:19.017 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 16: b'{"cid":"02f8"}'
2023-04-22 19:39:19.017 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [02f...2f8] Received event event_connected from gateway with data None
2023-04-22 19:39:19.021 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23071
2023-04-22 19:39:19.021 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z\x1f\x00\x00\x00\x10\x00\x00\x004\x1b1\\\x98\x08R\xac\xd4?|b\x8e.\x99\xf7\x17;\n\xfbNz^\xef\xa0\x10\xca>\xb5\xa9^\x8cg\xbc+\x11\x88\xe4\x94\xad\xdevo\xb4l\xce-\xbcP\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"02f8"}')
2023-04-22 19:39:19.022 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 16 waiting for sequence number 23071
2023-04-22 19:39:19.251 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23070, cmd=9, retcode=0, payload=b'', crc=b'\x8a\xd5\x01\xc3u\xf8\xaf\xbbzd\xa2k\xc4\xfcE\xe1\x9a\xee*w\xa5\x06Z\xe1\x8a\x9f\x9e\x80 \xdc\xdc\x1a', crc_good=True)
2023-04-22 19:39:19.251 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:39:19.251 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 16 TuyaMessage(seqno=23071, cmd=16, retcode=0, payload=b"e91sF\xb3\n\xf58\xad&@\xb7\x7f)\xbf\xfb\xa7\xf1\xba\xee\x17\xffS\xe5\xa5C\xb2f\xb0\xa2\x86\xf1\x81~\xf4\x7f\xc0\x1e\xf4\xda\xa5T\x94R\xf2\xda\xcdm\x88'\x9f/\xe0[T\xc8\xfd\xd3\xd7)8\xef\xbe", crc=b'A\x8a(\xec3\x07\x84*\xfd\x16;\x8c\xfd\x02\xa9H\xcba\xef\xcd\x13\x01P\x9d\xeaS\xea\xd4p\xa0\xfcS', crc_good=True)
2023-04-22 19:39:19.251 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23071
2023-04-22 19:39:19.304 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:39:19.305 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Deciphered data = '{"dps":{"1":false,"2":"white","3":10,"4":0},"cid":"02f8"}'
2023-04-22 19:39:19.305 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_status_updated to sub-device 02f8 with data {'1': False, '2': 'white', '3': 10, '4': 0}
2023-04-22 19:39:19.317 DEBUG (SyncWorker_3) [custom_components.localtuya.common] [02f...2f8] Received event event_status_updated from gateway with data {'1': False, '2': 'white', '3': 10, '4': 0}
2023-04-22 19:39:19.318 WARNING (SyncWorker_3) [custom_components.localtuya.light] [02f...2f8] Entity light.living_room_spotlight_7_1 is requesting unknown DPS index 21
2023-04-22 19:39:19.328 WARNING (SyncWorker_3) [custom_components.localtuya.light] [02f...2f8] Entity light.living_room_spotlight_7_1 is requesting unknown DPS index 21
2023-04-22 19:39:19.443 INFO (MainThread) [custom_components.localtuya.light] [02f...2f8] Entity Living-room-spotlight-7-1 - Additional attributes: {'raw_state': False}
2023-04-22 19:39:29.306 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:39:29.307 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:29.307 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:29.309 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:39:29.309 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z \x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xa2\x02\x12y.+q5fv\xea\xec|\xafI\xa0\xd1B\xec\xab\xdd\x8b}\xbdFD\xcd_\xe3\x99*\xcc\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:39:29.310 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:39:29.338 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23072, cmd=9, retcode=0, payload=b'', crc=b'\x12\xca\xf4x\xb8\xdag\x91>YT\xe6\xb6\x9dL\x12zE\x16\xe8\xcf}l\xc6\x91\xaf\x1c\x7f\x04\x9e-\x19', crc_good=True)
2023-04-22 19:39:29.338 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:39:29.339 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:39:39.340 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:39:39.340 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:39.340 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:39.342 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:39:39.342 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z!\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xffH8\xedc\xc8v\xfa\x89\xb5:\x87\xda\xfd\x03\xd6\xa9JM\x8f\xb9\xec\x03J\x1f6\x02/\x1c\xe7?1\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:39:39.344 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:39:39.373 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23073, cmd=9, retcode=0, payload=b'', crc=b'F\xb8j|\xe4\x97\xc4\xdc\xe8\x9b\xb1\xe1\xcc\xae\xf8\x86%\xab\x90\xden)\xf3\xb1\x83\x04F\x83W=\xf8\xeb', crc_good=True)
2023-04-22 19:39:39.374 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:39:39.375 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:39:49.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:39:49.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:49.377 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:49.379 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:39:49.379 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z"\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xb2h\xaa\x1e\xfe\xc4\xd3$\x8f\xbcw\xabZ"eH\x00\xa8\xdc\xfe\xbc\xc6X\x9bf\xb2\xe4\xf2\\\xb9\xee<\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:39:49.380 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:39:49.408 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23074, cmd=9, retcode=0, payload=b'', crc=b"\xf9\xdc<u\xe9\xa1V\x90F\xd6\x95\xf4<\x9c*\x8d\x01\xbd!\x14<\x80 O\xc7\x10\x171\xc9'\x1e\xbb", crc_good=True)
2023-04-22 19:39:49.408 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:39:49.410 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:39:59.411 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:39:59.411 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:59.412 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:39:59.414 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:39:59.414 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z#\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\x19\x94Qz0\x1a\xa5~\x96Zw(\x1c\x88\xae\x9c\x87\xe8\xa3\xe9\x1eK\xc2g$8}$s\x8dAX\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:39:59.415 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:39:59.444 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23075, cmd=9, retcode=0, payload=b'', crc=b'n\x16]\x16\xd9R)d\xba\xa7\xd8>\xdb\xd6\xf0\xb5\xbf\xaf\x00*Fu:U\xc1\xe5F*R\xe8\x87\xe0', crc_good=True)
2023-04-22 19:39:59.445 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:39:59.447 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:40:09.448 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:40:09.448 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:09.448 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:09.450 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:40:09.450 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z$\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\x98\x865\xe0\xe9\xe2\x9a(\xa8\xd2\xd2\xf0\x9b!\xc1\x07\x85\x8d\xc26\x98\xd6\xd0\x86\xa8\x91v\xebg\xa3~\xfd\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:40:09.451 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:40:09.478 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23076, cmd=9, retcode=0, payload=b'', crc=b'\xe0\xab\xea\xff`\xc0\xc6>I\xf3\x0b\x0e\x00\xa3e4\xee\x9f\xad\x9b\x94QC\xf0Xn\xf6\x8a\xd6W\x0c;', crc_good=True)
2023-04-22 19:40:09.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:40:09.479 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:40:19.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:40:19.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:19.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:19.483 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:40:19.483 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z%\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xd8\xb2\x03\xe7\xd4\x19a#_:\x0e\xfc[\xa2\xcc\xa2\xad\xb6\x9f\x04k*\x8c\xec\x03\xca>\xbc\x8f\x18MS\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:40:19.485 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:40:19.509 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23077, cmd=9, retcode=0, payload=b'', crc=b'\x8e\xc2.\x0e\xc7i\xe2|b\xd5I)\xd8\xb6$\xb3\x99m\xef-\xca\xb0\xa5\xafwa\x10\xe4R\x8b\x9aM', crc_good=True)
2023-04-22 19:40:19.509 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:40:19.510 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:40:29.514 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:40:29.515 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:29.515 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:40:29.517 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:40:29.518 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z&\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xeb\xf4S\xb7b\t\xdbL\xd7\x02\xf6\xd9\xf2s\xe7\xc6w\x9d\xb8 o\x86VA\x02\x86\xaf\x1b\x92\x8b\x96-\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:40:29.519 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:40:29.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23078, cmd=9, retcode=0, payload=b'', crc=b'\xf9\x87\xe9\xa8\xcd|\x89\xcf*mzI\xa1c{\xe0j\xb7Z\rH>\xac\xdc\xa5\xe4\x18T\x12\xe3.e', crc_good=True)
2023-04-22 19:40:29.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:40:29.554 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it

When I try to turn on the light, my logs:

2023-04-22 19:42:39.975 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:42:39.976 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:42:39.976 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:42:39.978 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:42:39.978 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z3\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\x12\x9fe\xebIG\x82t\x02\xec,\x92\xc4\xea0\x01\xb9\xe2t\xa9\xf2\xe2R.Lg\xdb\xa4zD]!\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:42:39.979 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:42:40.009 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23091, cmd=9, retcode=0, payload=b'', crc=b'W\x0e\x8c!\xc4\x95`\xd9\x14\x87\xf3=Z\x08\xceu=w\xb5\x88\x12\xeaY\xfa\x1czl\x9d\x92\xc5,\xae', crc_good=True)
2023-04-22 19:42:40.009 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:42:40.010 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:42:41.200 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Dispatching request request_set_dps to gateway with content {'dps': {1: True}}
2023-04-22 19:42:41.200 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_set_dps from 02f8 with content {'dps': {1: True}}
2023-04-22 19:42:41.201 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 7 (device type: v3.4)
2023-04-22 19:42:41.201 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"protocol":5,"t":1682181761,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 19:42:41.201 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 13: b'3.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"protocol":5,"t":1682181761,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 19:42:41.202 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23092
2023-04-22 19:42:41.202 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z4\x00\x00\x00\r\x00\x00\x00\x84\xf8AO*\xfeC|\x08\x06\xceo(\xdc%\xca\x98\x92\xea\x8aF\xbe 4M\xe7\x83\x9d\x1f\xcd\x90\xde\x90O\xd9s\x90@\xe83\x04\x84\xb7u\xc1\xab\xe4\x12\xac\x14\xac\x1c\x12\xb3Z7\xcb\xd9\x80),o\xd6D\xf1\xcb P\xd7\xf6\xc5!\x99\xa4z\xd4\xe0\x10oF\xcb\x17\x97`XP\x0ej\xbd\xdf\x89T\x91Y\xfc\x80\xa6\x99yhw\xa4S\xd05\x80~\xd9/"=\xf2\x0f\x8c\xa7\xb3\x8c\xd5\xea\xdb\x83/\x9e\xffN?\xe9\x1b\x8e\x00\x00\xaaU' - MessagePayload(cmd=13, payload=b'{"protocol":5,"t":1682181761,"data":{"dps":{"1":true}},"cid":"02f8"}')
2023-04-22 19:42:41.203 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 13 waiting for sequence number 23092
2023-04-22 19:42:41.243 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 13 TuyaMessage(seqno=23092, cmd=13, retcode=0, payload=b'', crc=b'8:\x80\x87\xe7\xd6\x8d\x80\xb3\x1f\x16\xa0_4\x02\x15\x8e\x08\xa6\xc2\x9dT\x9c\x80\x1d`\x98\xe9]\x99\x0c5', crc_good=True)
2023-04-22 19:42:41.243 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23092
2023-04-22 19:42:41.244 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 13: ignoring it
2023-04-22 19:42:50.012 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:42:50.013 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:42:50.013 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:42:50.014 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:42:50.014 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z5\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~\xad\x1f#"\xea\xed\x06#D\x90\xc5\xb99\xde\xba\x1cr|]\xfa+\x0b\x03h\xbe\x0c3\xe4@\xde\x8c\x1a\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:42:50.015 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:42:50.041 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23093, cmd=9, retcode=0, payload=b'', crc=b'\x99\xe5\xfa\xa7\xf9\x918\x11\xd0\x12I\x83\x9b7\xde>78\xd0\xf9(Sw*\x14|y\xf5I\xd7\xfc\xe2', crc_good=True)
2023-04-22 19:42:50.041 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:42:50.042 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:42:58.438 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Dispatching request request_set_dps to gateway with content {'dps': {1: True}}
2023-04-22 19:42:58.438 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_set_dps from 02f8 with content {'dps': {1: True}}
2023-04-22 19:42:58.439 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 7 (device type: v3.4)
2023-04-22 19:42:58.439 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"protocol":5,"t":1682181778,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 19:42:58.439 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 13: b'3.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"protocol":5,"t":1682181778,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 19:42:58.440 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23094
2023-04-22 19:42:58.440 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z6\x00\x00\x00\r\x00\x00\x00\x84\xf8AO*\xfeC|\x08\x06\xceo(\xdc%\xca\x98\x92\xea\x8aF\xbe 4M\xe7\x83\x9d\x1f\xcd\x90\xde\x90lg\xcb\x96\x10\xc7ID\x9b\xaex\'\xc1\x9b^"\x14\xac\x1c\x12\xb3Z7\xcb\xd9\x80),o\xd6D\xf1\xcb P\xd7\xf6\xc5!\x99\xa4z\xd4\xe0\x10oF\xcb\x17\x97`XP\x0ej\xbd\xdf\x89T\x91Y\xfc\x80\xa6\xa3\x92\xfbQB\x03\x9e\xf9\xae9\xf2\xfaD\xed \xb9Ii\xee\xa4&\xe4\xc7\x1a\xac+\xaa\xb8F\xa4\x90(\x00\x00\xaaU' - MessagePayload(cmd=13, payload=b'{"protocol":5,"t":1682181778,"data":{"dps":{"1":true}},"cid":"02f8"}')
2023-04-22 19:42:58.440 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 13 waiting for sequence number 23094
2023-04-22 19:42:58.454 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 13 TuyaMessage(seqno=23094, cmd=13, retcode=0, payload=b'', crc=b'\x81\xb2\xfc\xe97C\x19\xfa\x82Gb\xab\x0c\xcb\x14l\x1aP\xaa\\\x11\x12\x997\xca\xa9\x0e5zuV\x12', crc_good=True)
2023-04-22 19:42:58.454 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 23094
2023-04-22 19:42:58.455 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 13: ignoring it
2023-04-22 19:43:00.043 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:43:00.044 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:43:00.044 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:43:00.045 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:43:00.045 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00Z7\x00\x00\x00\t\x00\x00\x00tV\x9dYt\x12\x98@ T*\xa3<~*;\x1bL\xc7\xf7k+[V\xcb\xac8\xd2I\x14\xa6\xce\x07\xdcW\x1b\xe8\xa0\xbcA\xf4\x17\xd5)?\x1c\xfc\xca d\xb5\xa7\x7f?\x14wn,=;\xdc\xed-\xe88\xdf;s\xaft\x83\xd5\n\xf4\xeb\x9d\x88)\xce\x85~4\x83\x08+\x8ev\xff\x90hBA:*\xec\xb6\xa4\xf6\t\x8cl\xda\xc81|2\x95\xeaY\x18H\x15\xab\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:43:00.047 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:43:00.079 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=23095, cmd=9, retcode=0, payload=b'', crc=b'\xa1Ap}K\xd4\x9d\x19+E\x1a!\xdc\xb43\xac-_\x0f\xd8\xc8\xdcM\xca \x05}E\xcb\xce\xfd\xf2', crc_good=True)
2023-04-22 19:43:00.080 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:43:00.082 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it

The situation is very similar to this one which was in the 3.3 protocol and the beta version (https://github.com/leeyuentuen/localtuya/issues/39#issuecomment-1501837303). However, when i run 3.6.6 version this issue has been solved.

And since I see you've been talking about beta 8, I tried that too, however the situation is the same as with 10. When start home assistant:

2023-04-22 19:48:39.138 DEBUG (MainThread) [custom_components.localtuya.discovery] Listening to broadcasts on UDP port 6666 and 6667
2023-04-22 19:48:39.291 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connecting to gateway 192.168.20.126
2023-04-22 19:48:39.396 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Connected to gateway 192.168.20.126 successfully
2023-04-22 19:48:39.396 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Attempting to reconnect 0 subdevices
2023-04-22 19:48:39.399 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Started heartbeat loop
2023-04-22 19:48:39.400 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] 3.4 device: negotiating a new session key
2023-04-22 19:48:39.400 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 3: b'0123456789abcdef'
2023-04-22 19:48:39.402 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 3 waiting for sequence number -102
2023-04-22 19:48:39.549 DEBUG (MainThread) [custom_components.localtuya.light] [02f...2f8] Adding light.living_room_spotlight_7_1 with configuration: OrderedDict([('platform', 'light'), ('friendly_name', 'Living-room-spotlight-7-1'), ('id', 1), ('brightness', 3), ('brightness_lower', 10), ('brightness_upper', 1000), ('color_mode', 21), ('color_temp', 4), ('color_temp_min_kelvin', 3000), ('color_temp_max_kelvin', 6000), ('music_mode', False), ('color_temp_reverse', False)])
2023-04-22 19:48:39.549 DEBUG (MainThread) [custom_components.localtuya.light] [02f...2f8] Restoring state for entity: Living-room-spotlight-7-1 - state: False
2023-04-22 19:48:39.894 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 4 TuyaMessage(seqno=29661, cmd=4, retcode=0, payload=b'\xa8\xb2\xa7\x1c\xf6\xaa!\xa66r\xc3R\xeb\xa3\x19\x8c\xae\xe6 \x9fd\xb1B\xf7\x03n&S\x03\xd4\x93\x85\xfd\xe5=P\x97\x1990F\x9a\x16\xfc\nM$\xb3\x96\x8f\xa9\xe5\x95\xc9\xa1\x03\x00Q\xb6,\xa2~R;', crc=b'>R\xf4\xf71\xbb\xbd\xc4b5y\xab_B\xc2\x0c\xd7 \x9bv\xd1\xe2\xfb\xec\t\xfb\x95\xacf\x99\x04\x01', crc_good=True)
2023-04-22 19:48:39.894 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got key negotiation response
2023-04-22 19:48:39.913 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] decrypted session key negotiation step 2: payload=b'c2b998627d8d9712\x1dt.\xb3\xd1hU\xf1w\x86\xca\xf0\xfbG\xabj&\x04M\x95\xd3g\x13\tK\xb14\x85\xc9\x1c\xe8S'
2023-04-22 19:48:39.915 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 5: b'\xcenK+\x1b\xda\xb7{\xdfC\xe6\xe9#\xaf\xb9\x99 \xb6\xbf\x12\x19}\xba]\x9b\x0f\x1c\xa6B\x8c7s'
2023-04-22 19:48:39.917 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Session key negotiate success! session key: b'\xd1\x04u\x8d\xf8\xa47G\xc6\x99\xe5\x06&s\x89\x80'
2023-04-22 19:48:39.917 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:48:39.917 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload_dict for 'bf5417442785995d41uqyc' ('v3.4'/'v3.4'): {1: {'command': {'gwId': '', 'devId': '', 'uid': '', 't': ''}}, 7: {'command': {'protocol': 5, 't': 'int', 'data': {}}, 'command_override': 13}, 8: {'command': {'gwId': '', 'devId': ''}}, 9: {'command': {'gwId': '', 'devId': ''}}, 10: {'command': {}, 'command_override': 16}, 13: {'command': {'protocol': 5, 't': 'int', 'data': {}}}, 16: {'command': {}}, 18: {'command': {'dpId': [18, 19, 20]}}, 64: {'command': {'reqType': '', 'data': {}}}}
2023-04-22 19:48:39.917 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:48:39.918 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:48:39.920 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:48:39.921 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b"\x00\x00U\xaa\x00\x00s\xde\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*\x87\xd5`t\x86[\xf7\xb4\xad\x1a?h\x08\x15\xb5@\x13\xa9l\xef\x7f\xe8\xa7\xb1\xad'uW\xeb\xbfZ\xf7\x00\x00\xaaU" - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:48:39.922 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:48:39.930 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Connecting to sub-device 02f8 via bf5417442785995d41uqyc
2023-04-22 19:48:39.932 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Dispatching request request_add to gateway with content {'dps': {1: None, 3: None, 4: None, 21: None}}
2023-04-22 19:48:41.464 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_add from 02f8 with content {'dps': {1: None, 3: None, 4: None, 21: None}}
2023-04-22 19:48:41.464 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_connected to sub-device 02f8 with data None
2023-04-22 19:48:41.464 INFO (MainThread) [custom_components.localtuya.common] [bf5...qyc] Getting status for 02f8
2023-04-22 19:48:41.464 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 16 (device type: v3.4)
2023-04-22 19:48:41.464 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"cid":"02f8"}'
2023-04-22 19:48:41.464 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 16: b'{"cid":"02f8"}'
2023-04-22 19:48:41.465 DEBUG (SyncWorker_3) [custom_components.localtuya.common] [02f...2f8] Received event event_connected from gateway with data None
2023-04-22 19:48:41.465 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 29663
2023-04-22 19:48:41.466 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00s\xdf\x00\x00\x00\x10\x00\x00\x004\x87+&\xb2\xa8W\xe4\xb7t\xf4\xb0LL\x92!l\xdd\xd8a\x18\xf4\xafs)b\xb1\x0f\xd9\xf8\xd6\x0e*\x15\x8a\xf6\x9e\x18\x0fM2\xf6\xaf\xc3\x96\x0ev\xee\x10\x00\x00\xaaU' - MessagePayload(cmd=16, payload=b'{"cid":"02f8"}')
2023-04-22 19:48:41.466 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 16 waiting for sequence number 29663
2023-04-22 19:48:41.471 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29662, cmd=9, retcode=0, payload=b'', crc=b'f\xd2~499O\x8f\n\x98ox\x01\xdc\\\x89.\xe0\x97\r+>\x8f\x99\xfa\x8bS%\x05;\xd4!', crc_good=True)
2023-04-22 19:48:41.471 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:48:41.496 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 16 TuyaMessage(seqno=29663, cmd=16, retcode=0, payload=b"h\xb1\x186\x19\xdc\x8c\xa1Hs\xd1\xa1\x05^,\xd7\xac\xf6\xe2Y\xca\xfb\xe5\xf6'\x16\xa2~\r\xe5\xa9\x89\x81pf4N\xe5\xe2zh\xbbP\xb7\xc9\xfb9\x08\x03\xb5\x9a\xc9\x1f\xac\xf2\xbe\xb7_\x97\x07\xdc\xbdP\xf0", crc=b'\x1c)\xc97\xb5,>\x8c/\x10\xe1\xc4\x92\x8b\x15\x9f\x08\x19\x9e\xad\x9e%\xab\x9a7\xb3L\xeb"_\xce\xd1', crc_good=True)
2023-04-22 19:48:41.496 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 29663
2023-04-22 19:48:41.499 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:48:41.991 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Deciphered data = '{"dps":{"1":false,"2":"white","3":10,"4":0},"cid":"02f8"}'
2023-04-22 19:48:41.991 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Dispatching event event_status_updated to sub-device 02f8 with data {'1': False, '2': 'white', '3': 10, '4': 0}
2023-04-22 19:48:41.992 DEBUG (SyncWorker_2) [custom_components.localtuya.common] [02f...2f8] Received event event_status_updated from gateway with data {'1': False, '2': 'white', '3': 10, '4': 0}
2023-04-22 19:48:41.992 WARNING (SyncWorker_2) [custom_components.localtuya.light] [02f...2f8] Entity light.living_room_spotlight_7_1 is requesting unknown DPS index 21
2023-04-22 19:48:41.998 WARNING (SyncWorker_2) [custom_components.localtuya.light] [02f...2f8] Entity light.living_room_spotlight_7_1 is requesting unknown DPS index 21
2023-04-22 19:48:42.101 INFO (MainThread) [custom_components.localtuya.light] [02f...2f8] Entity Living-room-spotlight-7-1 - Additional attributes: {'raw_state': False}
2023-04-22 19:48:51.510 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:48:51.510 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:48:51.517 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:48:51.518 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:48:51.518 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00s\xe0\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*R\x86\xfb\xc2\xa1\xa8S\x12\xe0X#\xbf@1\x12\xe0\xb9\xc5\xdcO\x12l\xd8\x87\x9a\xe7\x0fr\xb0\xe4\xc4\x1b\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:48:51.518 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:48:51.526 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29664, cmd=9, retcode=0, payload=b'', crc=b'#\xc4\xd7\xb7\xc9\xdf\x1eYo\xba\xafwQ\xb8m\xaf\xdcf%\xba\xa4x\xb3\xff\xe4k?S\x1a\xab0\\', crc_good=True)
2023-04-22 19:48:51.527 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:48:51.527 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:49:01.528 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:49:01.528 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:01.528 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:01.528 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:49:01.528 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00s\xe1\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*\x8b\x9b\xa0\x99\x95\xaa\xb0\x0c\x12\xf1X"\x85\xc5\xf8\x07\x03\xf6\xaa\xf5\xc9\xf9]B\x03\x80u\xe9H\xbf_\x90\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:49:01.529 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:49:01.547 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29665, cmd=9, retcode=0, payload=b'', crc=b'Wae)x\x9d0\xfe\xba\xe4\xc0\x7f+\x00\xc9g\xe9f\x93O\x8f(\xa3@\xcd2\xd0\xf9\xa5\xfcI5', crc_good=True)
2023-04-22 19:49:01.547 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:49:01.548 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:49:11.550 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:49:11.550 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:11.551 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:11.552 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:49:11.552 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b"\x00\x00U\xaa\x00\x00s\xe2\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*A\xb3A\x83\x85\x85\xc9\xf3\x7f\xe2\x06\xf3$\xe7\xbd\xe0\xe7\x8f\x84\xc8'\x87\xbb\xfal\x85\xcdF\xbbi\x9c\xee\x00\x00\xaaU" - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:49:11.553 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:49:11.592 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29666, cmd=9, retcode=0, payload=b'', crc=b'\x16>\xd7\xd7\xf4U-\xa6\x1e\x1f\x187\x0c\xaa+\xec&\xa5\x18\x8f\x8f\x87\xcb\xf8\xec]\xca\x16x\xfb\x0c\x0e', crc_good=True)
2023-04-22 19:49:11.593 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:49:11.594 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it
2023-04-22 19:49:21.596 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 19:49:21.597 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:21.597 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 19:49:21.598 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 19:49:21.598 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b"\x00\x00U\xaa\x00\x00s\xe3\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*\x17\xe1\xd4\xd9\x95\x06\x9a!\xcd;z'\x19\xd8\xbb\xb2*\x0fo\x0fU\xf1\x8eW\x83'\x08\xb5\xf6\x11\xa1h\x00\x00\xaaU" - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 19:49:21.599 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 19:49:21.620 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29667, cmd=9, retcode=0, payload=b'', crc=b'ns\xee\xbdG\x87g\x85\x82(\nj\x82{N \x17\xf8D\t\xc9 \x0b\x9e\xde\xd1X\xc2\xcf\xe0\x1a\xb2', crc_good=True)
2023-04-22 19:49:21.620 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 19:49:21.620 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it

When trying to turn on the light

2023-04-22 20:07:45.539 DEBUG (MainThread) [custom_components.localtuya.common] [02f...2f8] Dispatching request request_set_dps to gateway with content {'dps': {1: True}}
2023-04-22 20:07:45.540 DEBUG (MainThread) [custom_components.localtuya.common] [bf5...qyc] Received request request_set_dps from 02f8 with content {'dps': {1: True}}
2023-04-22 20:07:45.540 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 7 (device type: v3.4)
2023-04-22 20:07:45.540 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"protocol":5,"t":1682183265,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 20:07:45.540 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 13: b'3.4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{"protocol":5,"t":1682183265,"data":{"dps":{"1":true}},"cid":"02f8"}'
2023-04-22 20:07:45.541 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 29787
2023-04-22 20:07:45.541 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00t[\x00\x00\x00\r\x00\x00\x00\x84\x94*\xbeH\xda\xc8\x80q\xea\x84.z\xbb\xc6\xcaI\xcfyp\xe6\x89s_\x01\x8cVf\xf6\xc4\xd5\xea\xb0t\xadz]\xaa\x0b\xea\x08\x85\xa9R"\x84\x95}\xf1\x8bh\xef\xf6&\x10\x04y*\x13\xba\x95\x83\x05\x0f\xc6Hpf\x0f \xa5\xfc\x1d00\xcev\x89\xcd\xcf>\xa9q\xe7\xd8\xeb\x98\x0fD\xb4\x983\xce>\xe9\xd0?\x7f\xb9=6\x8b\x7f\xcf\x8a\xcf\x1a!\xd2?\xfe\xc0\x17\xb9\x81\xa9\xc3)\x045g\xb4\x94\x1eC\xc9PaM\x00\x00\xaaU' - MessagePayload(cmd=13, payload=b'{"protocol":5,"t":1682183265,"data":{"dps":{"1":true}},"cid":"02f8"}')
2023-04-22 20:07:45.541 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 13 waiting for sequence number 29787
2023-04-22 20:07:45.596 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 13 TuyaMessage(seqno=29787, cmd=13, retcode=0, payload=b'', crc=b'ez\xe5\xd3\xd2\xca)LU\x98\x08\x81\x03\xa0\x11z\xfd\xaf-r\xff\x15\xe9U?x\xe6\xafJ\xd0v\xde', crc_good=True)
2023-04-22 20:07:45.596 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number 29787
2023-04-22 20:07:45.597 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 13: ignoring it
2023-04-22 20:07:45.870 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending command 9 (device type: v3.4)
2023-04-22 20:07:45.870 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Sending payload: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 20:07:45.871 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] final payload for cmd 9: b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}'
2023-04-22 20:07:45.873 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching sequence number -100
2023-04-22 20:07:45.873 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] payload b'\x00\x00U\xaa\x00\x00t\\\x00\x00\x00\t\x00\x00\x00t\x1e\xfb\xfd\xec#\xc5z\xc6\xf8g\xa7\xac\xf0\x1dXO\x04\xa3\xfb\r\x19\x95\xf8\xa8\x85pr\x8e\x08\xbb\x06s\xf1>4\xb5Mp\xcbs`\xea\x9d7:\x86\xca\xd1[l\x85CZr\x08U`:\x93\xba\x17\xba]\xde\xf4\xac\xa4\x10\xd2\xabB\x91\x10q\xedE\xe6\x064*b\xb9\x06\x02\xe5\x88\rlu@]\x03o\xd7P\x10\xfa\xf9\x02\xaf\x8fO\xd88W\xe0\xea.V\xd0z\x8a\x00\x00\xaaU' - MessagePayload(cmd=9, payload=b'{"gwId":"bf5417442785995d41uqyc","devId":"bf5417442785995d41uqyc"}')
2023-04-22 20:07:45.874 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Command 9 waiting for sequence number -100
2023-04-22 20:07:45.898 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Dispatching message CMD 9 TuyaMessage(seqno=29788, cmd=9, retcode=0, payload=b'', crc=b'\xd0h.\x8e\x90\xec\x0e~\x9f\xd3=\x92\xdf\xc4p\xa8 (\x06\xf3+\xd6\x19U\x8c\xf8\n\xf4\x04\xe9\xc2v', crc_good=True)
2023-04-22 20:07:45.898 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] Got heartbeat response
2023-04-22 20:07:45.900 DEBUG (MainThread) [custom_components.localtuya.pytuya] [bf5...qyc] ACK received for command 9: ignoring it

@alexualbu

alexualbu commented 1 year ago

@mariustt , i see nothing wrong in the logs at first sight. i believe the first matter at hand would be to confirm the dp1 is the actual switch control - can you try to set it tuyaapi-cli ?

mariustt commented 1 year ago

@alexualbu can you provide more details/some links to what I should to do with the tuyaapi-cli, please? I've never used this lib before.

If I understand correctly you are not sure if I am using a a correct entities.id? Should it not be 1? All information about the devices I took from iot.tuya.com

image

alexualbu commented 1 year ago

@mariustt, you have installation and usage instructions at https://github.com/TuyaAPI/cli . You'll need node and npm installed. Then you can do something like the below to get DPs

tuya-cli get --id <gw_dev_id> --key <gw_local_key> --cid <sub-device_cid_or_node_id> --protocol-version 3.4 --ip <gw_ip> --full

and something like this to update a DP:

tuya-cli set --id <gw_dev_id> --key <gw_local_key> --cid <sub-device_cid_or_node_id> --protocol-version 3.4 --ip <gw_ip> --set <value> --dps <dp_id>

If you change the values from SmartLife then use tuya-cli get you can see how the actual dps change. Then you can use set to try and change them yourself. What we can find out is if everything works as expected with tuya-cli then it's likely a localtuya issues, but we have the dps and values confirmed.

mariustt commented 1 year ago

@alexualbu thanks!

I checked the situation and it is very strange. When I use the GET command with 3.4 nothing happens. When I try to do the same with 3.3, I get response. Then if I try SET, it seems to work and the homeassistant information is updated (information in the gif when I use the SET command).

image

turn-on-off

Just one more interesting thing - after starting localtuya-3.7.0-beta.8 light entity was unavailable. But when I opened the Tuya App and went to gateway settings home assistant everything was fine (despite the fact that I can't turn on/off the lights).