rospogrigio / localtuya

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

Add custom effect for lights #331

Open Yuke-hd opened 3 years ago

Yuke-hd commented 3 years ago

In light.py I found

SCENE_LIST_RGBW_1000 = {
    "Night": "000e0d0000000000000000c80000",
    "Read": "010e0d0000000000000003e801f4",
    "Meeting": "020e0d0000000000000003e803e8",
    "Leasure": "030e0d0000000000000001f401f4",
    "Soft": "04464602007803e803e800000000464602007803e8000a00000000",
    "Rainbow": "05464601000003e803e800000000464601007803e803e80000000046460100f003e803"
    + "e800000000",
    "Shine": "06464601000003e803e800000000464601007803e803e80000000046460100f003e803e8"
    + "00000000",
    "Beautiful": "07464602000003e803e800000000464602007803e803e80000000046460200f003e8"
    + "03e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e80"
    + "3e800000000",
}

After playing with it for a while I found:

"Shine": "06464601000003e803e800000000464601007803e803e80000000046460100f003e803e8"
    + "00000000",

A  B    C  D    E    F    G
06 4646 01 0000 03e0 03e8 00000000

A = No. of entry in the APP aka "scene_num" B = "unit_switch_duration" and "unit_gradient_duration" C = "unit_change_mode" [“static”,“jump”,“gradient”] (01-02) D = four bytes of hue (0-0168) E = four bytes of saturation (0-03e8) F = four bytes of brightness (0-03e8) G= padding (not sure)

I was able to manually add my on effect:

"Alert": "06606001016803e803e80000000060600100f003e803e800000000",

It's just flash red and blue

Can someone confirm if the data schema is correct and is there a way to add custom effect via config-flow?

Yuke-hd commented 3 years ago

Is there a tutorial on HA config-flow? I'm interested in implementing this feature myself, at least give it a try

KTibow commented 3 years ago

See https://developers.home-assistant.io.

bongzyx commented 3 years ago

I made a little Python script to decode or create new effect set. It is interactive and hope can be added to a GUI

localtuyaDecoder.py.zip

KTibow commented 3 years ago

@brandonongzy Nice! Small suggestion: Format it with Black. Also consider uploading it as a GitHub gist/repo.

bongzyx commented 3 years ago

@brandonongzy Nice! Small suggestion: Format it with Black. Also consider uploading it as a GitHub gist/repo.

Thanks for the suggestion, I have published to a repo here https://github.com/brandonongzy/LocalTuyaDecoder :)

acs-lux commented 3 years ago

Hi,

I finally figured out the dps for my led strip that didn't match the example. Now i can go crazy colours for party time locally.

Its great but my question is...

Is transition supported in localtuya? For me it has no affect on the speed of changes.

This is still worth all the effort since the official tuya is still cloud based and is the best thing i found for HA so far imho.

KTibow commented 3 years ago

@acs-lux I don't think that Tuya on its own supports transition, and localtuya doesn't add that. Effects (part of Tuya on its own) might be used to add that, though.

acs-lux commented 3 years ago

Ah ok thanks

ThomasCr commented 1 year ago

I will also be Interested on this, because I also miss some scenes. https://github.com/rospogrigio/localtuya/issues/659