[SOLVED] Effect: "None" not triggering automation

Setup: In short ESPHome device, made of WS2812B LED strip. 50 pixels in summary, split in 5x10 pixels via partition platform. Proudly made by me :crazy_face: :crazy_face:

This is the ESPHome configuration:

esphome:
  name: bottle-lights

esp8266:
  board: esp01

logger:

api:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
e131:
  method: multicast
  
light:
  - platform: neopixelbus
    variant: WS2812X
    pin: GPIO0
    num_leds: 50
    name: "Bottle Lights Complete"
    id: strip
    type: GRB
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: neopixelbus
    variant: WS2812X
    pin: GPIO15
    num_leds: 10
    name: "Bottle Lights"
    id: dummy
    type: GRB
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: partition
    name: "Bottle 1"
    id: bottle1
    segments:
      - id: strip
        from: 40
        to: 49
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: partition
    name: "Bottle 2"
    id: bottle2
    segments:
      - id: strip
        from: 30
        to: 39
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: partition
    name: "Bottle 3"
    id: bottle3
    segments:
      - id: strip
        from: 20
        to: 29
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: partition
    name: "Bottle 4"
    id: bottle4
    segments:
      - id: strip
        from: 10
        to: 19
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
  - platform: partition
    name: "Bottle 5"
    id: bottle5
    segments:
      - id: strip
        from: 0
        to: 9
    effects:
      - e131:
          universe: 1
          channels: RGB
      - random:
      - pulse:
      - strobe:
      - flicker:
      - addressable_rainbow:
      - addressable_color_wipe:
      - addressable_scan:
      - addressable_twinkle:
      - addressable_random_twinkle:
      - addressable_fireworks:
      
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: True
    name: "Bottle Lights Button"
    on_click:
    - min_length: 5ms
      max_length: 1000ms
      then:
        - if:
            condition:
              light.is_on: strip
            then:
              - light.turn_off:
                  id: strip
        - if:
            condition:
              light.is_off: bottle4
            then:
              - light.turn_on:
                  id: bottle4
                  effect: "flicker"
            else:
              - light.turn_off: bottle4 
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - if:
            condition:
              light.is_off: bottle2
            then:
              - light.turn_on:
                  id: bottle2
                  effect: "flicker"
            else:
              - light.turn_off: bottle2
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - if:
            condition:
              light.is_off: bottle5
            then:
              - light.turn_on:
                  id: bottle5
                  effect: "flicker"
            else:
              - light.turn_off: bottle5
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - if:
            condition:
              light.is_off: bottle3
            then:
              - light.turn_on: 
                  id: bottle3
                  effect: "flicker"
            else:
              - light.turn_off: bottle3
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - if:
            condition:
              light.is_off: bottle1
            then:
              - light.turn_on: 
                  id: bottle1
                  effect: "flicker"
            else:
              - light.turn_off: bottle1
    - min_length: 1001ms
      max_length: 3000ms
      then:
        - if:
            condition:
              light.is_on: strip
            then:
              - light.turn_off:
                  id: strip
        - light.turn_on:
            id: bottle5
            brightness: 100%
            red: 100%
            green: 84%
            blue: 38%
            effect: "flicker"
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - light.turn_on:
            id: bottle2
            brightness: 100%
            red: 100%
            green: 84%
            blue: 38%
            effect: "flicker"
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - light.turn_on:
            id: bottle3
            brightness: 100%
            red: 100%
            green: 84%
            blue: 38%
            effect: "flicker"
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - light.turn_on:
            id: bottle1
            brightness: 100%
            red: 100%
            green: 84%
            blue: 38%
            effect: "flicker"
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - light.turn_on:
            id: bottle4
            brightness: 100%
            red: 100%
            green: 84%
            blue: 38%
            effect: "flicker"
    - min_length: 3001ms
      max_length: 10000ms
      then:
        - if:
            condition:
              light.is_on: strip
            then:
              - light.turn_off:
                  id: strip
        - homeassistant.service:
            service: script.bottle_lights_random_color

The idea is that I would have 5 separate “bottle entities” (Bottle 1, 2, 3, 4 and 5) which would be controlled with one dummy entity (Bottle Lights). “Bottle Lights” is “connected” to GPIO15. GPIO15 is not exist on ESP01S module, so as said, it is dummy. It’s purpose is only to have it inside HA as light entity, so I can turn it on/of, change color, etc. and transfer it’s value to every separate bottle via automation, with 1 second delay between bottles.

Not important for current situation, but just to explain: “Bottle Lights Complete” is whole strip, all 50 pixels, and it is controlable directly from HA. This is something I will need later.

Ok, as said, the idea is that I change color or brightness or effect on dummy “Bottle Lights” entity, then automation should apply same color/brightness/effect values from “Bottle Lights” to “Bottle 5”, wait 1 second, apply to “Bottle 2”, wait 1 second, etc. all 5 bottles.

This is the automation:

- id: '1652174226030'
  alias: Bottle Lights Dummy
  description: ''
  trigger:
  - platform: state
    entity_id: light.bottle_lights
    attribute: brightness
  - platform: state
    entity_id: light.bottle_lights
    attribute: rgb_color
  - platform: state
    entity_id: light.bottle_lights
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: light.bottle_lights
    from: 'on'
    to: 'off'
  - platform: state
    entity_id: light.bottle_lights
    attribute: effect
  condition: []
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', ''effect'') }}

            '
        entity_id: light.bottle_5
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_5
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', ''effect'') }}

            '
        entity_id: light.bottle_2
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_2
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', ''effect'') }}

            '
        entity_id: light.bottle_3
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_3
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', ''effect'') }}

            '
        entity_id: light.bottle_1
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_1
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', ''effect'') }}

            '
        entity_id: light.bottle_4
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_4
    default: []
  mode: single

Everything is working like a charm, except when I’m playing with effects. If I change the effect on dummy “Bottle Lights” entity, this is also ok - new effect will be applied on all 5 bottles, second by second. But if turn off the effect on dummy entity, i.e. set effect to None, then nothing happens. Basically, if I turn on any effect via dummy entity, it is not possible switch back to None any more, I can only switch between effects (of course, I can switch to None via each single entity lovelace card - Bottle 1, 2, 3…)

Is it possible that automation cannot be triggered if some state has been changed to “None”?

Sorry for long post, I was try to explain best I can. Thanks in advance, if you need any additional info… :innocent:

Hey, I solved it on my own. It wasn’t that not triggering, but was that not executing, cause it seems it wont to pass “None” as value to template.

I added one more “Choose”, where I declared if effect is “None”, then apply “Flicker” effect. This is ok for me, cause I anyway wanted these bottles to shinning with “Flicker” effect, as normal solid color behavior, cause this is making them little more rustic :grin:

I also removed all previous ridiculous triggers, for every state change and attribute change and left only one “empty” trigger - for any state change.

So this is the complete automation:

- id: '1652174226030'
  alias: Bottle Lights Dummy
  description: ''
  trigger:
  - platform: state
    entity_id: light.bottle_lights
  condition: []
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: None
        attribute: effect
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: Flicker
        entity_id: light.bottle_5
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_5
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', "effect") }}

            '
        entity_id: light.bottle_5
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: None
        attribute: effect
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: Flicker
        entity_id: light.bottle_2
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_2
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', "effect") }}

            '
        entity_id: light.bottle_2
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: None
        attribute: effect
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: Flicker
        entity_id: light.bottle_3
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_3
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', "effect") }}

            '
        entity_id: light.bottle_3
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: None
        attribute: effect
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: Flicker
        entity_id: light.bottle_1
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_1
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', "effect") }}

            '
        entity_id: light.bottle_1
    default: []
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - choose:
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: None
        attribute: effect
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: Flicker
        entity_id: light.bottle_4
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'off'
      sequence:
      - service: light.turn_off
        entity_id: light.bottle_4
    - conditions:
      - condition: state
        entity_id: light.bottle_lights
        state: 'on'
      sequence:
      - service: light.turn_on
        data_template:
          rgb_color: '{{ state_attr(''light.bottle_lights'', ''rgb_color'') }}

            '
          brightness: '{{ state_attr(''light.bottle_lights'', ''brightness'') }}

            '
          effect: '{{ state_attr(''light.bottle_lights'', "effect") }}

            '
        entity_id: light.bottle_4
    default: []
  mode: single