You appear to have copied the flaw the original had to this one. If a HA registered light anywhere in the house changes state while this is flashing, the change will be cancelled when the flashing stops because you are collecting the state of all the lights in the house in the initial scene to restore.
I suggest using an entity selector and control the lights as an entity list, then also only collecting the light state of the lights in the selector before doing the flash.
I use this in an automation, perhaps that will help you adjust your blueprint should you find it necessary.
####################################################
# Smoke Detector #
####################################################
- id: fb27c45c-c4fb-4c5e-962c-99c19c55ff26
alias: Smoke
initial_state: on
trigger:
- platform: state
entity_id: binary_sensor.basement_smoke_alarm
to: 'on'
id: basement
- platform: device
type: smoke
device_id: e6cb7bd304816dc875959768023d2c1b
entity_id: binary_sensor.stairway_smoke_smoke
domain: binary_sensor
id: upstairs
variables:
# Generate a random scene ID
scene_id: "color_flip_{{ this.context.id | lower }}"
action:
- alias: make some noise on the speakers
service: script.media_player_fire_alert
- delay: 00:00:03
- service: scene.create
data:
scene_id: "{{ scene_id }}"
snapshot_entities:
- light.grp_kitch
- light.grp_jens_color
- repeat:
count: 2
sequence:
- repeat:
count: 3
sequence:
- service: script.color_flip
data:
color: [255,255,255]
bright_pct: 80
entities: light.grp_kitch,light.grp_jens_color
- delay: 00:00:01
- service: script.color_flip
data:
color: [255,0,0]
bright_pct: 100
entities: light.grp_kitch,light.grp_jens_color
- delay: 00:00:03
- alias: Voice alert to say where the problem is
service: script.turn_on
target:
entity_id: >
{% if trigger.id == 'basement' %}
script.tts_smoke_detected_in_the_basement
{% else %}
script.tts_smoke_detected_upstairs
{% endif %}
- service: scene.turn_on
target:
entity_id: "scene.{{ scene_id }}"
data:
transition: 2.5
And the color flip script called…
color_flip:
alias: Flip a light to a color
fields:
entities:
name: Light to flip
description: make a light flip color
required: true
selector:
entity:
multiple: true
filter:
domain: light
color:
name: RGB color
description: Set the light color to flip to
example: "[255,0,0]"
default: [255,0,0]
selector:
color_rgb:
bright_pct:
name: Brightness Percentage
description: Set 0 to 100 brightness percentage
example: "100"
default: 100
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: slider
step: 1
sequence:
- service: light.turn_on
data:
transition: 0
entity_id: "{{ entities }}"
rgb_color: "{{ color }}"
brightness_pct: "{{ bright_pct }}"
If you make a scene in the ui, it does hang around. If you create them with the service on the fly, they are named in a temp folder and are cleared each restart of HA. So the name is really only available for a short time.
Also be aware that the id only accepts lowercase letters.
Yes, I have the problem that the selected lights (2) are blinking, but then all (10) lights in the apartment are on, there seems to be a problem with resetting to the previous state because the script collects the state of all lights.
So I was fed up with blueprints, so I recreated it with script and automation, and hopefully fixed all things.
Script:
alias: "[WIP] flash lights"
fields:
target_lights:
name: Lights
description: Lights to flash
selector:
entity:
multiple: true
domain: light
required: true
repetitions:
name: Number of times to flash
description: How many times to flash the lights
default: 5
selector:
number:
min: 0
max: 100
mode: box
unit_of_measurement: times
step: 1
color_temp:
name: Color temperature
description: Choose the color temperature for blinking lights
default: 400
selector:
color_temp:
min_mireds: 153
max_mireds: 500
brightness_pct:
name: Brightness
description: Color Brightness percentage
default: 80
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
step: 1
mode: slider
delay:
name: Delay Duration
description: Delay duration in seconds
default: 0.5
selector:
number:
min: 0.1
max: 10
unit_of_measurement: seconds
step: 1
mode: slider
variables:
scene_id: color_flip_{{ this.context.id | lower }}
expanded_lights: >-
{%- set data = namespace(entities=[]) %} {%- for light in target_lights %}
{%- if state_attr(light, 'entity_id') == none %} {%- set data.entities =
data.entities + [light] %} {%- else %} {%- set data.entities =
data.entities + [state_attr(light, 'entity_id') | list | join(',')] %} {%-
endif %} {%- endfor %} {{- data.entities | list | join(',') }}
sequence:
- service: scene.create
metadata: {}
data:
scene_id: "{{ scene_id }}"
snapshot_entities: "{{ expanded_lights }}"
- service: light.turn_on
data_template:
entity_id: "{{ target_lights }}"
color_temp: "{{ color_temp }}"
brightness_pct: "{{ brightness_pct }}"
- repeat:
count: "{{ repetitions * 2 }}"
sequence:
- service: light.toggle
metadata: {}
data: {}
data_template:
entity_id: "{{ target_lights }}"
- delay: "{{ delay }}"
enabled: true
- service: scene.turn_on
metadata: {}
data:
entity_id: scene.{{ scene_id }}
enabled: true
- service: scene.delete
metadata: {}
data: {}
enabled: true
target:
entity_id: scene.{{ scene_id }}
mode: parallel
Automation for night notification (at set times flash lights)
alias: Night notification
description: Time to go to bed notifications
trigger:
- platform: time
at: "19:45:00"
- platform: time
at: "20:45:00"
- platform: time
at: "21:00:00"
condition: []
action:
- parallel:
- service: script.1708772336118
metadata: {}
data:
repetitions: 5
color_temp: 400
brightness_pct: 80
delay: 0.5
target_lights:
- light.wifi_lights_no_kids_room
- service: script.1708772336118
metadata: {}
data:
repetitions: 5
color_temp: 400
brightness_pct: 80
delay: 0.5
target_lights:
- light.ikea_zigbee_light
mode: single
I noticed that all automation when running on mixed lights (some I have from Ikea on ZigBee some from Xiaomi on WiFi) will have problems, so that is why I created 2 groups of the same lights light.ikea_zigbee_light and light.wifi_lights_no_kids_room and running script on those in parallel, which looks like working for now.
When I will have some more spare time I might port it back to blueprints, but for now I am happy that it is at least working