Script Blueprint to flash a custom color light a x amount of times and restore its previous state

This blueprint will create a script that flashes some lights a certain amount of times and restores them at their previous state.

You can customize the number of flashes, color, brightness and the time which the lights stay ON or OFF

This was inspired by @markus78 's blueprint simple-flashing-lights-via-on-off-and-delay-restore-previous-light-states

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Flash lights
  description: Create a script that flashes lights and restore them at their previous state.
  domain: script
  input:
    target_lights:
      name: Lights
      description: Lights to flash
      selector:
        entity:
          filter: 
            domain: light
          multiple: true
    number_of_times:
      name: Number of times to flash
      description: How many times to flash the lights
      selector:
        number:
          min: 0
          max: 100
          mode: box
          unit_of_measurement: times    
    color_rgb:
      name: RGB Color
      description: Choose the color for blinking lights
      selector:
        select:
          options:
            - white   
            - red
            - green
            - lime
            - blue
            - navy
            - yellow
            - orange
            - turquoise
            - violet
            - magenta
            - aliceblue
            - antiquewhite
            - aquamarine
            - aqua
            - cadetblue
            - coral
            - cornflowerblue
            - crimson
            - darkblue
            - darkorange
            - darkorchid
            - darksalmon
            - darkslategray
            - deeppink
            - darkviolet
            - deepskyblue
            - ghostwhite
            - gold
            - lawngreen
            - lightcoral
            - lightgreen
            - lightseagreen
    brightness_pct:
      name: Brightness
      description: Color Brightness percentage
      default: 100
      selector:
        number:
          min: 0
          max: 100
          unit_of_measurement: '%'
          step: 1.0
          mode: slider
    advanced:
      name: Advanced
      collapsed: true
      input:
        delay_on:
          name: (OPTIONAL) ON Delay
          description: Time which the light is off
          default: 1
          selector:
            number:
              min: 0.0
              max: 5
              unit_of_measurement: s
              step: 0.1
              mode: slider

        delay_off:
          name: (OPTIONAL) OFF Delay
          description: Time which the light is off
          default: 1
          selector:
            number:
              min: 0.0
              max: 5
              unit_of_measurement: s
              step: 0.1
              mode: slider
mode: restart
max_exceeded: silent
sequence:
- service: scene.create
  data:
    scene_id: light_flash_snapshot
    snapshot_entities: !input 'target_lights'
- delay:
    hours: 0
    minutes: 0
    seconds: !input 'delay_on'
- service: light.turn_on
  target: 
    entity_id: !input 'target_lights'
  data:
    color_name: !input 'color_rgb'
    brightness_step_pct: !input 'brightness_pct'
- repeat:
    count: !input 'number_of_times'
    sequence:
    - service: light.turn_off
      data: {}
      target: 
        entity_id: !input 'target_lights'
    - delay:
            hours: 0
            minutes: 0
            seconds: !input 'delay_off'
    - service: light.turn_on
      target: 
        entity_id: !input 'target_lights'
      data:
        color_name: !input 'color_rgb'
        brightness_step_pct: !input 'brightness_pct'
    - delay:
            hours: 0
            minutes: 0
            seconds: !input 'delay_on'
- service: scene.turn_on
  data:
    entity_id: scene.light_flash_snapshot

preview:

3 Likes

Hi. I have been using this for an indicator light in my kitchen that flashes when my boiler turns on.

The same script runs a few times a day. Every so often, however, the snapshot reset step seems to turn on every smart light in my house, rather than just return the indicator light to the previous state. I can see this in the logs for any of these accidentally toggled lights but only one device is defined in the blueprint script that triggers them.

Any ideas whether this snapshot step can lose the device id and just activate light entity types?

The blueprint creates a snapshot of all lights in your house.

Ideally it should create a snapshot of only the lights that will be flashed (not all lights).

Exactly… it’s possible to take a snapshot of just a bunch of lights but unfortunately i don’t know how to pass them from the blueprint interface to the template that creates the snapshot.

I’ve this Blueprint to blinking lights:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

it will blink lights. You will have some configurable parameters like number of blinks, time for each light status change and the scene to activate before (it’s very useful if you need to have a specific color).

I use it with Alarmo actions to blink internal and external lights if the alarm is triggered.

1 Like

How can i use this code in home assistan?

Like this:

1 Like

Maybe you can replace:

snapshot_entities with: {{ (states.light|selectattr('state','eq','on')|rejectattr('attributes.hue_type', 'in', ['room', 'zone'])|map(attribute='entity_id')|list+['light.dummy'])|join(',') }}

This should only take a snapshot from lights which are on and don’t touch lights which are off.

Unfortunately this blueprint works only with lights which are turned on. Lights which are turned off will not flash.

I updated the blueprint, now it takes a snapshot of just the selected lights (not every light you own). Feel free to suggest any improvements!

WDYM? i use it everytime and it flashes my lights even when they are turned off :face_with_raised_eyebrow:

I get an error when I try to import this blueprint. I’ve tried others and they seem to work. Is this a legitimate error or am I doing something wrong?

Unfortunately not, I also get an error message …
image