tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
868 stars 206 forks source link

LED Strip brightness mapping is wrong #395

Open ptavasci opened 3 years ago

ptavasci commented 3 years ago

Describe the bug Brightness level mapping on Warm White/Cool White is working OK Brightness level mapping on RGB mode is not working OK

Same issue as described in this integration of Local TUYA https://github.com/rospogrigio/localtuya/issues/33

Expected behavior I would expect that 100% of britghtness in the integration with Home Assistant would set 100% britghtness in then led strip and the Smart Life App. Instead, 100% in HA on RGB sets about 25% of brightness in the led strip and in the Smart Life App.

Home Assistant Version core-2021.8.8 supervisor-2021.06.8 Sistema operativo Debian GNU/Linux 10 (buster) Versión de Docker 20.10.8

Device info/specifications

{ "active_time":1608259869, "biz_type":18, "category":"dd", "create_time":1600114497, "icon":"smart/icon/ay1532660270361428EU/26b43242c44734bbb456b35b0b6d75ce.png", "id":"eb08fa3f5eb63b0c4csajh", "ip":"", "lat":"", "local_key":"", "lon":"", "model":"sirui-rgbcw", "name":"Cama de Sofi", "online":true, "owner_id":"21235077", "product_id":"w5v2xttjxib8sajw", "product_name":"sirui-rgbcw", "status":[ { "code":"switch_led", "value":false }, { "code":"work_mode", "value":"colour" }, { "code":"bright_value", "value":1000 }, { "code":"temp_value", "value":500 }, { "code":"colour_data", "value":"{\"h\":304,\"s\":1000,\"v\":1000}" }, { "code":"scene_data", "value":"{\"scene_num\":2,\"scene_units\":[{\"bright\":1000,\"h\":0,\"s\":0,\"temperature\":500,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}" }, { "code":"countdown", "value":0 } ], "sub":false, "time_zone":"-03:00", "uid":"", "update_time":1629442095, "uuid":"29bb98de99d1e0b9" }, { "active_time":1600899125, "biz_type":18, "category":"dd", "create_time":1599689881, "icon":"smart/icon/ay1532660270361428EU/26b43242c44734bbb456b35b0b6d75ce.png", "id":"eb37100112a8bfa1fexa8o", "ip":"", "lat":"", "local_key":"", "lon":"", "model":"sirui-rgbcw", "name":"Sillón", "online":true, "owner_id":"21235077", "product_id":"w5v2xttjxib8sajw", "product_name":"sirui-rgbcw", "status":[ { "code":"switch_led", "value":true }, { "code":"work_mode", "value":"white" }, { "code":"bright_value", "value":1000 }, { "code":"temp_value", "value":500 }, { "code":"colour_data", "value":"{\"h\":300,\"s\":260,\"v\":1000}" }, { "code":"scene_data", "value":"{\"scene_num\":2,\"scene_units\":[{\"bright\":1000,\"h\":0,\"s\":0,\"temperature\":500,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}" }, { "code":"countdown", "value":0 } ], "sub":false, "time_zone":"-03:00", "uid":"", "update_time":1629268101, "uuid":"2d9402c02f19f953" }, { "active_time":1600899067, "biz_type":18, "category":"dd", "create_time":1598994217, "icon":"smart/icon/ay1532660270361428EU/26b43242c44734bbb456b35b0b6d75ce.png", "id":"ebcd2e2f01cadd51f67spn", "ip":"", "lat":"", "local_key":"", "lon":"", "model":"sirui-rgbcw", "name":"Escritorio", "online":true, "owner_id":"21235077", "product_id":"w5v2xttjxib8sajw", "product_name":"sirui-rgbcw", "status":[ { "code":"switch_led", "value":true }, { "code":"work_mode", "value":"white" }, { "code":"bright_value", "value":1000 }, { "code":"temp_value", "value":423 }, { "code":"colour_data", "value":"{\"h\":270,\"s\":255,\"v\":255}" }, { "code":"scene_data", "value":"{\"scene_num\":2,\"scene_units\":[{\"bright\":1000,\"h\":0,\"s\":0,\"temperature\":500,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}" }, { "code":"countdown", "value":0 } ], "sub":false, "time_zone":"-03:00", "uid":"***", "update_time":1629268099, "uuid":"0bb628aee29fba87" }

Additional context None

User2234 commented 3 years ago

I'm dealing with exactly the same issue with my RGBCCT lights. The brightness and color temperature of the WW and CW work without issue.

However in the RGB mode there is an issue. For example, if light is set to red via color wheel in HA with 100% brightness, the light switches to 26% brightness and the color saturation on the color palette wheel is also reduced, like visible on the screenshot below:

Screenshot_20210821_123741_com tuya smartlife - Copy

Device info/specifications

{ "active_time": 1623166604, "biz_type": 18, "category": "dd", "create_time": 1623166604, "icon": "smart/icon/ay1532660270361428EU/87af0626f0d76af969f07557f84cba26.png", "id": "", "ip": "", "lat": "", "local_key": "", "lon": "", "model": "wifi-5ch", "name": "Bed light", "online": true, "owner_id": "10021157", "product_id": "qfx0apvo5dsigaj9", "product_name": "YSR-RGBCW", "status": [ { "code": "switch_led", "value": false }, { "code": "work_mode", "value": "colour" }, { "code": "bright_value", "value": 1000 }, { "code": "temp_value", "value": 0 }, { "code": "colour_data", "value": "{\"h\":360,\"s\":255,\"v\":255}" }, { "code": "scene_data", "value": "{\"scene_num\":1,\"scene_units\":[{\"bright\":200,\"h\":0,\"s\":0,\"temperature\":0,\"unit_change_mode\":\"static\",\"unit_gradient_duration\":13,\"unit_switch_duration\":14,\"v\":0}]}" }, { "code": "countdown", "value": 0 } ], "sub": false, "time_zone": "+02:00", "uid": "eu1580147494420s6vlA", "update_time": 1629470329, "uuid": "6fefcde42e6796fe" }, "success": true, "t": 1629543873545 }

If I am not mistaken, the wrong values for saturation and value (both 255 therefore showing as 26% in the Smart life app) are sent to the device when 100% brightness and 100% saturation is selected in HA RGB color palette wheel and the brightness slider.

Additional context

[tuya iot] on_message: {'data': {'dataId': '0e59bd74-1dce-4604-bc8b-30f7d1a00302', 'devId': '', 'productKey': 'qfx0apvo5dsigaj9', 'status': [{'24': '016800ff00ff', 'code': 'colour_data', 't': '1629548477', 'value': '{"h":0,"s":255,"v":255}'}]}, 'protocol': 4, 'pv': '2.0', 'sign': '7f53d9144fb1c6c23bbcfb03785f8949', 't': 1629548477}

It should probably be sending 1000 for both brightness and saturation like in the bolded text below:

[tuya iot] mq _on_device_report-> [{'24': '000003e803e8', 'code': 'colour_data', 't': '1629549244', 'value': '{"h":0,"s":1000,"v":1000}'}]

bellini666 commented 2 years ago

Same issue here! Any workaround until a fix has been released?

User2234 commented 2 years ago

I figured a workaround in Node-RED that works, but for the moment I only needed for the red light with low brightness to be turned on based on the motion sensor. I guess if CCT or other options would be needed it shouldn't be too hard to modify my template.

I've used the node-red-contrib-tuya-smart-device module in Node-RED to add my RGB light and then listened what values it was receiving when I changed the setting in my mobile app. The relevant part of the flow looks like this: image

Below are the contents of the function node. The essential part is the value after "24", the one in the example below sets my light to red at 10% brightness:

msg.payload = {"multiple": true, "data": {"20": msg.payload, "24":"000003e80062" } }

/*

    */
return msg;

It's not an elegant workaround, but I am just starting my first month with HA so can't really figure out a better one.

Hopefully, the issue will be closed in one of the future releases as it would be much easier to control the light with the RGB/CCT picker.

Wlada commented 2 years ago

This is still an issue