xZetsubou / hass-localtuya

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

Battletron ball light always shows green as colour in HA #106

Closed hmmbob closed 8 months ago

hmmbob commented 9 months ago

The problem

We have 2 Battletron Ball Lights in our house, which are Tuya based. I can set them up in the component and they get detected nicely, however regardless what color we choose in Home Assistant it will always show as "green" in HA state. It does however change color if you click another color in HA, but in HA the color quickly returns to that bright green color again. So it is basically the "color state reporting" that goes wrong. Turning on/off is reliable and correct.

Environment

Steps to reproduce

  1. Install the hass-localtuya component
  2. Add the lights
  3. open the light to try and change color
  4. See that the light does change color physically, but isn't updating color in HA

image

DP dump

Could not get this to work - it can't connect

Provide Home Assistant traceback/logs

2024-01-11 17:13:46.079 DEBUG (MainThread) [custom_components.localtuya.common] [bfa...jdk] Closed connection with Battletron Ball Light T
2024-01-11 17:13:46.092 DEBUG (MainThread) [custom_components.localtuya.common] [bfa...jdk] Trying to connect to 192.168.88.248...
2024-01-11 17:13:46.391 INFO (MainThread) [custom_components.localtuya.cloud_api] Cloud API connection succeeded.
2024-01-11 17:13:47.381 DEBUG (MainThread) [custom_components.localtuya.common] [bfa...jdk] Success: connected to 192.168.88.248
2024-01-11 17:13:47.381 DEBUG (SyncWorker_4) [custom_components.localtuya.light] [bfa...jdk] None: is requesting unknown DP Value brightness
2024-01-11 17:13:56.610 DEBUG (SyncWorker_2) [custom_components.localtuya.light] [bfa...jdk] None: is requesting unknown DP Value brightness
2024-01-11 17:13:56.704 DEBUG (SyncWorker_16) [custom_components.localtuya.light] [bfa...jdk] None: is requesting unknown DP Value brightness
2024-01-11 17:14:00.053 DEBUG (SyncWorker_15) [custom_components.localtuya.light] [bfa...jdk] None: is requesting unknown DP Value brightness
2024-01-11 17:14:00.814 DEBUG (SyncWorker_14) [custom_components.localtuya.light] [bfa...jdk] None: is requesting unknown DP Value brightness

Additional information

Config data from Home Assistant:

{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2024.1.2",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.11.6",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "6.1.0-17-amd64",
    "run_as_root": true
  },
  "integration_manifest": {
    "domain": "localtuya",
    "name": "Local Tuya",
    "codeowners": [],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/xZetsubou/hass-localtuya/",
    "integration_type": "hub",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/xZetsubou/hass-localtuya/issues",
    "requirements": [],
    "version": "3.2.4",
    "is_built_in": false
  },
  "data": {
    "device_config": {
      "friendly_name": "Battletron Ball Light T",
      "device_id": "bfa4176--8lettersredacted--63ehjdk",
      "host": "192.168.88.248",
      "local_key": "--redacted--",
      "protocol_version": "3.5",
      "enable_debug": false,
      "node_id": null,
      "model": "6232000200",
      "product_key": "keycs439tffj9cw5",
      "dps_strings": [
        "20 ( code: switch_led , value: False )",
        "21 ( code: work_mode , value: colour )",
        "24 ( code: colour_data , value: 007803e80190 )",
        "26 ( code: countdown , value: 0 )",
        "61 ( code: paint_colour_data , value: AQB4A+gBkAB4A+gBkA==, cloud pull )",
        "102 ( code: love_scene , value: AA==, cloud pull )",
        "103 ( code: scene_data , value: ABICAQ4AAAAAAGQGAABkAHhkAPBkADxkALRkASxkAg4AAAAAAGQGAABkAHhkAPBkADxkALRkASxk, cloud pull )"
      ],
      "entities": [
        {
          "id": "20",
          "color_mode": "21",
          "color": "24",
          "brightness_lower": 29,
          "brightness_upper": 1000,
          "color_temp_min_kelvin": 2700,
          "color_temp_max_kelvin": 6500,
          "color_temp_reverse": false,
          "music_mode": false,
          "friendly_name": null,
          "icon": "",
          "entity_category": "None",
          "platform": "light"
        }
      ]
    },
    "device_cloud_info": {
      "active_time": 1704651928,
      "biz_type": 0,
      "category": "dd",
      "create_time": 1704651928,
      "icon": "smart/icon/ay1578118863094h8YCV/dd0c14119f57a766178f0591e0929dc7.png",
      "id": "bfa4176--8lettersredacted--63ehjdk",
      "ip": "8...1",
      "lat": "--redacted--",
      "local_key": "--redacted--",
      "lon": "--redacted--",
      "model": "6232000200",
      "name": "Battletron Ball Light T",
      "online": true,
      "owner_id": "179622909",
      "product_id": "yrg6a649fkozp1hw",
      "product_name": "Battletron Ball Light",
      "status": [
        {
          "code": "switch_led",
          "value": false
        },
        {
          "code": "work_mode",
          "value": "colour"
        },
        {
          "code": "colour_data",
          "value": "{\"h\":120,\"s\":1000,\"v\":400}"
        },
        {
          "code": "countdown",
          "value": 0
        }
      ],
      "sub": false,
      "time_zone": "+01:00",
      "uid": "--redacted--",
      "update_time": 1704987892,
      "uuid": "e66d7a8275164a17",
      "dps_data": {
        "20": {
          "code": "switch_led",
          "custom_name": "",
          "dp_id": 20,
          "time": 1704987957515,
          "value": false,
          "type": "Boolean",
          "values": "{\"type\": \"bool\", \"typeDefaultValue\": False}",
          "id": 20,
          "accessMode": "rw"
        },
        "21": {
          "code": "work_mode",
          "custom_name": "",
          "dp_id": 21,
          "time": 1704987846184,
          "value": "colour",
          "type": "Enum",
          "values": "{\"range\": [\"love_scene\", \"colour\", \"scene\", \"music\"], \"type\": \"enum\", \"typeDefaultValue\": \"love_scene\"}",
          "id": 21,
          "accessMode": "rw"
        },
        "24": {
          "code": "colour_data",
          "custom_name": "",
          "dp_id": 24,
          "time": 1704987893558,
          "value": "007803e80190",
          "type": "Json",
          "values": "{\"maxlen\": 255, \"type\": \"string\", \"typeDefaultValue\": \"\"}",
          "id": 24,
          "accessMode": "rw"
        },
        "26": {
          "code": "countdown",
          "custom_name": "",
          "dp_id": 26,
          "time": 1704651932740,
          "value": 0,
          "type": "Integer",
          "values": "{\"max\": 86400, \"min\": 0, \"scale\": 0, \"step\": 1, \"type\": \"value\", \"typeDefaultValue\": 0, \"unit\": \"s\"}",
          "id": 26,
          "accessMode": "rw"
        },
        "27": {
          "code": "music_data",
          "custom_name": "",
          "dp_id": 27,
          "time": 1704651928423,
          "value": "",
          "type": "Json",
          "values": "{\"maxlen\": 255, \"type\": \"string\", \"typeDefaultValue\": \"\"}",
          "id": 27,
          "accessMode": "wr"
        },
        "61": {
          "code": "paint_colour_data",
          "custom_name": "",
          "dp_id": 61,
          "time": 1704987898117,
          "value": "AQB4A+gBkAB4A+gBkA==",
          "id": 61,
          "accessMode": "rw",
          "values": "{\"maxlen\": 128, \"type\": \"raw\"}"
        },
        "102": {
          "code": "love_scene",
          "custom_name": "",
          "dp_id": 102,
          "time": 1704987898502,
          "value": "AA==",
          "id": 102,
          "accessMode": "rw",
          "values": "{\"maxlen\": 128, \"type\": \"raw\"}"
        },
        "103": {
          "code": "scene_data",
          "custom_name": "",
          "dp_id": 103,
          "time": 1704987893560,
          "value": "ABICAQ4AAAAAAGQGAABkAHhkAPBkADxkALRkASxkAg4AAAAAAGQGAABkAHhkAPBkADxkALRkASxk",
          "type": "Json",
          "values": "{\"maxlen\": 128, \"type\": \"raw\"}",
          "id": 103,
          "accessMode": "rw"
        }
      }
    }
  }
}
hmmbob commented 9 months ago

new attempt of the DP dump:

INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.10.0 (default, Feb 25 2023, 15:47:08) [GCC 10.2.1 20210110] on linux
INFO:localtuya:Using pytuya version '10.0.0'
INFO:localtuya:Detecting list of available DPS of device bfa4176c6602f3063ehjdk [192.168.88.248], protocol 3.3.
DEBUG:localtuya.pytuya:[bfa...jdk] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[bfa...jdk] Sending payload: b'{"gwId":"bfa4176c6602f3063ehjdk","devId":"bfa4176c6602f3063ehjdk","uid":"bfa4176c6602f3063ehjdk","t":"1704990204"}'
DEBUG:localtuya.pytuya:[bfa...jdk] Command 10 waiting for sequence number 1
ERROR:localtuya.pytuya:[bfa...jdk] Failed to get status: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 387, 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 458, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 849, in detect_available_dps
    data = await self.status()
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 781, in status
    status = await self.exchange(DP_QUERY)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 755, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 446, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 460, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
INFO:localtuya:Detecting list of available DPS of device bfa4176c6602f3063ehjdk [192.168.88.248], protocol 3.3.
DEBUG:localtuya.pytuya:[bfa...jdk] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[bfa...jdk] Sending payload: b'{"gwId":"bfa4176c6602f3063ehjdk","devId":"bfa4176c6602f3063ehjdk","uid":"bfa4176c6602f3063ehjdk","t":"1704990211"}'
DEBUG:localtuya.pytuya:[bfa...jdk] Command 10 waiting for sequence number 1
ERROR:localtuya.pytuya:[bfa...jdk] Failed to get status: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 387, 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 458, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 849, in detect_available_dps
    data = await self.status()
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 781, in status
    status = await self.exchange(DP_QUERY)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 755, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 446, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 460, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
INFO:localtuya:Detecting list of available DPS of device bfa4176c6602f3063ehjdk [192.168.88.248], protocol 3.3.
DEBUG:localtuya.pytuya:[bfa...jdk] Sending command 10 (device type: type_0a)
DEBUG:localtuya.pytuya:[bfa...jdk] Sending payload: b'{"gwId":"bfa4176c6602f3063ehjdk","devId":"bfa4176c6602f3063ehjdk","uid":"bfa4176c6602f3063ehjdk","t":"1704990219"}'
DEBUG:localtuya.pytuya:[bfa...jdk] Command 10 waiting for sequence number 1
ERROR:localtuya.pytuya:[bfa...jdk] Failed to get status: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 387, 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 458, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 849, in detect_available_dps
    data = await self.status()
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 781, in status
    status = await self.exchange(DP_QUERY)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 755, in exchange
    msg = await self.dispatcher.wait_for(seqno, payload.cmd)
  File "/home/bob/docker/smarthome/homeassistant/tuyadebug/localtuya/pytuya/__init__.py", line 446, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 460, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
INFO:localtuya:TIMEOUT: No response from device bfa4176c6602f3063ehjdk [192.168.88.248] after 2 attempts.
xZetsubou commented 9 months ago

new attempt of the DP dump:

When you want to get the dump DPs you need to select correct version you selected 3.3 and your device is 3.5. But there is not reason for that as you can see device diagnostics includes this.

Does the brightness update the states or it the same as colors, I did try the same your device config but it worked for me. Can you try this test and see if the device reports to HA or not. Go to HA -> developer-tools -> event . http://ip:8123/developer-tools/event In the event subscribe field to type this: localtuya_device_dp_triggered or localtuya_states_update then start listening after that control your device and check in HA what DP triggered and the value that triggered the DP.

Can you show what states shows in home assistant from developer-tools -> states

hmmbob commented 9 months ago

new attempt of the DP dump:

When you want to get the dump DPs you need to select correct version you selected 3.3 and your device is 3.5. But there is not reason for that as you can see device diagnostics includes this.

Getting same error when appending 3.5 to the command (output also specifies version 3.5 now).

Does the brightness update the states or it the same as colors, I did try the same your device config but it worked for me.

No, when changing brightness in HA the colors of the lamp actually change (not the brightness, the color)

Can you try this test and see if the device reports to HA or not. Go to HA -> developer-tools -> event . http://ip:8123/developer-tools/event In the event subscribe field to type this: localtuya_device_dp_triggered or localtuya_states_update then start listening after that control your device and check in HA what DP triggered and the value that triggered the DP.

Sure. This was me turning on the light with the remote, and changing color to red with the remote:

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "20"
  value: true
origin: LOCAL
time_fired: "2024-01-11T19:15:52.625604+00:00"
context:
  id: 01HKWZ7J5HSFKS1PFV8RDKRR38
  parent_id: null
  user_id: null

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "24"
  value: 000003e803e8
origin: LOCAL
time_fired: "2024-01-11T19:15:54.856054+00:00"
context:
  id: 01HKWZ7MB86GKKY8P8JTQZJ9HP
  parent_id: null
  user_id: null

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQAAA+gD6AAAA+gD6A==
origin: LOCAL
time_fired: "2024-01-11T19:15:55.299168+00:00"
context:
  id: 01HKWZ7MS3YD0841S9N4WW6DEA
  parent_id: null
  user_id: null

After this, I selected "blue" in homeassistant and the light is now somewhat purple-ish (it seems like there are two lights in this ball?)

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQDuA3oD6O4AegPoAw==
origin: LOCAL
time_fired: "2024-01-11T19:17:48.245335+00:00"
context:
  id: 01HKWZB32NZNJ92S664YCGM7MG
  parent_id: null
  user_id: null

Can you show what states shows in home assistant from developer-tools -> states

State after selecting "blue" on the remote:

State on, attributes:

effect_list: null
supported_color_modes: brightness, hs
color_mode: hs
brightness: 255
hs_color: 0, 100
rgb_color: 255, 0, 0
xy_color: 0.701, 0.299
effect: null
raw_state: true
icon: 
friendly_name: Battletron Ball Light T
supported_features: 4
hmmbob commented 9 months ago

20240111_202155

My phone camera is freaking out why I try to take a picture 😂. It made this picture - in reality it is way more smooth transition (but definitely 2 different colors)

20240111_202130

hmmbob commented 9 months ago

Not sure if it helps, but if I go to the API Explorer on iot.tuya.com. and going to Device Control(Standard Instruction Set) > Get the specifications and properties of the device, this is the output:

{
  "result": {
    "category": "dd",
    "functions": [
      {
        "code": "switch_led",
        "desc": "{}",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "desc": "{\"range\":[\"colour\",\"scene\",\"music\"]}",
        "name": "模式",
        "type": "Enum",
        "values": "{\"range\":[\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "colour_data",
        "desc": "{\"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}}",
        "name": "彩光",
        "type": "Json",
        "values": "{\"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",
        "desc": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}",
        "name": "倒计时剩余时间",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "music_data",
        "desc": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}",
        "name": "音乐灯",
        "type": "Json",
        "values": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}"
      },
      {
        "code": "scene_data",
        "desc": "{\"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}}}",
        "name": "场景",
        "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}}}"
      }
    ],
    "status": [
      {
        "code": "switch_led",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "name": "模式",
        "type": "Enum",
        "values": "{\"range\":[\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "colour_data",
        "name": "彩光",
        "type": "Json",
        "values": "{\"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",
        "name": "倒计时剩余时间",
        "type": "Integer",
        "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "scene_data",
        "name": "场景",
        "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}}}"
      }
    ]
  },
  "success": true,
  "t": 1705001640199,
  "tid": "5e835427b0b811ee8bdcceeb0d1e0bda"
}
xZetsubou commented 9 months ago

Getting same error when appending 3.5 to the command (output also specifies version 3.5 now).

Oh I think you're using the wrong "tuyadebug", use this fork "tuyadebug" package not upstream :). tho like I mentioned it not needed since it included in "device diagnostics" but if you are curious:

Dump dps

``` wget https://github.com/xZetsubou/hass-localtuya/raw/master/tuyadebug.tgz tar -zxvf tuyadebug.tgz && cd tuyadebug python python test.py "device_id" "host_ip" "localkey" "3.5" ```

in reality it is way more smooth transition (but definitely 2 different colors)

Well I'm pretty sure it's impossible to control the 2 colors from one entity 😄

After this, I selected "blue" in homeassistant and the light is now somewhat purple-ish (it seems like there are two lights in this ball?)

event_type: localtuya_device_dp_triggered data: device_id: bfa4176c6602f3063ehjdk dp: "61" value: AQDuA3oD6O4AegPoAw== origin: LOCAL time_fired: "2024-01-11T19:17:48.245335+00:00" context: id: 01HKWZB32NZNJ92S664YCGM7MG parent_id: null user_id: null



I noticed when you changed the color from Home Assistant only the "DP 61" triggered? In entity configuration, light color data rely on "dp 24".
Does changing the color from the remote update HA status? because "dp 24" seems it triggers when you tested via remote.

Can you repeat the event test and check again what DP and value triggers when colors changes. from remote and home Assistant. 
Assuming the DP 61 what trigger when color changes it no wonder HA doesn't update since it use DP 24 for color data.
hmmbob commented 9 months ago

Getting same error when appending 3.5 to the command (output also specifies version 3.5 now).

Oh I think you're using the wrong "tuyadebug", use this fork "tuyadebug" package not upstream :). tho like I mentioned it not needed since it included in "device diagnostics" but if you are curious:

Dump dps

wget https://github.com/xZetsubou/hass-localtuya/raw/master/tuyadebug.tgz
tar -zxvf tuyadebug.tgz && cd tuyadebug
python python test.py "device_id" "host_ip" "localkey" "3.5" 

Still no joy, INFO:localtuya:TIMEOUT: No response from device bfa4176c6602f3063ehjdk [192.168.88.229] after 2 attempts.. ICMP ping etc works fine.

in reality it is way more smooth transition (but definitely 2 different colors)

Well I'm pretty sure it's impossible to control the 2 colors from one entity 😄

Agreed, but it's not too obvious yet on how to do that 😉

After this, I selected "blue" in homeassistant and the light is now somewhat purple-ish (it seems like there are two lights in this ball?)

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQDuA3oD6O4AegPoAw==
origin: LOCAL
time_fired: "2024-01-11T19:17:48.245335+00:00"
context:
  id: 01HKWZB32NZNJ92S664YCGM7MG
  parent_id: null
  user_id: null

I noticed when you changed the color from Home Assistant only the "DP 61" triggered? In entity configuration, light color data rely on "dp 24". Does changing the color from the remote update HA status? because "dp 24" seems it triggers when you tested via remote.

Can you repeat the event test and check again what DP and value triggers when colors changes. from remote and home Assistant. Assuming the DP 61 what trigger when color changes it no wonder HA doesn't update since it use DP 24 for color data.

Sure.

Test with only remote being used.

Test sequence: turn on device, change color to red, change color to green, change color to blue, turn off device with 5 seconds in between so it's easy to distinguish between steps. The light fully changes color when using the remote (solid color all over)

# Turn on
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "20"
  value: true
origin: LOCAL
time_fired: "2024-01-12T08:57:07.554919+00:00"
context:
  id: 01HKYE7A724E9PB5725AA7M1FD
  parent_id: null
  user_id: null

#Set red color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "24"
  value: 000003e803e8
origin: LOCAL
time_fired: "2024-01-12T08:57:13.447694+00:00"
context:
  id: 01HKYE7FZ7G72WFXHPP0F5DRH5
  parent_id: null
  user_id: null

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQAAA+gD6AAAA+gD6A==
origin: LOCAL
time_fired: "2024-01-12T08:57:13.781167+00:00"
context:
  id: 01HKYE7G9N4FB8KK549AYPM69T
  parent_id: null
  user_id: null

# Set green color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "24"
  value: 007803e803e8
origin: LOCAL
time_fired: "2024-01-12T08:57:19.476189+00:00"
context:
  id: 01HKYE7NVMARZ6ZAW53K9NQKYS
  parent_id: null
  user_id: null

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQB4A+gD6AB4A+gD6A==
origin: LOCAL
time_fired: "2024-01-12T08:57:19.920667+00:00"
context:
  id: 01HKYE7P9GW3FV9HFJT8RKJP0F
  parent_id: null
  user_id: null

# Set blue color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "24"
  value: 00f003e803e8
origin: LOCAL
time_fired: "2024-01-12T08:57:24.618157+00:00"
context:
  id: 01HKYE7TWA10ADAAE0SVPA64X9
  parent_id: null
  user_id: null

event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQDwA+gD6ADwA+gD6A==
origin: LOCAL
time_fired: "2024-01-12T08:57:25.052559+00:00"
context:
  id: 01HKYE7V9WDD1W4VX255PPW90K
  parent_id: null
  user_id: null

# Turn off device
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "20"
  value: false
origin: LOCAL
time_fired: "2024-01-12T08:57:30.481399+00:00"
context:
  id: 01HKYE80KHM4NCT2W1C8Z2FVC3
  parent_id: null
  user_id: null 

Test from Home Assistant

Same test sequence: turn on device, change color to red, change color to green, change color to blue, turn off device with 5 seconds in between so it's easy to distinguish between steps. ⚠️ I have observed that only half of the light changes color (the upper half). The bottom keeps a red-ish hue when changing the light color from HA.

# Turn on
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "20"
  value: true
origin: LOCAL
time_fired: "2024-01-12T09:03:12.121620+00:00"
context:
  id: 01HKYEJE7SNKCKJZGJSRN1RWYZ
  parent_id: null
  user_id: null

# Set red color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQFmA6ID6GYBogPoAw==
origin: LOCAL
time_fired: "2024-01-12T09:03:17.551946+00:00"
context:
  id: 01HKYEJKHFVP41X4YVNQQ6J9DK
  parent_id: null
  user_id: null

#Set green color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQB9A5gD6H0AmAPoAw==
origin: LOCAL
time_fired: "2024-01-12T09:03:22.658461+00:00"
context:
  id: 01HKYEJRH23SSHVVT0HCFXCZ4T
  parent_id: null
  user_id: null

# Set blue color
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "61"
  value: AQDgA5gD6OAAmAPoAw==
origin: LOCAL
time_fired: "2024-01-12T09:03:27.583740+00:00"
context:
  id: 01HKYEJXAZW6DZDWV6Z0YX3S1H
  parent_id: null
  user_id: null

# Turn off device
event_type: localtuya_device_dp_triggered
data:
  device_id: bfa4176c6602f3063ehjdk
  dp: "20"
  value: false
origin: LOCAL
time_fired: "2024-01-12T09:03:32.881502+00:00"
context:
  id: 01HKYEK2GHDSQ8SZ0NR3A39AFV
  parent_id: null
  user_id: null
hmmbob commented 9 months ago

More info in DP 61 here https://developer.tuya.com/en/docs/iot/sdk?id=Kbhjudllricrx#title-9-Smudge%20dimming%20(required)

xZetsubou commented 9 months ago

Still no joy, INFO:localtuya:TIMEOUT: No response from device bfa4176c6602f3063ehjdk [192.168.88.229] after 2 attempts.. ICMP ping etc works fine

Then the only thing I can think of is the device doesn't accept more then 1 connection at the same, since you HA probably connected to it.

More info in DP 61 here https://developer.tuya.com/en/docs/iot/sdk?id=Kbhjudllricrx#title-9-Smudge%20dimming%20(required)

What it written in the description doesn't match what the it your device reported "dp 61" these values aren't even hexadecimal. However I'm really confused, Localtuya sending payload with new color_data and changes "dp21" but for some reason dp61 value changed!

To be honest I don't know if it possible to handle this device, there are many things that not sure how it done. Lights color data rely on one DP usually this DP Code is "colour_data" which is also the one that "official tuya" rely on as well

For some reason changing the value of DP24 colour_data triggers and change the value of DP61 and this an issue not only the value is encoded but also this will require to rely on 2 color_data this can kinda be done somehow?, and I don't know how to change the value of DP24 which is probably the DP of bottom side.

Using the data reported via "remote test" can you try change the values of "dp 61" from set_dp service.

service: localtuya.set_dp
data:
  device_id: 11100118278aab4de001
  dp: 61
  value: # Green: AQB4A+gD6AB4A+gD6A OR Blue: AQDgA5gD6OAAmAPoAw== OR Red: AQFmA6ID6GYBogPoAw==

I wonder if this will trigger "DP 21" Changing the colors from remote will probably update HA Entity right?

Note: You can go and click on configure the hub entry and select reconfigure the device and enable debug this will add more context into the logs when the device being controlled.

github-actions[bot] commented 8 months ago

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