I installed it and noticed that it only works with entity types : light. I adapted this to show also type: switch but it did not work (although the entities -> switch can be selected). Any clue what more we need to adapt to the script? Thanks in advance!
Many thanks for it! it’s very useful for me since I’m deaf and I use this to trigger light when the doorbell is pressed.
If I understand the flashing count is based on how long the status is “on” + delay?
However is there a possibility to configure counts of flashing because I would love to determine source/trigger based on count of flashing.
For example:
Doorbell = 3 times
Fire alarm = 6 times
burglar alarm = 10 times
Markus78 I use your blueprint choosing a device to activate the flashing light. It worked but the only way to stop it was stopping the automation. Then I create an input_boolean and modified the automation including also the delay. No results. Can you please help me to understand how it works and how to fix it in order to stop after a certain time or event? Thanks
@markus78, I have one idea to work around the issue of restoring light states when some lights are off:
Save the state as scene_old.
Turn on all the lights configured in the automation.
Wait a short delay to make sure they are turned on.
Save the state as scene_on.
Continue the blinking light automation/blueprint as normal. Go nuts!
Wait a short delay before activating any scene.
Activate scene_on.
Wait another short delay before activating another scene.
Activate scene_old.
END
This should make sure the “off” state is correctly saved and restored, because the on/off state is saved first, then the light properties are saved next; and they are restored in reverse order. In theory, because I haven’t tested it myself (and I likely won’t test any time soon). So, if this solution sounds plausible, please test if it works.
My only suggestion is the “short delay” should be an input variable with a default value. The default delay should work for most people, but being a parameter lets each person to fine-tune it to their setup.
I added a RGB name and brigthness selector to the blueprint for those who would like to use it on LED RGB lights. The RGB works fine, not sure about the brightness, still have to do some tests.
blueprint:
name: flashing lights
description: 'Flashing lights via on off and delay and finally restore the previous
light states.
'
domain: automation
source_url: https://community.home-assistant.io/t/simple-flashing-lights-via-on-off-and-delay-restore-previous-light-states/258099
input:
activated:
name: Activated
description: Enter the Entity Name for Trigger (On-Off)
selector:
entity:
domain: input_boolean
target_lights:
name: Lights
description: To flashing lights
selector:
target:
entity:
domain: light
color_rgb:
name: RGBColor
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_rgb:
name: (OPTIONAL) Light Brightness
description: Color Brigthness between 0 to 255
selector:
number:
min: 0
max: 255
unit_of_measurement: RGB
step: 1.0
mode: slider
delay:
name: (OPTIONAL) Delay
description: Delay flashing lights
default: 1000
selector:
number:
min: 0.0
max: 20000.0
unit_of_measurement: milliseconds
step: 1.0
mode: slider
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input 'activated'
to: 'on'
variables:
activated: !input 'activated'
delay: !input 'delay'
target_lights: !input 'target_lights'
condition: []
action:
- service: scene.create
data:
scene_id: all_lights_snapshot
snapshot_entities: "{% set lights = states.light\n | map(attribute='entity_id')\
\ | join(',') %}\n {{lights}}\n"
- service: light.turn_on
target: !input 'target_lights'
data:
color_name: !input 'color_rgb'
brightness: !input 'brightness_rgb'
- repeat:
while:
- condition: template
value_template: '{{ activated == none or is_state(activated, ''on'') }}'
sequence:
- delay:
milliseconds: '{{ delay }}'
- service: light.toggle
target: !input 'target_lights'
- service: scene.turn_on
data:
entity_id: scene.all_lights_snapshot
You can add whatever color names you like (as long as they are CSS color names). A full list of color names can be found here (make sure they are written small caps).
You’re probably trying to call “switches” not “lights”. For switches to show up in the selector, you need to define the switches as lights first. You can do so in the configuration.yaml in a very simple manner. See code below. Just add the entity name of your switches and under name you can add whatever you want. It’s probably a good idea to add all your switches here which are in fact switches that turn on lights. Test your config and then restart your server and the entities should show up in scripts or automations aso that need lights as entity or device inputs. Hope that helps!
# Tell Home Assistant that the following switches are lights, so they appear in script and other GUIs
light:
- platform: switch
name: Enter Name Here01
entity_id: switch.sonoff_yourswitchentity01
- platform: switch
name: Enter Name Here02
entity_id: switch.sonoff_yourswitchentity02
- platform: switch
name: Enter Name Here03
entity_id: switch.sonoff_yourswitchentity03
Great Blueprint @markus78 - I can see this being used in many of my automations.
With the idea of flashing my LED strip when the doorbell rings, am I correct in my thinking such that I need an automation to set my input boolean to “on” when the doorbell is pressed, eg:
alias: Set Doorbell_Pressed = ON when the doorbell is pressed
description: ''
trigger:
- platform: device
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
domain: nest
type: doorbell_chime
condition: []
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.doorbell_pressed
- delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
- service: input_boolean.turn_off
target:
entity_id: input_boolean.doorbell_pressed
mode: single
This seems to successfully change the boolean value to ON, and keeps it on for 15 seconds before changing it back to OFF.
Then, I have another automation which is your blueprint that is triggered when my input_boolean.doorbell_pressed has changed to ON.
This seems to work well - when the doorbell is pressed, the lights flash on and off for 15 seconds, and the initial on/off state of the light is preserved, great! Can you confirm that this is the correct usage? Or did you design it in a way that could simplify my implementation?
Nice addition @avviano - I’m now able to specify that I would like my LED strip to flash specifically in RED.
Is it possible to use alternating colour into this? So for example to accommodate choosing 2 RGB colours, and respective Brightness. Then when the condition is triggered, it alternates (e.g. RED then BLUE and then continue the repeat / while block)
I’ll be honest, as a yaml noob, I thought I’d have a try but gave up after 10 minutes - is this a possible feature that can be edited?
@avviano & @markus78 - great work on this. It’s my first use of blueprints, and it looks like it could be very useful! I am intending to use this to ‘alert’ of different calls to action - ie doorbell/answer the front/back door, a meal is ready so come to eat, etc etc. Each circumstance uses lights which are already possibly in use.
I have found that if the lights are already on, and the boolean is turned off when the flashing is in the ‘off’ state, all works as it should.
However if the boolean is turned off when the flasher is in the ‘on’ state, the scene snapshot return doesn’t work, and the lights stay off - although the gui shows the light as having successfully returned to the snapshotted scene.
Also, if the lights are off but set to (eg) yellow, when a red flasher blueprint finishes, when the light is next turned on it will be red, not the previous colour.