rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.94k stars 562 forks source link

RGBW Control #143

Open buzurk26 opened 4 years ago

buzurk26 commented 4 years ago

Hi, Great plugin, got my bulbs into HA finally which is great!

Couple of things i am missing and hope to be able to add are

image

ultratoto14 commented 4 years ago

Hi @buzurk26 there is already an issue open about scenes: #131 About the white value, for the moment changing the color_temp is the only way to switch to white.

If you have this configurations options, can you describe the behavior of the white value slider in conjunction of the brightness one ? Are they linked in any manner ? What are the way to go from color to white and the opposite ?

FeikoJoosten commented 3 years ago

I'd like to add onto this. I have a RGBCW bulb which isn't functioning just right either. It seems as if I'm missing an option, and I believe the white value might help out with this. For reference, these are the bulbs I have.

Edit: I had a misconfiguration where I assigned the max brightness as 100 instead of 255. This partially resolves my issue, but I still have an issue where assigning the color White causes the lamp to turn white/blueish. So I still think something is off.

Added a screenshot of my configuration. image

ultratoto14 commented 3 years ago

Hi @FeikoJoosten, i assume you are using master.

Some questions:

Now, to help in debugging, I need to first know the boundaries of the light.

Using the tuya app, set the brightness/color_temp/white_value to max and min and each time, using How to get a DP dump write down the values and report here.

Thanks.

ultratoto14 commented 3 years ago

@postlund question for you, when you edit the entity-configuration, the values are not synced, aren't they ?

postlund commented 3 years ago

@ultratoto14 Currently no, they have values from when the device was initially added. Would be great to fix that...

ultratoto14 commented 3 years ago

@postlund just thinking of a way to easily have DP dumps for users, maybe a configuration option that can add full DPs as an extra attribute, or even as an automatically added text sensor ?

postlund commented 3 years ago

@ultratoto14 I was working on a debug menu for the config flow to do this a while back, but it got messy and didn't fit in so I abandoned it. My intention is to add it as an attribute to a status sensor, once I get the going. I think I have some base code laying around for it, will se when I can fix and push it.

FeikoJoosten commented 3 years ago

Hi @ultratoto14, thanks for your response!

Hi @FeikoJoosten, i assume you are using master.

Yes, I'm indeed using the master version.

  • What happens when you move the slider of the color_temp ?

The bulb does change it's color temperature properly.

  • Can you describe from switch on to the problem, what are the steps you are using ?

I switch the switch on using HomeAssistant. And I set the color to white using the color wheel. I have 2 bulbs of this model/type. 1 of which is still synced through Tuya and the other bulb is now synced through LocalTuya. When I do the same with the Tuya bulb it is set properly to a color of white. With the LocalTuya one, it's set to a blue ish white.

  • From the color value here, the bulb is using the RGB coding of color. The scene value seems to be quite long for this coding.

Yeah my screenshot was a bit outdated, as I had now set the scene value to value 6 which properly assigned the scene value. Up to date screenshot: image

Using the tuya app, set the brightness/color_temp/white_value to max and min and each time, using How to get a DP dump write down the values and report here.

I'd love to do a datadumb, but for some reason the lamp doesn't want me to do this. (Yes it's disconnected from the Tuya app, no other devices are interacting with it, etc).

C:\Users\Feiko\Downloads\tuyadebug\tuyadebug>test.py 80157022e09806021245 192.168.0.60 b0282753461fa169
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
INFO:localtuya:Using pytuya version '8.1.0'
INFO:localtuya:Detecting list of available DPS of device 80157022e09806021245 [192.168.0.60], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"80157022e09806021245","devId":"80157022e09806021245"}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.0.60. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: [WinError 10054] An existing connection was forcibly closed by the remote host
INFO:localtuya:Detecting list of available DPS of device 80157022e09806021245 [192.168.0.60], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"80157022e09806021245","devId":"80157022e09806021245"}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.0.60. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: [WinError 10054] An existing connection was forcibly closed by the remote host
INFO:localtuya:Detecting list of available DPS of device 80157022e09806021245 [192.168.0.60], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"80157022e09806021245","devId":"80157022e09806021245"}'
DEBUG:localtuya.pytuya:Failed to connect to 192.168.0.60. Raising Exception.
WARNING:localtuya.pytuya:Failed to get status: [WinError 10054] An existing connection was forcibly closed by the remote host
INFO:localtuya:TIMEOUT: No response from device 80157022e09806021245 [192.168.0.60] after 2 attempts.
FeikoJoosten commented 3 years ago

@ultratoto14 Okay, I managed to do a DP of the Tuya device. Here are the DPs

Max:

Device 80157022e09806020421 at 192.168.0.129 key f82e00d819d54955 protocol 3.3 dev_type type_0a:
    DPS [1] VALUE [True]
    DPS [2] VALUE [white]
    DPS [3] VALUE [255]
    DPS [4] VALUE [255]
    DPS [5] VALUE [0040ff00e1ffff]
    DPS [6] VALUE [bd76000168ffff]
    DPS [7] VALUE [ffff500100ff00]
    DPS [8] VALUE [ffff8003ff000000ff000000ff000000000000000000]
    DPS [9] VALUE [ffff5001ff0000]
    DPS [10] VALUE [ffff0505ff000000ff00ffff00ff00ff0000ff000000]

Min:

Device 80157022e09806020421 at 192.168.0.129 key f82e00d819d54955 protocol 3.3 dev_type type_0a:
    DPS [1] VALUE [True]
    DPS [2] VALUE [white]
    DPS [3] VALUE [25]
    DPS [4] VALUE [0]
    DPS [5] VALUE [ff00130163ffff]
    DPS [6] VALUE [bd76000168ffff]
    DPS [7] VALUE [ffff500100ff00]
    DPS [8] VALUE [ffff8003ff000000ff000000ff000000000000000000]
    DPS [9] VALUE [ffff5001ff0000]
    DPS [10] VALUE [ffff0505ff000000ff00ffff00ff00ff0000ff000000]
ultratoto14 commented 3 years ago

@FeikoJoosten Sorry to bother you, the two dumps are exactly the same, something went wrong.

FeikoJoosten commented 3 years ago

@ultratoto14 Whoops my bad. That was a copy paste mistake haha. Anyway, I've fixed the original post.

I'd also like to point out that the info in TuyaCloud is pretty convenient as well as it gives a bit more context what each value stands for. image

FeikoJoosten commented 3 years ago

Also figured out that I had a min brightness value assigned of 0. Changing it to 25 does increase the min brightness level. However, it's now clear that assigning white using the color wheel in HomeAssistant makes the lamp go purple instead of blue ish.

ultratoto14 commented 3 years ago

@FeikoJoosten Ahhh, its clearer now ๐Ÿ˜„. On the tuya devices the white and colors are separated. When you use the color picker to change to white, it still use the color leds to display your choice, it explains why you have this behavior. To switch to white, try to change the color_temp slider instead.

FeikoJoosten commented 3 years ago

@ultratoto14 that does seem to make sense, but I'd say this is a bug then though. As the regular Tuya integration does support this properly. The lamp switches to white mode whenever I select the white color ๐Ÿ˜‰

ultratoto14 commented 3 years ago

@FeikoJoosten can you check the PR #182 ?

buzurk26 commented 3 years ago

how do you get the DPs, I got some mirabella genio bulbs https://www.kmart.com.au/product/mirabella-genio-smart-home-wi-fi-dimmable-5w-led-light/3188305, i got them into localtuya, i can get power on/off but thats about it

FeikoJoosten commented 3 years ago

@ultratoto14 What exactly do you want me to check? ๐Ÿ˜… The code or the functionality?

@buzurk26 I added the lamp using Tuya/Smart Life and then followed the instructions from HOWTO get a DPs dump. Be sure to close the Tuya/Smart Life app as it can interfere with the connection. The LocalTuya approach never worked for me.

ultratoto14 commented 3 years ago

@FeikoJoosten the functionality as it should be a fix to your issue ๐Ÿ˜„ (but to do so you need to test the code on your install)

ThomasCr commented 2 years ago

@FeikoJoosten how you got the info from your screenshot of the cloud?

Maybe it would help to figure out, how we can find a better way to set our devices.

I put my idea at https://github.com/rospogrigio/localtuya/issues/659

FeikoJoosten commented 2 years ago

@ThomasCr loging to iot.tuya.com. On the side --> Cloud --> Development --> Ensure the correct data center (top right) --> click on the devices tab --> select a list of your devices under the all devices catergory. --> Hit Debug Device

evlo commented 2 years ago

[WinError 10054] An existing connection was forcibly closed by the remote host

@FeikoJoosten How did you get DPs after that error?

I'm stuck on that error for the device that does not have function set in tuya cloud image

FeikoJoosten commented 2 years ago

Sorry, itโ€™s been way over a year since Iโ€™ve looked at that. I donโ€™t recall on how you should do this.

evlo commented 2 years ago

as for the error message - tuya app on phone and other means of connecting to the device can't be used at the same time

as for the missing instruction set in iot.tuya.com - no idea