Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
egorgam opened this issue Sep 10, 2021 · 8 comments
Open

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

egorgam opened this issue Sep 10, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@egorgam
Copy link

egorgam commented Sep 10, 2021

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 egorgam added the bug Something isn't working label Sep 10, 2021
@Mihonarium
Copy link

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!

@jeffborg
Copy link

jeffborg commented Oct 8, 2021

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

@Mihonarium
Copy link

@regevbr @rospogrigio the bug is still there :(

It would be great if someone could look into the issue

@Yterz
Copy link

Yterz commented Apr 10, 2022

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'

@belykhk
Copy link

belykhk commented Jun 5, 2022

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

@audifan88
Copy link

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?

@Darkside138
Copy link

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.

@anikin1971
Copy link

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.

CloCkWeRX pushed a commit to CloCkWeRX/localtuya-experimental that referenced this issue Feb 25, 2025
* Fix typos and improve some sentences in README

* Update README.md

Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com>

* Update README.md

Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com>

* Update README.md

Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com>

* Update README.md

---------

Co-authored-by: Bander <46300268+xZetsubou@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants