localtuya
localtuya copied to clipboard
DP 24 (for RGBW light) is None in some states
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?
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!
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
@regevbr @rospogrigio the bug is still there :(
It would be great if someone could look into the issue
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'
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
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?
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.
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.