WLED light preset value overriding light master entity "off" status

I’ve set up WLED with two presets:

  • Random Color - A preset with 5 segments and each segment selecting a random color
  • Night Light - A night light that is just pure white with the single segment

I can see both presets in Home Assistant.

I have 2 scenes in Home Assistant:

  • Evening lighting - this sets the LEDs to the Random Color preset
  • Night lighting - this sets the LEDs to the Night Light preset

Now, I want an automation that is triggered by my bedroom door sensor that would act as a night light for me when I get out of bed at night:

  1. Get out of bed and leave the bedroom by opening the door
  2. Door sensor is triggered which takes a snapshot scene of the WLED lights before turning on the Night Light scene.
  3. Wait a bit for the door to close again
  4. Door is closed and the lights get restored to the snapshot scene, if that means the light was previously off, it will be off.

Here is what I have so far for the automation:

alias: Turn on night lights when leaving the bedroom at night
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.bedroom_door_opening
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition:
  - condition: time
    after: "00:00:00"
    before: "06:00:00"
    weekday:
      - mon
      - tue
      - thu
      - wed
      - sat
      - fri
      - sun
action:
  - service: scene.create
    data:
      scene_id: snapshot_night_light_before
      snapshot_entities:
        - light.shelf_light
        - light.shelf_light_segment_1
        - light.shelf_light_segment_2
        - light.shelf_light_segment_3
        - light.shelf_light_segment_4
        - select.shelf_light_preset
        - light.shelf_light_master
  - service: scene.turn_on
    target:
      entity_id: scene.night_lighting
    metadata: {}
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.bedroom_door_opening
        from: "on"
        to: "off"
        for:
          hours: 0
          minutes: 1
          seconds: 0
    timeout:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.snapshot_night_light_before
mode: single

This works well if the snapshot does not contain a preset value that isn’t “unknown”. I.e, I need to have not used a preset before the night light turned on. So if I have the lights on the preset Random Colors, I then turn off the light, and then the automation runs, when the automation attempts to restore the state of the lights, instead of having the lights off, the lights remain on with the Random Colors preset. I think this is because of WLED or Home Assistant assuming that if I set a preset value, then it also sets the light’s master entity to whatever brightness the preset was at.

Is there a better way to configure this automation so that the preset value does not override the light’s master entity’s “off” status? I’ve tried adjusting the list of snapshot entities so that the master is the very last thing applied, but that doesn’t work.

Alternatively, I could add more logic in the automation to check if the lights were originally off and just turn the lights off instead of applying the snapshot.