Twinkly Effect Automation

I may be me missing something but I’d love to be able to set Twinkly light effects in automations. Can a service be added for this?

Twinkly effects (movies) are not stored at device, but every time you select one are uploaded from phone. So you are asking for impossible. What can be done with 2022.12 is to have one effect loaded to device from phone and being activated/disactivated from HA integration.
While technicly it might be possible to intercept upload process to Twinkly, each movie is customized to specific lights configuration on the tree during mapping process, so even uploading this from HA and playing on specific Twinkly setup would most likely cause garbage effect…

So in HA you can now choose an effect stored in the device provided you have 2022.12 on HA and latest twinkly device firmware (image for example).

In case it’s not clear, to achieve this you must create a playlist on the app, which stores all the effects on the device in an order which is where the numbers come from. You then reload the integration and they are read into HA for the effect dropdown at the bottom of the more-info card.

What I’m wondering is how to activate these via an automation.

2 Likes

I also wondering how to activate effect via an automation.

It’s a bit of a bodge but if you specify the effect and state in a scene you can then call the scene using an automation. I’d love to see a twinkly light.set_effect service call though

3 Likes

Strange Home Assistant’s automations do not have an action to change a light’s effect. ESPhome’s neopixelbus platform does not provide an action to change a light’s effect either. However, using Lambdas, a template switch, and an interval component, you can automate the changing of effects.

light:
  - platform: neopixelbus
    type: GRB
    variant: WS2811
    pin: 23
    num_leds: 480
    name: NeoPixels
    id: neo_pix
    effects:
      - random:
      - random:
          name: Slow Random
          transition_length: 5s
          update_interval: 5s
      - random:
          name: Fast Random
          transition_length: 1s
          update_interval: 2s
      - pulse:
      - pulse:
          name: Fast Pulse
          transition_length: 0.5s
          update_interval: 0.5s
      - pulse:
          name: Slow Pulse
          transition_length: 2s
          update_interval: 2s
      - strobe:
      - strobe:
          name: Custom Strobe
          colors:
            - state: true
              brightness: 100%
              red: 100%
              green: 90%
              blue: 0%
              duration: 500ms
            - state: false
              duration: 75ms
            - state: true
              brightness: 100%
              red: 0%
              green: 100%
              blue: 0%
              duration: 500ms
            - state: false
              duration: 75ms
            - state: true
              brightness: 100%
              red: 100%
              green: 0%
              blue: 0%
              duration: 500ms
            - state: false
              duration: 75ms
      - flicker:
      - flicker:
          name: Custom Flicker
          alpha: 65%
          intensity: 100%
      - lambda:
          name: Custom Lambda
          update_interval: 1s
          lambda: |-
            static int state = 0;
            auto call = id(neo_pix).turn_on();
            // Transition of 1000ms = 1s
            call.set_transition_length(750);
            if (state == 0) {
              call.set_rgb(1.0, 1.0, 1.0);
            } else if (state == 1) {
              call.set_rgb(1.0, 0.0, 1.0);
            } else if (state == 2) {
              call.set_rgb(0.0, 0.0, 1.0);
            } else {
              call.set_rgb(1.0, 0.0, 0.0);
            }
            call.perform();
            state += 1;
            if (state == 4)
              state = 0;
      - addressable_rainbow:
      - addressable_rainbow:
          name: Custom Rainbow
          speed: 10
          width: 50
      - addressable_color_wipe:
      - addressable_color_wipe:
          name: Custom Wipe
          colors:
            - red: 0%
              green: 0%
              blue: 100%
              num_leds: 2
            - red: 100%
              green: 0%
              blue: 0%
              num_leds: 1
            - red: 0%
              green: 100%
              blue: 0%
              num_leds: 2
            - red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
          add_led_interval: 30ms
          reverse: false
      - addressable_scan:
      - addressable_scan:
          name: Custom Scan
          move_interval: 30ms
          scan_width: 1
      - addressable_twinkle:
      - addressable_twinkle:
          name: Custom Twinkle
          twinkle_probability: 100%
          progress_interval: 30ms
      - addressable_random_twinkle:
      - addressable_random_twinkle:
          name: Custom Random Twink
          twinkle_probability: 100%
          progress_interval: 30ms
      - addressable_fireworks:
      - addressable_fireworks:
          name: Fireworks Effect
          update_interval: 30ms
          spark_probability: 100%
          use_random_color: true
          fade_out_rate: 120
      - addressable_flicker:
      - addressable_flicker:
          name: Custom Flicker II
          update_interval: 20ms
          intensity: 20%

switch:
  - platform: template
    name: Automate LEDs
    id: automate_switch
    icon: mdi:electric-switch
    optimistic: true
    restore_mode: ALWAYS_OFF

interval:
  - interval: 17s
    then:
      - lambda: |-
          if (id(automate_switch).state) {
            static int executions = 0;
            auto leds = id(neo_pix).turn_on();
            switch (executions) {
              case 0:
                leds.set_effect("Fireworks Effect");
                leds.set_brightness(1);
                break;
              case 1:
                leds.set_effect("Rainbow");
                leds.set_brightness(.5);
                break;
              case 2:
                leds.set_effect("Custom Wipe");
                break;
              case 3:
                leds.set_effect("Custom Strobe");
                leds.set_brightness(.04);
                break;
            }
            executions += 1;
            if (executions == 4) {
              executions = 0;
            }
            leds.perform();
          }

This is working fine with an esp32 as the LED controller and HA Blue or ODROID N2+ equivalent running HA.

Has there been any update with the integration?
I have just added some twinkly curtains in daughters bedroom and have the effects correctly coming into the integration, but would love a way to select these via HA and voice.

1 Like

No integration specific update but Home assistants light.turn_on service contains an effect trigger in the data section now so you can do this without using scenes. I’ve not got the christmas lights out yet but when I do I’ll test this.

tested and working on my hue bulb though:

service: light.turn_on
data:
  effect: colorloop
target:
  entity_id: light.r07_l01_huelight

This pre-supposes you follow my above instructions to “install” the desired effects onto the twinkly controller first and reload the integration.

1 Like

Works like a charm! Many thanks. For the Twinkly strings, for "effect:", you need to provide the effect number instead of a string.

How do you find the effect number?

I am running Firmware 2.8.18 and app version 3.12.7

For Twinkly, you need recent hardware (one with enouh controller memory, the first models didn’t have that) and firmware, and you need to have uploaded several effects to the controller using the Twinkly app. I created a playlist for that.

The Twinkly integration will allow you to select a color or pick an effect from the ones uploaded to the controller. The twinkly playlist cannot be selected.

Using homekit integration, if a playlist is active when you turn it off, it will continue it when it is turned on. It does not allow you to pick an effect. Using the Twinkly integration, it will turn on with a last selected color, unless you specify the effect. So you cannot resume a playlist. Luckily you can have both integrations active at the same time.

Since you can set a specific effect from the playlist in HA, you could emulate the playlist from HA now. If you turn the Twinkly on in HA using the UI, you will see all uploaded effects in the dropdown at the bottom. These are the names that you can use in automations as well, in the light.turn_on service call.

Apparently, the number alone is enough. I hadn’t noticed that, I always used the full number plus name.

Cheers…more play time required :grin:

If I want to switch from an effect to a solid light colour, how do I stop the effect ?
If I set a colour with a service call, the effect seems to overridde it.
If I set a colour with the UI it seems to accept it.
What should I send in the service call to set a fixed colour ?

Thanks

1 Like

Hi all,

I solved the problem implementing the script from Kylehase ( Profile - kylehase - Home Assistant Community ).
Is a simple script that every time is called change the effect of a light to the next item.
The script is here : Select_next script for light effects

After the script I setup an automation that every minutes call that script and the Twinkly tree works fine and smooth.

thanks to all and BR.

Hi, did you figure out how to go from effect to solid color in service call?
I’ve tried
“effect”:none
“effect”:stop
“effect”:“None”
and similar, but no success.

Why don’t you try something like this (maybe i didn’ t get the point ,sorry ):

alias: Test albero
sequence:
  - service: light.turn_on
    target:
      entity_id: light.albero_di_natale
    data:
      color_name: blue
mode: single

Where light.albero_di_natale is my twinkly light.
This is only an on the flight example .

Sending just a colour didn’t stop the effect. But if I send a colour and brightness then it works.

Thanks anyway.

Anyone knows, why Homekit is resuming the playlist and the HA integration is not doing this.

I’m looking just for a way to resume or start a playlist. Anyone got a trick for this already (withoiut rebuilding the playlist in HA with a row of effects).

I’ve gotten a little bit further on this, and it may be the case that the light color needs to be black or white for Twinkly integration to resume too. When it was red with me, that would be how it came back on always. after I experimented with white/warm white colors, then the twinkly integration did go back to previous. But to be honest, I don’t really know what made the difference. I’d rather not toch it now if I’m not sure I’ll get it back.

I use node red with a number randomizer and a 30second trigger to shuffle through saved effects. Stopping and starting the randomizer via msg.reset on the trigger. Pretty neat that Twinkly uses numbers instead of names in that scenario. Yes, looking at you Nanoleaf.

Does anyone know how to implement a transition time without intermediaries as mentioned above? The inbuilt transition command doesn’t seem to work for me…

Edit: Concerning this Scene/Static transition issue. You could always create a scene with a solid color. Doesn’t really use space on the Controller.