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
858 stars 206 forks source link

Merkury BW904 Smart Bulb only has color option, but is an RGBW bulb #308

Open mikesellt opened 2 years ago

mikesellt commented 2 years ago

For this bulb, colors work fine from HA, but when I choose the color white, it only uses the color LEDs and not the white LEDs. HA is missing the white color (I think). I can set the white from the Smart Life app with no problem.

p.s. I think I removed the personal info from the log below, but please remove more if there is still some there (new at this... first log export)

Thanks

Device normal info

Device info (please complete the following information, which can be found in log): like this: { "active_time": 1628109806, "biz_type": 18, "category": "dj", "create_time": 1628109806, "icon": "smart/icon/ay1480002761059me2zH/d9c13d8169120823a3db4b7467195c58.png", "id": "eb4aa8cddaf085fbb1a3iu", "ip": "x.x.x.x", "lat": "41.2609155", "local_key": "85f16ad234a78a79", "lon": "-111.9553291", "model": "", "name": "Merkury BW904 Smart Bulb 2", "online": true, "owner_id": "20202222", "product_id": "jxfp7dobvcneylao", "product_name": "Merkury BW904 Smart Bulb", "status": [ { "code": "switch_led", "value": true }, { "code": "work_mode", "value": "colour" }, { "code": "bright_value_v2", "value": 1000 }, { "code": "colour_data_v2", "value": "{\"h\":60,\"s\":972,\"v\":1000}" }, { "code": "scene_data_v2", "value": "{\"scene_num\":1,\"scene_units\":[{\"bright\":200,\"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": "-06:00", "uid": "az1595291392815ifJaS", "update_time": 1628109840, "uuid": "401c8781bf55b7b0" },

2021-08-04 14:54:19 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaus.com/v1.0/devices/eb4aa8cddaf085fbb1a3iu/specifications, params = None, body = None, headers = "result": { "client_id": "xxxxxxxx", "expire_time": 7200, "password": "xxxxxxxx", "sink_topic": { "device": "cloud/token/out/{device_id}" }, "source_topic": { "device": "cloud/token/in/xxxxxxxxxx" }, "url": "ssl://m1.tuyaus.com:8883", "username": "xxxxxxxxxx" }, "success": true, "t": 1628110459080 } 2021-08-04 14:54:19 DEBUG (Thread-3) [tuya iot] connecting ssl://m1.tuyaus.com:8883 2021-08-04 14:54:19 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "dj", "functions": [ { "code": "switch_led", "type": "Boolean", "values": "{}" }, { "code": "work_mode", "type": "Enum", "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}" }, { "code": "bright_value_v2", "type": "Integer", "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}" }, { "code": "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", "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", "type": "Integer", "values": "{\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "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}}" } ], "status": [ { "code": "switch_led", "type": "Boolean", "values": "{}" }, { "code": "work_mode", "type": "Enum", "values": "{\"range\":[\"white\",\"colour\",\"scene\",\"music\"]}" }, { "code": "bright_value_v2", "type": "Integer", "values": "{\"min\":10,\"max\":1000,\"scale\":0,\"step\":1}" }, { "code": "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", "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", "type": "Integer", "values": "{\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "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}}" } ] }, "success": true, "t": 1628110459131 }

mikesellt commented 2 years ago

FYI I tried changing the features of the bulb under customizations in HA, but that didn't work. I followed this:

https://orbitcityhomes.com/2020/07/tuya-lights-getting-color-sliders-to-work-in-home-assistant/

mikesellt commented 2 years ago

Also see issue #131. It looks like the same issue as this one, though it may be for a different brand of bulb.
https://github.com/tuya/tuya-home-assistant/issues/131

mikesellt commented 2 years ago

I just tried changing values under "customization" for over an hour. I could get different brightness sliders and other options to show up, but they wouldn't change anything. I ended up going back to default, and again, color and brightness work (in color mode). I can't get any kind of "white" settings (temp, brightness) to work at all. I checked this against the debug values in iot.tuya.com for the device, but none of those values worked either when trying them in HA.

rmensing commented 2 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

frenck commented 2 years ago

This should be fixed in the latest version of Home Assistant, could you check?

mikesellt commented 2 years ago

This should be fixed in the latest version of Home Assistant, could you check?

Frenck, thanks for the update. The bulb still shows RGB only. Is there anything I need to do to re-sync the device or the integration to try and push a change? image

frenck commented 2 years ago

On the device page, there is a download diagnostics button, could you click it and drag that downloaded file into a response in this issue?

daveneeley commented 9 months ago

Here is a diagnostic file for a Merkury BW904 Smart Bulb.

Home Assistant 2023.8.4 Frontend 20230802.1 - latest

Interestingly, if I manually pair the bulb in the Tuya android app as "Light Source (BLE+Wi-fi)" it will appears as a "Merkury Smart Color Bulb" in the Tuya cloud developer panel and the additional temperature control will be present in HA for that bulb. However HA still reports the bulb product name as Merkury BW904 Smart Bulb.

Merkury BW904 Smart Bulb

Merkury Smart Color Bulb

bigboigahoy commented 5 months ago

Screenshot 2024-01-25 at 12 50 41 AM

I have the same issue. Trying to use "Light Source (BLE+Wi-fi)" did not work for me. I only have color at the moment with my bulbs. I have attached my diagnostic.

Edit: It appears that some of the bulbs I have do work with this setting, but not all of them. Weird...

tuya-4c97de23c5f3a98be9a4a02b904f179e-Bed Light-34381faacae80c2e82cdf5ce445a0587.json.txt