Esphome conditions help needed

Hi all,

I am having an issue with getting a automation to work in esphome.

The gist of what I am is doing is automated stair lighting. I have the lights working as i want but I am struggling with one aspect.

I want the lights to come on top to bottom when the top sensor is activated then go off top to bottom when the bottom sensor is activated and vice versa.

Now I achieved this with out issue but what I also want is if the top sensor is activated then activated again before the bottom sensor the lights go off bottom to top, and this is where I am struggling.

The code I have that works is:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    id: strip
    name: led strip
    pin: D7
    num_leds: 70
    rgb_order: GRB
    effects:
      - addressable_color_wipe:
          name: Color Wipe Up On
          colors:
              red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
          add_led_interval: 15ms
      - addressable_color_wipe:
          name: Color Wipe Up Off
          colors:
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 15ms  
      - addressable_color_wipe:
          name: Color Wipe Down On
          colors:
              red: 100%
              green: 100%
              blue: 100%
              num_leds: 1
          add_led_interval: 15ms
          reverse: true          
      - addressable_color_wipe:
          name: Color Wipe Down Off
          colors:
            - red: 0%
              green: 0%
              blue: 0%
              num_leds: 1
          add_led_interval: 15ms            
          reverse: true


binary_sensor:
  - platform: gpio
    id: strip_sensor_up
    pin: 
      number: D1
      mode: INPUT_PULLUP
    filters:
      - invert 
    on_press:
      if:
        condition:
         - light.is_off: strip
        then:
          - light.turn_on: 
              id: strip
              effect: color wipe down on
          - wait_until: 
               binary_sensor.is_on: strip_sensor_up
          - light.turn_on: 
              id: strip
              effect: color wipe down off  
          - light.turn_off: strip

  - platform: gpio
    id: strip_sensor_down
    pin: 
      number: D2
      mode: INPUT_PULLUP
    filters:
      - invert 
    on_press:
      if:
        condition:
         - light.is_off: strip
        then:
          - light.turn_on: 
              id: strip
              effect: color wipe up on
          - wait_until: 
               binary_sensor.is_on: strip_sensor_up
          - light.turn_on: 
              id: strip
              effect: color wipe up off  

The code that doesn’t work is

  - platform: gpio
    id: strip_sensor_down
    pin: 
      number: D2
      mode: INPUT_PULLUP
    filters:
      - invert 
    on_press:
      if:
        condition:
         - light.is_off: strip
        then:
          - light.turn_on: 
              id: strip
              effect: color wipe up on
          - delay: 3s
          - if: 
              condition:
                binary_sensor.is_on: strip_sensor_up
              then:
               - light.turn_on: 
                  id: strip
                  effect: color wipe up off        
               - delay: 10s    
               - light.turn_off: strip                  
                  
          - if: 
              condition:
                binary_sensor.is_on: strip_sensor_down
              then:
               - light.turn_on: 
                  id: strip
                  effect: color wipe down off                
               - delay: 10s    
               - light.turn_off: strip

If i have hold the binary sensors on within the 3s delay it behaves as I want, but if they are pressed after the 3s delay nothing happens.
Hopefully you understand what I am trying to do.

Any help appreciated

I dont think that nested actions like this possible.

That would explain the difficulties I’m having.

Could this be solved with lambdas. Not that I know much about them but if its possible to achieve what I want, I will learn.