Flash lights

Is there any possibility to access the included function that flash red lights when alarm is triggered? I would like to use such a function to flash (ON/OFF) some relays that action lights when a dedicated alarm switch is ON and a PIR is triggered, because I do not have smart LED bulbs (yet). This function may be used also in other situation, for example in case of water leak or gas detected to flash light in that area. Thank you

Hi Mihai,

You could try the script component to script this out. It might be a lengthy script with multiple on, delay, off, delay steps but should work.

FYI, the Philips Hue has a “flash” effect you can use out of the box. You can specify either a “short” (1 flash) or “long” (15 flashes/30 seconds) sequence. Very easy to use in HA.

-wade

Thank you for directions, I was also thinking about script in config file, but is far from optimization, you can imagine for one minute of flash duration 1 or 2 sec ON then OFF, several lights. It could be feasible if HA allow loop in the config file, here I have no info. I do not own a Philips smart bulb and I do not plan yet to change few bulbs in my house. Is it possible to link the Philips Hue component to the MQTT switch?
Other idea that I have is a code in Arduino board, I can manage it, but I prefer to move most of the “logic” from the nodes to the server, because of better control and possibilities.

I think you can try make two script with loop to another. Like this: Automation rule triggered -> Script 1: light on -> light off -> call Script 2, Script 2: light on -> light off -> call Script 1. Then when your alarm goes off another automation rule shut down both scripts. Maybe it is easier make with Hue but this way it is much cheaper if you already control some way those lights. If my suggestion works :wink:

Thank you for this ideea.

I make the following code for flashing light:

[code]switch:

  • platform: mqtt
    name: “Sw1”
    command_topic: “home/bedroom/switch1/set”
  • platform: mqtt
    name: “Sw2”
    command_topic: “home/bedroom/switch2/set”

automation:

  • alias: ‘flash_start’
    trigger:
    platform: state
    entity_id: switch.sw1
    state: ‘on’
    action:
    service: script.turn_on
    entity_id: script.flash_on

  • alias: ‘flash_stop’
    trigger:
    platform: state
    entity_id: switch.sw2
    state: ‘off’
    condition:
    platform: state
    entity_id: switch.sw1
    state: ‘off’
    action:
    service: script.turn_off
    entity_id: script.flash_on

script:
flash_on:
alias: Flash On
sequence:
- alias: swon
service: homeassistant.turn_on
data:
entity_id: switch.sw2
- delay:
seconds: 1
- alias: swoff
service: homeassistant.turn_off
data:
entity_id: switch.sw2
- delay:
seconds: 1
- alias: loop
service: script.turn_on
data:
entity_id: script.flash_on[/code]
So I was using somehow booth ideas from Zebble and Kurmu, thank you!
Now I am working to integrate with the PIR sensors and some relays.

1 Like

Hi Mihai,

I am actually using your idea with some alarm clock. Though I haven’t tried it in my configuration yet but looking at the configuration, one thing popped in my mind. How, this loop will stop ?

Hi,
Please take a look here: https://home-assistant.io/cookbook/automation_flashing_lights/ , it is more detailed. Actually, I use another timer for the buzzer (not presented here). Each time the light is off, I check if the sound is active or not; if it is active - do nothimg, just let the flash loop active, when the sound is off then command turn off the flashing script.
However, as detailed here: Looping scripts the latest version of HA forbid calling procedure from itself, so I have modified the script by splitting it in two parts, one call the other one, call stop for booth. If you use an older version of HA (e.g. 0.19) it works as presented.
Detailed description of my project is here: https://forum.mysensors.org/topic/3478/home-automation , detailed code is here: https://github.com/Mihai258/MySensors2-HomeAssistant-MQTT

Thanks a lot man! I have seen all the links you had provided. However, still I cant figure out how to stop them.

What I understood so far, Script 1 should turn_on a service then after a delay it should call another script (script 2) which then turn_off a service and after a delay should call script 1. This part is okay to me.

But if these are the sequence then how the turn_off section works for both script ? I followed your project in Github but that is too much for my current level of understanding home assistant and MQTT :scream:

Thanks & Regards
Tarikul

Sw1 is a switch connected to the buzzer. It has it own timer (not shown here, but you will find on the whole yaml file).
Sw2 is connected to the light. The light goes ON-OFF-ON etc when script.flash_on is active.
To stop it, the automation flash_stop is activated each time the light goes OFF (trigger). It check if the buzzer is still active (condition); if is inactive (off), then this automation just stop the flashing script.
You are free to use any other procedure you can imagine, may be yours will be more interesting one and we will appreciate if you will share with us.

Hi Mihai, my looping script working now. I did the simplest logic, script1>script2>scrpit1… And an input boolean to turn both off… May be this is the thing you tried to make me understand in the first place.
However, I was thinking like a programming logic, if I don’t mention a condition inside the loop, how I am going to control the loop. But from YAML, this is apparently not true, Hass can call any procedure any moment and shut it down:-) simple…

Hi Wade, do you have an example automation making use of the ‘flash’ sequence on Hue? Thanks!

I have an automation letting hue lights flashing .I can paste my config if u need

Figured it out now, but thanks for the offer :grin:

Apologies for resurrecting this old thread, but I am looking for an automation to flash my hue bulbs red and afterwards restoring the light to the previous state. Could you post your config as I think it might help me?

Hi!

Let’s try this:

automation:
- id: one
  alias: Turn on light when motion is detected
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_1
      to: 'on'
  action:
    - service: light.turn_on
      data:
        entity_id: light.living_room
        brightness: 255
        rgb_color: [255, 0, 0]
        flash: long
3 Likes

Feel ashamed it was so simple… Thanks for posting!

you know the thing with the trees and the forrest ? :slight_smile:

that happens to us all. Glad to hear it helped you.

2 Likes

hi, is this working for you?

In my case it is working only when the light was off (ignoring the rgb color), but when the light is on it stays on with the flashing color without going back to its previous state :frowning:

(I’m using Hue lights)

In case someone comes to this thread like myself and has lights that do not have a ‘flash’ option I found a Blueprint that may work for some: Simple ... flashing light's via on off and delay. Restore previous light states

1 Like