jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
951 stars 172 forks source link

set_colour(r,g,b) brightness problem #422

Closed batuttu closed 10 months ago

batuttu commented 10 months ago

Hi, d.set_brightness(200) d.set_colour(r,g,b) d.set_brightness(500) When you want to write the code this way, the brightness changes instantly in the set_colour line.

jasonacox commented 10 months ago

Interesting. I assume the bulb has some brightness default it uses when receiving the command to switch to color mode (which is part of the set_colour() function). It would be interesting to test some of these...

# Changing mode change brightness?
d.set_mode(mode="colour")

# Try using nowait
d.set_brightness(200, nowait=True)
d.set_colour(r,g,b, nowait=True)
d.set_brightness(500, nowait=True)

# Send color command without changing mode
d.set_brightness(200)
payload = d.generate_payload(
    CONTROL,
    {
        d.DPS_INDEX_COLOUR[d.bulb_type]: d._rgb_to_hexvalue(r, g, b, d.bulb_type),
    },
)
data = d._send_receive(payload)
d.set_brightness(500)
batuttu commented 10 months ago
# Changing mode change brightness? / Yes :/
# Nowait is not working :/
# Send color command without changing mode / Same, not working :/
uzlonewolf commented 10 months ago

What's the output of print(d.status()) and print(d.bulb_type) ?

uzlonewolf commented 10 months ago

Since we haven't heard back in 2 week I'm going to go ahead and close this. Feel free to re-open if you're still having issues.