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
879 stars 207 forks source link

Bulb continues to show old color in HA app after switching to white mode #234

Open Nuuki9 opened 3 years ago

Nuuki9 commented 3 years ago

Describe the bug

I'm able to control the colour and temperature of this bulb no problems. If I've set an RBG colour, and then I change the temperature, the bulb switches to white as I would expect. However the colour of the bulb shown in the Home Assistant app doesn't update, and continutes to show the old colour. The reported colour does correctly update in both TuyaSmart, and when using TuyaLocal.

Expected behavior The bulb entity colour shown in the Home Assistant app should change to white when the white temperature is adjusted while the bulb is in a color mode, to match the actual bulb.

Home Assistant Version

Device info

{ "active_time": 1605266664, "biz_type": 0, "category": "dj", "create_time": 1604593202, "icon": "smart/product_icon/dj.png", "id": "aaaaaaaaaaa", "ip": "xxxxxxxxxxxxxxxx", "lat": "xxxxxxxxxx", "local_key": "xxxxxxxxxxxxx", "lon": "-xxxxxxxxxx", "name": "Night Light", "online": true, "owner_id": "18344533", "product_id": "8UhAGZyCrYqYAcEc", "product_name": "RGBCW light", "status": [ { "code": "switch_led", "value": true }, { "code": "work_mode", "value": "colour" }, { "code": "bright_value", "value": 136 }, { "code": "temp_value", "value": 109 }, { "code": "colour_data", "value": "{\"h\":360.0,\"s\":218.0,\"v\":133.1}" }, { "code": "scene_data", "value": "{\"h\":37.5,\"s\":255.0,\"v\":189.0}" }, { "code": "flash_scene_1", "value": "{\"bright\":255,\"frequency\":80,\"hsv\":[{\"h\":120.0,\"s\":255.0,\"v\":255.0}],\"temperature\":255}" }, { "code": "flash_scene_2", "value": "{\"bright\":255,\"frequency\":128,\"hsv\":[{\"h\":0.0,\"s\":255.0,\"v\":255.0},{\"h\":120.0,\"s\":255.0,\"v\":255.0},{\"h\":240.0,\"s\":255.0,\"v\":255.0},{\"h\":0.0,\"s\":0.0,\"v\":0.0},{\"h\":0.0,\"s\":0.0,\"v\":0.0},{\"h\":0.0,\"s\":0.0,\"v\":0.0}],\"temperature\":255}" }, { "code": "flash_scene_3", "value": "{\"bright\":255,\"frequency\":80,\"hsv\":[{\"h\":0.0,\"s\":255.0,\"v\":255.0}],\"temperature\":255}" }, { "code": "flash_scene_4", "value": "{\"bright\":255,\"frequency\":5,\"hsv\":[{\"h\":0.0,\"s\":255.0,\"v\":255.0},{\"h\":120.0,\"s\":255.0,\"v\":255.0},{\"h\":60.0,\"s\":255.0,\"v\":255.0},{\"h\":300.0,\"s\":255.0,\"v\":255.0},{\"h\":240.0,\"s\":255.0,\"v\":255.0},{\"h\":0.0,\"s\":0.0,\"v\":0.0}],\"temperature\":255}" } ], "sub": false, "time_zone": "+00:00", "uid": "eu16044126174017IJNM", "update_time": 1627240844, "uuid": "3458238010521ccc0827" }

Device specifications

2021-07-26 10:09:42 DEBUG (SyncWorker_0) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/aaaaaaaaaaa/specifications, params = None, body = None, headers = {'client_id': 'xxxxxxxxxxxxxxx', 'sign': 'xxxxxxxxxxxxxxx', 'sign_method': 'HMAC-SHA256', 'access_token': 'xxxxxxxxxxxxxxx', 't': '1627290582093', 'lang': 'en'} 2021-07-26 10:09:42 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": { "category": "dj", "functions": [ { "code": "switch_led", "type": "Boolean", "values": "{}" }, { "code": "bright_value", "type": "Integer", "values": "{\"min\":25,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}" }, { "code": "work_mode", "type": "Enum", "values": "{\"range\":[\"white\",\"colour\"]}" }, { "code": "temp_value", "type": "Integer", "values": "{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}" }, { "code": "colour_data", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "scene_data", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_1", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_2", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_3", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_4", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" } ], "status": [ { "code": "switch_led", "type": "Boolean", "values": "{}" }, { "code": "work_mode", "type": "Enum", "values": "{\"range\":[\"white\",\"colour\"]}" }, { "code": "bright_value", "type": "Integer", "values": "{\"min\":25,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}" }, { "code": "colour_data", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "scene_data", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_1", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_2", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_3", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "flash_scene_4", "type": "Json", "values": "{\"h\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":1,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}" }, { "code": "temp_value", "type": "Integer", "values": "{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}" } ] }, "success": true, "t": 1627290582157 }

Additional context Add any other context or logs about the problem here.

XCraftMan52 commented 3 years ago

I am having the same issue

0xa51f commented 3 years ago

i also have the same

foltymat commented 3 years ago

I would like to expand on this a little bit. It seems that Home Assistant is not aware of the "white mode" of the bulbs. Like you said, changing the colour is not a problem, but there is no white option as well.

That means, that I have to change to white manually via the app and Home Assitant - not knowhing what white is, reports the last known colour.

0xa51f commented 3 years ago

I would like to expand on this a little bit. It seems that Home Assistant is not aware of the "white mode" of the bulbs. Like you said, changing the colour is not a problem, but there is no white option as well.

That means, that I have to change to white manually via the app and Home Assitant - not knowhing what white is, reports the last known colour.

i think this is related https://github.com/tuya/tuya-home-assistant/issues/131

foltymat commented 3 years ago

I would like to expand on this a little bit. It seems that Home Assistant is not aware of the "white mode" of the bulbs. Like you said, changing the colour is not a problem, but there is no white option as well. That means, that I have to change to white manually via the app and Home Assitant - not knowhing what white is, reports the last known colour.

i think this is related #131

Yeah, seems that both of these are tightly connected.

iotinkognito commented 3 years ago

Having the same issue.

howie1989 commented 3 years ago

I too am having the same issue, Also the effects dropdown is missing which I know my light supports. interestingly in the HA Lovelace dashboard when the light is on in its White mode "had to set it from the Tuya App" the icon shows a grey instead of yellow when turned on

howie1989 commented 3 years ago

Setting supported features to 21 seems to rectify the issue. Though it would be better if it picked this up automatically

foltymat commented 3 years ago

Setting supported features to 21 seems to rectify the issue. Though it would be better if it picked this up automatically

Can you explain how can one do that? I honestly just started using this integration and never changed supported features manually.

andreskebe commented 3 years ago

I am having the same issue, and I've also noticed that the color_mode stays as hs when switching to a white value. With my lifx bulbs the mode becomes color_temp and the bulb shows the right white state!

mikesellt commented 3 years ago

Same issue here. I have tried adding all kinds of supported features in customizations by following several guides, but nothing has worked yet. My bulbs are Merkury and Smart Life app has ability to choose white but HA doesn't. I just get rgb 255,255,255 but it doesn't use the white LEDs.

mikesellt commented 3 years ago

See issue #131 and several others. No fix as far as I know, but trying to get more attention to these issues.

iotinkognito commented 3 years ago

Plus 1

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: mikesellt @.> Sent: Saturday, August 7, 2021 3:13:35 PM To: tuya/tuya-home-assistant @.> Cc: iotinkognito @.>; Comment @.> Subject: Re: [tuya/tuya-home-assistant] Bulb continues to show old color in HA app after switching to white mode (#234)

See issue #131https://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftuya%2Ftuya-home-assistant%2Fissues%2F131&data=04%7C01%7C%7Caca610a7777f4ee427c408d95972e5b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637639172279723061%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=XFJH28HKUhzYKydLkvjAN%2BOm0GmKAkSpFR2g%2BYBGR70%3D&reserved=0 and several others. No fix as far as I know, but trying to get more attention to these issues.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftuya%2Ftuya-home-assistant%2Fissues%2F234%23issuecomment-894617433&data=04%7C01%7C%7Caca610a7777f4ee427c408d95972e5b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637639172279733017%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=I9VFdwi7X%2Fdo%2BxLvLWrzjm5GlSXUa%2BERa9BGcWRh7Qg%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FATTKFENAXEFUF7POK4QKRR3T3TMJ7ANCNFSM5A7X2AIQ&data=04%7C01%7C%7Caca610a7777f4ee427c408d95972e5b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637639172279733017%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=LwWcgA6Ye1FM3%2FcD5l9Ha4br8KMfFAGqm8BiuvvMkuM%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7Caca610a7777f4ee427c408d95972e5b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637639172279742976%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yzYDVZUTkNntnPQ6QxHlugNsFDrg4KbdSXTwMR3hpXs%3D&reserved=0 or Androidhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7C%7Caca610a7777f4ee427c408d95972e5b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637639172279742976%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=THY8YDAtYh1lgw3xr1dSC1B19236lyEu83da2PYcbFA%3D&reserved=0.

rmensing commented 3 years ago

I am having the same issue with a similar light. A Merkury BW904 Smart Bulb. I am a sometimes hobby coder so I know enough to read the code and have an idea of what it is doing but I don't know enough right now about HA Dev to fix it myself. I wanted to add my observations about what is/is not happening and, at least generally, what needs to be done I think.

To start with, in a nutshell, there are few types of lights that fall under category "dj" :

  1. White - single temperature
  2. White - adjustable temperature
  3. Color only
  4. Color with white - single temp
  5. Color with white - adjustable temp

Referencing the code for lights on the Tuya_v2 github. From what I see, each time the integration polls the API for the device it looks at the status responses and determines what options the device supports. Currently, the integration only sends 3 of the things to HA:

(code lines 14-16)

    SUPPORT_BRIGHTNESS,
    SUPPORT_COLOR,
    SUPPORT_COLOR_TEMP

If your device does not have Color Temp in the status, you do not get color temp adjustment in the UI even if you try and change it in the customizations.

When you change the brightness, the code will look at the Work_Mode to see if it is color or white so it knows how to adjust the brightness but it will not change the work mode. (Code lines 164 - 183)

If the color wheel on the UI is used to change the color while it is in white Work_Mode, it will change the Work_Mode to color. (Code lines 185 - 210, Specifically lines 209-210)

The ONLY time the Work_Mode is changed to white is if the Color_Temp is changed and it is not in white Work_Mode (Code lines 212 - 233, Specifically lines 232 - 233)

As it stands right now, the easiest way that I see for them to fix this is to add the color temp option to the lights that have a work_mode status. or at least make it so the color temp option is able to be set in the customizations. The only potential issue I see is that the Work_Mode status does not necessarily mean it supports both color and white because it also supports other options (ref. Tuya Standard instruction set of lights (dj).

An additional issue I see creating upon us that will have an effect on this and maybe why they aren't pushing code changes heavily is, the way light features/color modes for lights are being handled in Home Assistant is changing some of them have been deprecated and will be removed with Home Assistant Core 2021.10 (Oct. I am assuming since we are on 2021.8.x now)

Please feel free to correct me where I am wrong or just add your input.

Cross posted to #131, #234, and #308

sbur83 commented 3 years ago

Same here with both Mirrabella Genio bulbs and Connect Smart Home bulbs.