rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.94k stars 561 forks source link

Color Light missing Color & Scene - Both functions available via Tuya app #965

Open JGrantman opened 2 years ago

JGrantman commented 2 years ago

The problem

I am having problems getting a light to work with full function (color, scene) using localTuya. I am able to add device via localTuya but Color and Scene are not available on configuration dialog (and not available controls for the device after adding to Home Assistant).

Environment

Home Assistant 2022.7.6 Supervisor 2022.07.0 Operating System 8.3 Frontend 20220707.1 - latest HACS Integration version: 1.26.2 HACS Frontend version: 20220714083628 Localtuya version: 4.01 from HACS

Steps to reproduce

Add new device via localTuya Home Assistant integration

Configuration configuration.yaml or config_flow

via config flow only 5 DP values are presented: 20 (value: False) - entity 21 (value: white) - color mode 22 (value: 300) - brightness 23 (value: 500) - color temp 26 (value: 0) - timer (not used)

I have 7 other different types of lights with similar features and all show both DP24 (color) and DP25 (scene) via config flow setup.

DP dump

I could not get the tools installed/working so I went to the TuyaIoT Cloud and captured results for the device using the API Explorer. Both color and scene/effect appear to be supported -- and both work via mobile app. It is curious that both color and scene list as "v2" but so do bright and temp values which show up correctly in the setup dialog.

** these are same results as 7 other types of lights (38 devices) that do work without issue via localTuya. Both color (DP24) and scene (DP25) show up in config flow setup dialog and are subsequently controllable via Home Assistant.


Results from TuyaIoT Cloud API Explorer

biz_type: 18, category: "dj", category_name: "Light Source", icon: "smart/icon/ay1530625888062OnLeq/fcac4e566d55d11fba3064af1d9d90cf.png", model": "YL.DY.0633", product_id: "6jz7sqeuxnhom2rk", product_name": "Smart Floor Light 2.4G WIFI",

category: "dj", functions: code": "switch_led",

    dp_id: 20,
    type": "Boolean",
    values": "{}"
    code": "work_mode",
    -----
    dp_id: 21,
    type": "Enum",
    values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
    code": "bright_value_v2",
    -----
    dp_id: 22,
    type": "Integer",
    values": "{\"min\":10,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}"
    code": "temp_value_v2",
    -----
    dp_id: 23,
    type": "Integer",
    values": "{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}"
    code": "colour_data_v2",
    -----
    dp_id: 24,
    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": "scene_data_v2",
    -----
    dp_id: 25,
    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": "music_data",
    -----
    dp_id: 27,
    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": "control_data",
    -----
    dp_id: 28,
    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": "countdown_1",
    -----
    dp_id: 26,
    type": "Integer",
    values": "{\"unit\":\"\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"

functions:
    code: "switch_led",
    desc: "switch led",
    name: "switch led",
    type: "Boolean",
    values: "{}"
    -----
    code: "work_mode",
    desc: "work mode",
    name: "work mode",
    type: "Enum",
    values: "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
    -----
    code: "bright_value_v2",
    desc: "bright value v2",
    name: "bright value v2",
    type: "Integer",
    values": "{\"min\":10,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}"
    -----
    code: "temp_value_v2",
    desc: "temp value v2",
    name: "temp value v2",
    type: "Integer",
    values": "{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}"
    -----
    code: "colour_data_v2",
    desc: "colour data v2",
    name: "colour data v2",
    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: "scene_data_v2",
    desc: "scene data v2",
    name: "scene data v2",
    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: "music_data",
    desc: "music data",
    name: "music data",
    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: "control_data",
    desc: "control data",
    name: "control data",
    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: "countdown_1",
    desc: "countdown 1",
    name: "countdown 1",
    type: "Integer",
    values: "{\"unit\":\"\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"

result:
    code: "switch_led",
    value: true

    code: "work_mode",
    value: "scene"

    code: "bright_value_v2",
    value: 1000

    code: "temp_value_v2",
    value: 500

    code: "colour_data_v2",
    value: "{\"h\":0,\"s\":1000,\"v\":1000}"

    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: "music_data",
    value: ""

    code: "control_data",
    value: ""

Provide Home Assistant taceback/logs

2022-07-22 23:05:46 WARNING (MainThread) [homeassistant.components.number] custom_components.localtuya.number::LocaltuyaNumber is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom component author. 2022-07-22 23:05:47 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': 'xxx.xxx.x.xxx', 'gwId': 'xxxxxxxxxxxxxxxxxxxx', 'active': 2, 'ability': 0, 'mode': 0, 'encrypt': True, 'productKey': '6jz7sqeuxnhom2rk', 'version': '3.3'} 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.light] [017...dfd] Adding light.name_of_light with configuration: {'id': 20, 'friendly_name': 'Friendly Light Name', 'brightness_lower': 10, 'brightness_upper': 1000, 'color_temp_min_kelvin': 2700, 'color_temp_max_kelvin': 6500, 'color_temp_reverse': False, 'music_mode': False, 'brightness': 22, 'color_temp': 23, 'color_mode': 21, 'platform': 'light'} 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.common] [017...dfd] Connecting to xxx.xxx.x.xxx 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Started heartbeat loop 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Sending command heartbeat (device type: type_0a) 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Send payload: b'{}' 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Waiting for sequence number -100 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.common] [017...dfd] Retrieving initial state 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Sending command status (device type: type_0a) 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Send payload: b'{"gwId":"xxxxxxxxxxxxxxxxxxxx","devId":"xxxxxxxxxxxxxxxxxxxx"}' 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Waiting for sequence number 1 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Got heartbeat response 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Decrypted payload: {} 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Dispatching message TuyaMessage(seqno=1, cmd=10, retcode=0, payload=b"\xd9{d\x7fj\xc6(\xd8\x8b\xcc{\xa9\x8d\xb1\xfa\x03\xa8\xd1\xa6\xe8O\xbcsL\x13\x85\x0fF\xb8\x8e\xf3\xc86\x16\x18\x17\xea\xb1\xd5\x14n\xd7\xcc\xa1=g\x069@h\xfc\xb4\n\xba&\x16gA@6\xec\xe6\xc0\xd0\xb8\xd3qY\xba\xc4\x02hx#\xaf\xbc\x07\x93=\xb2\xae%\xf7\xe6!\x1boS\xcb'\x9a-\xd6\x0coN", crc=1340625387) 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Dispatching sequence number 1 2022-07-22 23:05:49 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Decrypted payload: {"devId":"xxxxxxxxxxxxxxxxxxxx","dps":{"20":false,"21":"white","22":300,"23":500,"26":0}} 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Sending command heartbeat (device type: type_0a) 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Send payload: b'{}' 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Waiting for sequence number -100 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Got heartbeat response 2022-07-22 23:05:59 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Decrypted payload: {} 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Sending command heartbeat (device type: type_0a) 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Send payload: b'{}' 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Waiting for sequence number -100 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Dispatching message TuyaMessage(seqno=0, cmd=9, retcode=0, payload=b'', crc=2958142211) 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Got heartbeat response 2022-07-22 23:06:09 DEBUG (MainThread) [custom_components.localtuya.pytuya] [017...dfd] Decrypted payload: {}

Additional information

I have 6 of the same device having this issue. All 6 puchased via Amazon though 5 came from vendor "MikeWin" and the other from "HueLiv". Phyically the all 6 are identical and in my TuyaIoT Cloud envrionment all 6 show up identically. I chose one with the first several chars of ID being unique to make it easier to pinpoint log entries. When I add the device using localTuya the dialog box shows the device correctly but then shows a different style coniguration dialog than 6 other different types of color lights I setup. Instead of drop down boxes the entire dialog is radio buttons and both Color (DP24) and Scene (DP25) are missing.

=============== END OF CONTENT

derekmurawsky commented 2 years ago

I have another bulb that supports the colour_data_v2 and scene_data_v2 fields only. Not sure if I should create a new ticket or list here, so I will list here for now. It appears the v2 fields need to be supported.

{
  "result": {
    "category": "dj",
    "functions": [
      {
        "code": "switch_led",
        "desc": "{}",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "desc": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}",
        "name": "工作模式",
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "desc": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}",
        "name": "亮度",
        "type": "Integer",
        "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_value_v2",
        "desc": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}",
        "name": "色温",
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "colour_data_v2",
        "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": "scene_data_v2",
        "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}}}"
      },
      {
        "code": "countdown_1",
        "desc": "{\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}",
        "name": "倒计时",
        "type": "Integer",
        "values": "{\"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": "control_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": "rhythm_mode",
        "desc": "{\"maxlen\":255}",
        "name": "生物节律",
        "type": "Raw",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "sleep_mode",
        "desc": "{\"maxlen\":255}",
        "name": "入睡",
        "type": "Raw",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "wakeup_mode",
        "desc": "{\"maxlen\":255}",
        "name": "唤醒",
        "type": "Raw",
        "values": "{\"maxlen\":255}"
      },
      {
        "code": "power_memory",
        "desc": "{}",
        "name": "断电记忆",
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "do_not_disturb",
        "desc": "{}",
        "name": "勿扰模式",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "cycle_timing",
        "desc": "{}",
        "name": "循环定时",
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "random_timing",
        "desc": "{}",
        "name": "随机定时",
        "type": "Raw",
        "values": "{}"
      }
    ],
    "status": [
      {
        "code": "switch_led",
        "name": "开关",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "work_mode",
        "name": "模式",
        "type": "Enum",
        "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}"
      },
      {
        "code": "bright_value_v2",
        "name": "亮度",
        "type": "Integer",
        "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "temp_value_v2",
        "name": "冷暖",
        "type": "Integer",
        "values": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}"
      },
      {
        "code": "colour_data_v2",
        "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": "scene_data_v2",
        "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}}}"
      },
      {
        "code": "countdown_1",
        "name": "倒计时",
        "type": "Integer",
        "values": "{\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}"
      },
      {
        "code": "music_data",
        "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": "control_data",
        "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": "rhythm_mode",
        "name": "生物节律",
        "type": "Raw",
        "values": "{\"maxlen\":\"255\"}"
      },
      {
        "code": "sleep_mode",
        "name": "入睡",
        "type": "Raw",
        "values": "{\"maxlen\":\"255\"}"
      },
      {
        "code": "wakeup_mode",
        "name": "唤醒",
        "type": "Raw",
        "values": "{\"maxlen\":\"255\"}"
      },
      {
        "code": "power_memory",
        "name": "断电记忆",
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "do_not_disturb",
        "name": "勿扰模式",
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "cycle_timing",
        "name": "循环定时",
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "random_timing",
        "name": "随机定时",
        "type": "Raw",
        "values": "{}"
      }
    ]
  },
  "success": true,
  "t": 1658782109697,
  "tid": "238fa4ef0c5b11edb6fa72c83ceb552d"
}

According to the Tuya API documentation, color_data_v2 is defined as

Control the color change of the light in the form of hue, saturation, and value (HSV). Value description

Hue (h): 0–360 Saturation (s): 0–1000 Value (v): 0–1000 Sample code

{
    "commands":[
        {
            "code":"colour_data_v2",
            "value":{
                "h":201,
                "s":511,
                "v":899
            }
        }
    ]

scene_data_v2 is also available. https://developer.tuya.com/en/docs/iot/dj?id=K9i5ql3v98hn3#title-11-scene_data_v2

Let me know what I can do to help here.

derekmurawsky commented 2 years ago

Looks like we'd have to start by changing this line and adding some kind of interpreter for those container objects. https://github.com/rospogrigio/localtuya/blob/master/custom_components/localtuya/common.py#L100

@rospogrigio it looks like this will be a bit of an api change to contend with? Wanted to be sure you were aware.

tivoo commented 2 years ago

I am running into the same issue. For now I am only able to turn the light on or off, not able to access the hsv values that the API sees..

clemente3905 commented 2 years ago

Same issue here. I can't neither add manual DP via configuration of the local tuya, it returns me an error. @rospogrigio I don't know if you are aware of this

arutkowski00 commented 1 year ago

I have the exact same issue with my CCT bulbs. They are using the scene_data_v2 field with a JSON value to store the brightness and temperature. Other fields like bright_value_v2 or temp_value_v2 do nothing.

It looks like there should be a feature to specify a JSON path (maybe something like jq?) where the value is stored, so the integration knows how to read/write it.

In the meantime, does anyone know of any workaround?

Example instruction set

```json { "category": "dj", "functions": [ { "code": "switch_led", "desc": "switch led", "name": "switch led", "type": "Boolean", "values": "{}" }, { "code": "work_mode", "desc": "work mode", "name": "work mode", "type": "Enum", "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}" }, { "code": "bright_value_v2", "desc": "bright value v2", "name": "bright value v2", "type": "Integer", "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}" }, { "code": "temp_value_v2", "desc": "temp value v2", "name": "temp value v2", "type": "Integer", "values": "{\"min\":0,\"max\":1000,\"scale\":0,\"step\":1}" }, { "code": "scene_data_v2", "desc": "scene data v2", "name": "scene data v2", "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", "desc": "countdown 1", "name": "countdown 1", "type": "Integer", "values": "{\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "control_data", "desc": "control data", "name": "control data", "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": "rhythm_mode", "desc": "rhythm mode", "name": "rhythm mode", "type": "Raw", "values": "{\"maxlen\":255}" }, { "code": "sleep_mode", "desc": "sleep mode", "name": "sleep mode", "type": "Raw", "values": "{\"maxlen\":255}" }, { "code": "wakeup_mode", "desc": "wakeup mode", "name": "wakeup mode", "type": "Raw", "values": "{\"maxlen\":255}" } ] } ```

Example status

```json [ { "code": "switch_led", "value": false }, { "code": "work_mode", "value": "white" }, { "code": "bright_value_v2", "value": 1000 }, { "code": "temp_value_v2", "value": 1000 }, { "code": "scene_data_v2", "value": "{\"scene_num\":1,\"scene_units\":[{\"bright\":33,\"h\":0,\"s\":0,\"temperature\":69,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}" }, { "code": "countdown_1", "value": 0 }, { "code": "control_data", "value": "" }, { "code": "rhythm_mode", "value": "AAAAAAA=" }, { "code": "sleep_mode", "value": "AAA=" }, { "code": "wakeup_mode", "value": "AAA=" } ] ```

javiertallon commented 10 months ago

Same issue here.

I managed to set the color and scene values setting the "Manual DPS to add" option to 24,25, but then I get python errors whenever I try to change the light colour.

Any progress? It look like my led strip capabilities are not adequately detected :\