WLED automation with segments

I currently have an automation script to turn on 99 ws2811 leds at sunset, randomly select an effect and palette every 10 seconds then turn off at a set time. I will be adding more leds and would like to set up segments, the script I am using was created using google and guesswork. So if I wanted to split the 99 leds into a 56 and 43 which have different random effects how to I do this.
my current script is

alias: shed_rgb_lights
description: ''
trigger:
  - platform: sun
    event: sunset
condition: []
action:
  - type: turn_on
    device_id: 836f5122ea9e3d8db25c264f34453538
    entity_id: light.wled
    domain: light
    brightness_pct: 55
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - repeat:
      until:
        - condition: time
          after: '23:00'
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
        - service: wled.effect
          target:
            entity_id: light.wled
          data:
            effect: '{{ state_attr(''light.wled'', ''effect_list'') | random }}'
            palette: '{{ range(0,53) | random }}'
  - type: turn_off
    device_id: 836f5122ea9e3d8db25c264f34453538
    entity_id: light.wled
    domain: light
mode: single

Please format your code.
See FAQ#11

1 Like

I can’t read your code as it is not formatted. However the docs say

Home Assistant treats every segment of the LED strip as a separate light entity

1 Like

I have set up a new segment in WLED via the UI web page.
the new segment_1 bit of the LEDs is changing every 10 seconds but the segment_master bit is not cycling effects but does light up with an effect initially

alias: shed_rgb_lights
description: ''
trigger:
 - platform: sun
   event: sunset
condition: []
action:
 - type: turn_on
   device_id: 836f5122ea9e3d8db25c264f34453538
   entity_id: light.wled
   domain: light
   brightness_pct: 55
 - delay:
     hours: 0
     minutes: 0
     seconds: 10
     milliseconds: 0
 - repeat:
     until:
       - condition: time
         after: '23:00'
     sequence:
       - delay:
           hours: 0
           minutes: 0
           seconds: 10
           milliseconds: 0
       - service: wled.effect
         target:
           entity_id: light.wled_segment_master
         data:
           effect: '{{ state_attr(''light.wled'', ''effect_list'') | random }}'
           palette: '{{ range(0,53) | random }}'
       - service: wled.effect
         target:
           entity_id: light.wled_segment_1
         data:
           effect: '{{ state_attr(''light.wled'', ''effect_list'') | random }}'
           palette: '{{ range(0,53) | random }}'
 - type: turn_off
   device_id: 836f5122ea9e3d8db25c264f34453538
   entity_id: light.wled
   domain: light
mode: single

Found the issue. When you create another segment the first segment stays as light.wled the newly created one becomes light.wled_segment_1. The light.wled_segment_master controls the overall brightness and palette for all the segments. So just in case anyone else wants to do something similar heres the code that seems to be working now.

alias: shed_rgb_lights
description: ''
trigger:
  - platform: sun
    event: sunset
condition: []
action:
  - type: turn_on
    device_id: 836f5122ea9e3d8db25c264f34453538
    entity_id: light.wled
    domain: light
    brightness_pct: 55
  - repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
        - service: wled.effect
          target:
            entity_id: light.wled
          data:
            effect: '{{ state_attr(''light.wled'', ''effect_list'') | random }}'
            palette: '{{ range(0,53) | random }}'
        - service: wled.effect
          target:
            entity_id: light.wled_segment_1
          data:
            effect: '{{ state_attr(''light.wled'', ''effect_list'') | random }}'
            palette: '{{ range(0,53) | random }}'
      until:
        - condition: time
          after: '23:00'
  - type: turn_off
    device_id: 836f5122ea9e3d8db25c264f34453538
    entity_id: light.wled
    domain: light
  - type: turn_off
    device_id: 836f5122ea9e3d8db25c264f34453538
    entity_id: light.wled_segment_1
    domain: light
mode: single
2 Likes