localtuya icon indicating copy to clipboard operation
localtuya copied to clipboard

DP 24 (for RGBW light) is None in some states

Open egorgam opened this issue 2 years ago • 8 comments

Hello!

I have a "Yandex lamp" device (Yeelight branded by russian vendor, working over Tuya B2B cloud) connected to TuyaSmart, and it works pretty nice with localtuya.

But if lamp was physically turned-off, last color mode wasn't "color", and hass was restarted, I see this message in logs:

2021-09-10 20:55:41 WARNING (SyncWorker_4) [custom_components.localtuya.light] [671...759] Entity light.y1 is requesting unknown DPS index 24

then, when I try to change color from hass or homekit (through preinstalled integration), I got this traceback (and color is not changing):

  File "/config/custom_components/localtuya/light.py", line 273, in __is_color_rgb_encoded
    return len(self.dps_conf(CONF_COLOR)) > 12
TypeError: object of type 'NoneType' has no len()

I added logging of self._status value in dps() function, and in this case it was:

2021-09-10 20:55:41 WARNING (MainThread) [custom_components.localtuya.light] [671...759] {'20': True, '21': 'white', '22': 1000, '23': 897, '26': 0}

After a small research, I templorary fixed it with small hardcode workaround. In common.py:

    def dps(self, dp_index):
        """Return cached value for DPS index."""

        value = self._status.get(str(dp_index))
        # self.warning(self._status)
    
        if dp_index == 24 and value is None:
            return '00EA02B203E8'

        if value is None:
            self.warning(
                "Entity %s is requesting unknown DPS index %s",
                self.entity_id,
                dp_index,
            )

        return value

and there is no any glitch when I set any color 🥳

Maybe a problem is because localtuya runs faster then device was fully initiated, or some devices needs dynamic dp definition. So please can you fix it, or put this workaround in localtuya release?

egorgam avatar Sep 10 '21 21:09 egorgam

I have the same issue with one of the light bulbs (also from Yandex) doing the "requesting unknown DPS index 24" thing. Your workaround fixed this for me. Thank you!

Mihonarium avatar Sep 24 '21 21:09 Mihonarium

I got the same issue, I just fixed it by setting the values with the Tuya app so that DP24 became populated.

Update: yeah it seems after HA restart somehow these values don't come back from the device.

I've got 2 devices here and unable to work out a pattern, one works then the other works etc... Both devices are blocked from internet access and dns

jeffborg avatar Oct 08 '21 00:10 jeffborg

@regevbr @rospogrigio the bug is still there :(

It would be great if someone could look into the issue

Mihonarium avatar Dec 27 '21 14:12 Mihonarium

Thanks, adding that part at the same spot in the existing function def dps(self, dp_index): of LocalTuya common.py patched it for me as well

        if dp_index == 24 and value is None:
            return '00EA02B203E8'

Yterz avatar Apr 10 '22 21:04 Yterz

Can confirm bug still exists and patching function helps. But for some reason i can't reploduce issue on all Yandex lamps, only on two out of 7 i have. Also this issue plagues config flow adoption of new devices as not all parameters discovered during process

belykhk avatar Jun 05 '22 15:06 belykhk

Can confirm bug exists for me using Fiat Electric RGB LED strip, patching function resolved it. Any reason this is not updated in the official release?

audifan88 avatar Oct 07 '22 02:10 audifan88

I have this issue with GLEDOPTO WiFi 5 in 1 LED Strip Controller for RGBCCT RGBW RGB WWCW controlling a RGBWWCW led strip. Going into the Tuya app and setting a color on the strip seems to fix the issue. Prior to doing that modifying the common.py and adding the function above didn't fix the issue for me. I could set Warm White and Cool white "colors" but no RGB through Local Tuya.

Darkside138 avatar Aug 28 '23 16:08 Darkside138

The same problem with the Yandex lamp. DP 24 and 25 disappear in Home Assistant from time to time. The device is also registered in the Smart Life application. If I switch the device to color mode in the application, the DP24 is immediately restored. Also if I switch the device to scene mode in the application, the DP25 is immediately restored.

anikin1971 avatar Feb 18 '24 10:02 anikin1971