Localtuya - adding Hama Wlan led light

Hello,

I went through a lot of threads before posting. I hope this will be helpful for someone one day :slight_smile:

I was trying to get working this light (sorry, in French) from Hama with localtuya.

The light was not detected and I had to add it manually. I was facing this issue: Connection to device succeeded but no datapoints found, please try again.

  • I could control it wth Tuya Smart
  • I got the local key on Tuya Cloud and did the bindings.
  • When I try to add it, I hadto use DP=1 to have the addition process working (like suggested on the thread above).
  • in HA/integrationm the light stays in unavailable state. With or without Internet Access.

So, I though I would give a try to tuyadebug to see if I could get the DataPoints. (you need the cryptography python module to work. pip install cryptography)

Here’s the result I got

 ./test.py d8d812110e692eb5 192.168.10.27 d8d812110e692eb5 3.3
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.10.10 (main, Feb  9 2023, 02:08:14) [GCC 12.2.1 20220924] on linux
INFO:localtuya:Using pytuya version '10.0.0'
INFO:localtuya:Detecting list of available DPS of device d8d812110e692eb5 [192.168.10.27], protocol 3.3.
DEBUG:localtuya.pytuya:[d8d...eb5] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[d8d...eb5] Sending payload: b'{"gwId":"d8d812110e692eb5","devId":"d8d812110e692eb5","uid":"d8d812110e692eb5","t":"1679991083"}'
DEBUG:localtuya.pytuya:[d8d...eb5] Command 10 waiting for sequence number 1
DEBUG:localtuya.pytuya:[d8d...eb5] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\xd2\xd6\xf35{o\x9d/\xcb\x9fD\xef\x8cu\xee\xc9', crc=2359914270, crc_good=True)
DEBUG:localtuya.pytuya:[d8d...eb5] Deciphered data = 'gw id invalid'
DEBUG:localtuya.pytuya:[d8d...eb5] ERROR Invalid JSON Response from Device - 900 - payload: "gw id invalid"
AVAILABLE DPS ARE [{}]
INFO:localtuya:COMPLETE response from device d8d812110e692eb5 [192.168.10.27].

**** deviceInfo returned OK ****

TuyaDebug (Tuya DPs dump) [1.0.0]

Device d8d812110e692eb5 at 192.168.10.27 key d8d812110e692eb5 protocol 3.3 dev_type type_0a:

test.py script seems to use the local_key as a gw id and the light seems not to like it. (issue opened)

test_tinytuya uses device_id instead., which seems to provide better results

./test_tinytuya.py 45245008483fdaab6b3e 192.168.10.27 d8d812110e692eb5 3.3
DEBUG:tinytuya.core:tinytuya.core version 1.9.1
DEBUG:tinytuya.core:Python 3.10.10 (main, Feb  9 2023, 02:08:14) [GCC 12.2.1 20220924] on linux
DEBUG:tinytuya.core:Using pyaes version [1, 3, 0]
DEBUG:tinytuya.core:Using pyaes from '/usr/lib/python3.10/site-packages/pyaes/__init__.py'
TinyTuya (Tuya Interface) [1.9.1]

TESTING: Device 45245008483fdaab6b3e at 192.168.10.27 with key d8d812110e692eb5 version 3.3
DEBUG:tinytuya.core:status() entry (dev_type is default)
DEBUG:tinytuya.core:building command 10 payload=b'{"gwId":"45245008483fdaab6b3e","devId":"45245008483fdaab6b3e","uid":"45245008483fdaab6b3e","t":"1679993289"}'
DEBUG:tinytuya.core:sending payload
DEBUG:tinytuya.core:payload encrypted=b'000055aa000000010000000a00000078e93ef7b77dedecbcf8116c6001c518e35ab6bf2781eab0d3fa0b72da7679703efc47563dfeb479446b6e9fd561256449c8b489cac456caaee632b4803d64c65776ca4ec404d15ab2cf985c91d4c0fedf76534d83c14fde642fe7c40fe2c313bdc53b83d621b177acba2c3dcf9236859482fecd2b0000aa55'
DEBUG:tinytuya.core:received data=b'000055aa000000010000000a0000008c00000000fe65f4e58f6391bd7994101530012c41fd925714ca2fc533431850a5fbc79722bf9ec485b690e7f52b652ee6e95fde1ffed3aaa44ab8a3c2b8d327cf85feb94fac084a5941ad0a03fbe8fddb56a5d9108983a89aad16a1079274233b42efb52eaad6279e327ae1cd81b957f29a83029f69034f21fa084f30995fd12cf7c405877a5a3ce50000aa55'
DEBUG:tinytuya.core:received message=TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b'\xfee\xf4\xe5\x8fc\x91\xbdy\x94\x10\x150\x01,A\xfd\x92W\x14\xca/\xc53C\x18P\xa5\xfb\xc7\x97"\xbf\x9e\xc4\x85\xb6\x90\xe7\xf5+e.\xe6\xe9_\xde\x1f\xfe\xd3\xaa\xa4J\xb8\xa3\xc2\xb8\xd3\'\xcf\x85\xfe\xb9O\xac\x08JYA\xad\n\x03\xfb\xe8\xfd\xdbV\xa5\xd9\x10\x89\x83\xa8\x9a\xad\x16\xa1\x07\x92t#;B\xef\xb5.\xaa\xd6\'\x9e2z\xe1\xcd\x81\xb9W\xf2\x9a\x83\x02\x9fi\x03O!\xfa\x08O0\x99_\xd1,\xf7\xc4\x05\x87', crc=2052734181, crc_good=True)
DEBUG:tinytuya.core:raw unpacked message = TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b'\xfee\xf4\xe5\x8fc\x91\xbdy\x94\x10\x150\x01,A\xfd\x92W\x14\xca/\xc53C\x18P\xa5\xfb\xc7\x97"\xbf\x9e\xc4\x85\xb6\x90\xe7\xf5+e.\xe6\xe9_\xde\x1f\xfe\xd3\xaa\xa4J\xb8\xa3\xc2\xb8\xd3\'\xcf\x85\xfe\xb9O\xac\x08JYA\xad\n\x03\xfb\xe8\xfd\xdbV\xa5\xd9\x10\x89\x83\xa8\x9a\xad\x16\xa1\x07\x92t#;B\xef\xb5.\xaa\xd6\'\x9e2z\xe1\xcd\x81\xb9W\xf2\x9a\x83\x02\x9fi\x03O!\xfa\x08O0\x99_\xd1,\xf7\xc4\x05\x87', crc=2052734181, crc_good=True)
DEBUG:tinytuya.core:decode payload=b'\xfee\xf4\xe5\x8fc\x91\xbdy\x94\x10\x150\x01,A\xfd\x92W\x14\xca/\xc53C\x18P\xa5\xfb\xc7\x97"\xbf\x9e\xc4\x85\xb6\x90\xe7\xf5+e.\xe6\xe9_\xde\x1f\xfe\xd3\xaa\xa4J\xb8\xa3\xc2\xb8\xd3\'\xcf\x85\xfe\xb9O\xac\x08JYA\xad\n\x03\xfb\xe8\xfd\xdbV\xa5\xd9\x10\x89\x83\xa8\x9a\xad\x16\xa1\x07\x92t#;B\xef\xb5.\xaa\xd6\'\x9e2z\xe1\xcd\x81\xb9W\xf2\x9a\x83\x02\x9fi\x03O!\xfa\x08O0\x99_\xd1,\xf7\xc4\x05\x87'
DEBUG:tinytuya.core:decrypting=b'\xfee\xf4\xe5\x8fc\x91\xbdy\x94\x10\x150\x01,A\xfd\x92W\x14\xca/\xc53C\x18P\xa5\xfb\xc7\x97"\xbf\x9e\xc4\x85\xb6\x90\xe7\xf5+e.\xe6\xe9_\xde\x1f\xfe\xd3\xaa\xa4J\xb8\xa3\xc2\xb8\xd3\'\xcf\x85\xfe\xb9O\xac\x08JYA\xad\n\x03\xfb\xe8\xfd\xdbV\xa5\xd9\x10\x89\x83\xa8\x9a\xad\x16\xa1\x07\x92t#;B\xef\xb5.\xaa\xd6\'\x9e2z\xe1\xcd\x81\xb9W\xf2\x9a\x83\x02\x9fi\x03O!\xfa\x08O0\x99_\xd1,\xf7\xc4\x05\x87'
DEBUG:tinytuya.core:decrypted 3.x payload='{"devId":"45245008483fdaab6b3e","dps":{"20":true,"21":"white","22":1000,"23":770,"25":"020e0d0000000000000003e803e8","26":0}}'
DEBUG:tinytuya.core:payload type = <class 'str'>
DEBUG:tinytuya.core:decoded results='{"devId":"45245008483fdaab6b3e","dps":{"20":true,"21":"white","22":1000,"23":770,"25":"020e0d0000000000000003e803e8","26":0}}'
DEBUG:tinytuya.core:status() received data={'devId': '45245008483fdaab6b3e', 'dps': {'20': True, '21': 'white', '22': 1000, '23': 770, '25': '020e0d0000000000000003e803e8', '26': 0}}

READING TEST: Response {'20': True, '21': 'white', '22': 1000, '23': 770, '25': '020e0d0000000000000003e803e8', '26': 0}

With this last result and the details of the device below, I could assign the right datapoints for this light:

  • 20: state
  • 21: color mode
  • 22: brightness. Which I found working between 100 and 1000
  • 23: temperature/color value
  • 25: it is about scenes, like: read, night, day

    image

Here’s some details from Tuya on the device:

{
  "result": {
    "active_time": 1679928107,
    "biz_type": 0,
    "category": "dj",
    "create_time": 1679920324,
    "icon": "smart/icon/ay1531739836474naEnL/5241531b6ead278374950aa2fcc3c689.png",
    "id": "45245008483fdaab6b3e",
    "ip": "XXXXXX",
    "lat": "0.0000",
    "local_key": "xxxxxx",
    "lon": "0.0000",
    "model": "176563/176564",
    "name": "Rez",
    "online": true,
    "owner_id": "152255553",
    "product_id": "j9i0sfxozfllabuy",
    "product_name": "176563/64",
    "status": [
      {
        "code": "switch_led",
        "value": true
      },
      {
        "code": "work_mode",
        "value": "white"
      },
      {
        "code": "bright_value_v2",
        "value": 1000
      },
      {
        "code": "temp_value_v2",
        "value": 770
      },
      {
        "code": "scene_data_v2",
        "value": "{\"scene_num\":3,\"scene_units\":[{\"bright\":1000,\"h\":0,\"s\":0,\"temperature\":1000,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}"
      },
      {
        "code": "countdown_1",
        "value": 0
      },
      {
        "code": "control_data",
        "value": ""
      }
    ],
    "sub": false,
    "time_zone": "+01:00",
    "uid": "eu16799280184549lmA2",
    "update_time": 1679928110,
    "uuid": "45245008483fdaab6b3e"
  },
  "success": true,
  "t": 1679991836692,
  "tid": "e1ee4ccfcd4111ed93c90a3a7cc6963e"
}