Canonical way to return a light to previous state after notification via effect

I’m trying to use an ESP8266 smart bulb to notify in a few ways with different color patterns, but then return to its original state after the pattern is complete. The attached code works as long as the previous state was on, somehow. But, if the previous state was off, then the effect continues.

esphome:
  name: livingroom-light
  friendly_name: Livingroom Light

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "SuperSecretHere..."

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Livingroom Light Fallback"
    password: !secret fallback_ap_pw

# PWM outputs for each LED channel
output:
  - platform: esp8266_pwm
    pin: GPIO4
    frequency: 240 Hz
    id: pwm_red
  - platform: esp8266_pwm
    pin: GPIO12
    frequency: 240 Hz
    id: pwm_green
  - platform: esp8266_pwm
    pin: GPIO14
    frequency: 240 Hz
    id: pwm_blue
    max_power: 14%
  - platform: esp8266_pwm
    pin: GPIO5
    frequency: 240 Hz
    id: pwm_cw
  - platform: esp8266_pwm
    pin: GPIO13
    frequency: 240 Hz
    id: pwm_ww

light:
  - platform: rgbww
    name: light
    id: main_light
    red: pwm_red
    green: pwm_green
    blue: pwm_blue
    cold_white: pwm_cw
    warm_white: pwm_ww
    cold_white_color_temperature: 6500 K
    warm_white_color_temperature: 2700 K
    # constant_brightness: true
    # color_interlock: true
    effects:
      - strobe:
          name: SevenOclock
          colors:
            - brightness: 100%
              duration: 500ms
              color_mode: white
            - state: False
              duration: 500ms
      - strobe:
          name: Laundry
          colors:
            - color_mode: RGB
              brightness: 100%
              red: 0.0
              green: 1.0
              blue: 0.0
              duration: 1000ms
            - state: False
              duration: 1000ms
      - strobe:
          name: PhoneRing
          colors:
            - color_mode: RGB
              brightness: 100%
              red: 0.0
              green: 1.0
              blue: 0.0
              duration: 50ms
            - color_mode: RGB
              brightness: 100%
              red: 1.0
              green: 0.0
              blue: 0.0
              duration: 50ms
      - strobe:
          name: Doorbell
          colors:
            - color_mode: RGB
              brightness: 100%
              red: 1.0
              green: 0.0
              blue: 0.0
              duration: 800ms
            - color_mode: RGB
              brightness: 100%
              red: 0.0
              green: 1.0
              blue: 0.0
              duration: 2000ms

globals:
  - id: light_color_set
    type: LightColorValues

# Note: Restoration fails if previous state was off...
button:
  - platform: template
    id: laundry
    name: Laundry Done
    on_press:
      then:
        - globals.set:
            id: light_color_set
            value: !lambda 'return id(main_light).current_values;'
        - light.turn_on:
            id: main_light
            effect: Laundry
        - delay: 6s
        - lambda: |-
            auto call = id(main_light).turn_on();
            auto colormode = id(light_color_set);
            call.set_color_mode(colormode.get_color_mode());
            call.set_state(colormode.get_state());
            call.set_brightness(colormode.get_brightness());
            call.set_color_brightness(colormode.get_color_brightness());
            call.set_red(colormode.get_red());
            call.set_green(colormode.get_green());
            call.set_blue(colormode.get_blue());
            call.set_warm_white(colormode.get_warm_white());
            call.set_cold_white(colormode.get_cold_white());
            call.set_effect(0u);
            call.perform();
  - platform: template
    id: sevenOClock
    name: 7 Flashes
    on_press:
      then:
        - globals.set:
            id: light_color_set
            value: !lambda 'return id(main_light).current_values;'
        - light.turn_on:
            id: main_light
            effect: SevenOclock
        - delay: 7s
        - lambda: |-
            auto call = id(main_light).turn_on();
            auto colormode = id(light_color_set);
            call.set_color_mode(colormode.get_color_mode());
            call.set_state(colormode.get_state());
            call.set_brightness(colormode.get_brightness());
            call.set_color_brightness(colormode.get_color_brightness());
            call.set_red(colormode.get_red());
            call.set_green(colormode.get_green());
            call.set_blue(colormode.get_blue());
            call.set_warm_white(colormode.get_warm_white());
            call.set_cold_white(colormode.get_cold_white());
            call.set_effect(0u);
            call.perform();
  - platform: template
    id: PhoneRing
    name: Telephone
    on_press:
      then:
        - globals.set:
            id: light_color_set
            value: !lambda 'return id(main_light).current_values;'
        - light.turn_on:
            id: main_light
            effect: PhoneRing
        - delay: 1500ms
        - lambda: |-
            auto call = id(main_light).turn_on();
            auto colormode = id(light_color_set);
            call.set_color_mode(colormode.get_color_mode());
            call.set_state(colormode.get_state());
            call.set_brightness(colormode.get_brightness());
            call.set_color_brightness(colormode.get_color_brightness());
            call.set_red(colormode.get_red());
            call.set_green(colormode.get_green());
            call.set_blue(colormode.get_blue());
            call.set_warm_white(colormode.get_warm_white());
            call.set_cold_white(colormode.get_cold_white());
            call.set_effect(0u);
            call.perform();
  - platform: template
    id: Doorbell
    name: Doorbell
    on_press:
      then:
        - globals.set:
            id: light_color_set
            value: !lambda 'return id(main_light).current_values;'
        - light.turn_on:
            id: main_light
            effect: Doorbell
        - delay: 1800ms
        - lambda: |-
            auto call = id(main_light).turn_on();
            auto colormode = id(light_color_set);
            call.set_color_mode(colormode.get_color_mode());
            call.set_state(colormode.get_state());
            call.set_brightness(colormode.get_brightness());
            call.set_color_brightness(colormode.get_color_brightness());
            call.set_red(colormode.get_red());
            call.set_green(colormode.get_green());
            call.set_blue(colormode.get_blue());
            call.set_warm_white(colormode.get_warm_white());
            call.set_cold_white(colormode.get_cold_white());
            call.set_effect(0u);
            call.perform();

time:
  - platform: homeassistant
    id: ha_time
    timezone: US/Central

captive_portal: