Philips Hue device "pausing" during script

Greetings all,

I’ve got a script that shuts down my house for the evening. As you can see, the script has a conditional statement where if entity light.white_noise_machine–a Philips Hue smart plug connected via the Hue integration–is off, it turns the white noise machine on.

Interestingly, when the white noise machine is already on and I run the script, the white noise machine seems to “pause”, briefly turning off and back on again. This is unexpected since I wrapped the action in a conditional.

Maybe someone with more experience has an idea why this might be happening. Thank you!

alias: Good Night
sequence:
  - service: light.turn_off
    metadata: {}
    data: {}
    target:
      floor_id:
        - basement
        - outdoors
        - garage_attic
      area_id:
        - breakfast_nook
        - dining_room
        - front_foyer
        - kitchen
        - library
        - laundry_room
        - downstairs_hallway
        - garage
        - living_room
        - stairs
        - study
        - master_bathroom
        - master_bedroom
      device_id:
        - ddeb376b43a34e0bcfff8f79219164c6
        - bf2ece7f47785c89790b107cb278e24e
  - service: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: 6c5e69f7f6d78aeb02251b39a04c1606
  - if:
      - condition: state
        entity_id: light.white_noise_machine
        state: "off"
    then:
      - service: light.turn_on
        metadata: {}
        data: {}
        target:
          device_id: dae5cb369adfabfc9830326867dafdb2
    alias: If Off, Turn On White Noise Machine
  - service: cover.close_cover
    metadata: {}
    data: {}
    target:
      device_id:
        - 1c9bde8991456ed3c01edc2adefde0ae
        - 6277422d0d61778effb3d5f774b1f7d6
        - 92cca654d35736e989d4e5a594af1031
  - service: alarm_control_panel.alarm_arm_home
    metadata: {}
    data: {}
    target:
      device_id: 45ed1b95c21dcdbcb80c67383b1b64a0
mode: single
icon: mdi:power-sleep

This is solved. In retrospect, a stupid mistake. It was happening because the White Noise machine Smart Plug is classified as a light, and a previous action in the script turned off all the lights in that room.