How to keep light flashing?

Though I am a longtime user of HA and Hue I only now run into the option of flash: short and flash: long… sorry for that.

I’ve found this looking for a way to have my lights flash until acknowledged. The flash: long does flash the lights 15 time, but this obviously isn’t long enough.

I started writing a few scripts and was hoping to find some sort of attributes or state ‘flashing’ on the lights, but unfortunatly the lights show a state: off …?

so, how could one have the lights flashing until another event takes place? Other than timing the 15 flashes and have 2 scripts call each other in a sequence of just about that time, and then check for that script being ‘on’?

hope this makes sense, thanks for any suggestion

script:
  lights_flash:
    sequence:
      - service: script.turn_off
        entity_id: script.lights_flash_startup, script.lights_flash_followup
      - service: script.lights_flash_startup


  lights_flash_startup:
    sequence:
      - service: light.turn_on
        data:
          entity_id: light.dining_table
          flash: long
      - delay:
          seconds: 15
      - service: script.lights_flash_followup

  lights_flash_followup:
    sequence:
      - service: light.turn_on
        data:
          entity_id: light.dining_table
          flash: long
      - delay:
          seconds: 15
      - service: script.lights_flash_startup

would be a viable option maybe?

1 Like

That isn’t too hard. Create a binary sensor or input binary that holds a true or false Boolean value. Than create an automation that toggles a light on or off every few seconds. Use the ‘toggle’ service and not ‘on’ or ‘off’.

Yeah, like metbril says, just insert a condition (in either or both scripts) to check for your acknowledgement bit (set at same time first script called) and required to be on for scripts to run

cool, thanks, will certainly try that, though that automation wouldn’t then use the service flash: long? Not sure yet.

Fiddled a bit with the placement of the delays, (was tangled in a loop I couldn’t stop … haha)

now below seems to work, and because I named these with _on and _off, I can easily use these scripts with template based in your boolean suggestions.

Heck, I hope I will even be able to add these to the ‘alert to service’ hack we made earlier this week based on @pnbruckners trick using

- name: notify_service
    platform: group
    services: []!

for the group notifier

lights_flash:
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.dining_table
        flash: long

lights_flash_off:
  sequence:
    service: script.turn_off
    entity_id: script.lights_flash_on, script.lights_flash_followup

lights_flash_on:
  sequence:
    - service: script.lights_flash
    - delay:
        seconds: 15
    - service: script.lights_flash_followup

lights_flash_followup:
  sequence:
    - service: script.lights_flash
    - delay:
        seconds: 15
    - service: script.lights_flash_on
1 Like

Hmmm ! I see what you did there.
Trading the input boolean for another automation.
It doesn’t require a restart to implement (yes, I have voted for Taras’s avoiding restart feature request :smile: )
Though if the boolean turning on was the trigger to call the first script and it being on is the condition that keeps them running then you could use this whereever and also in testing.
The overall number of ‘items/entities’ stays the same - so I suppose it’s down to whatever the user prefers, still, your solution is very neat :smile:

yes, thanks.
but, (there’s always a but…) my other challenge how is how to pass in a variable to the small subscript from an external trigger.

If I don’t want to hardcode the entity_id, and I don’t, I need a way to pass the variable on the lights_flash sub-script, in a way the lights_flash_on script can use that (remember I use that as main script for the on/off template later on).

But like your recent post about “minutes” cant you pass the entity id (from the trigger, as a parameter) to the script and use that in a service template, and then again in the call to the second script ?
Not used them myself but …

yes, easy :wink:

not sure, hence my But… Don’t think I’ve ever seen scripts inherit variables, so would probably have to redefine them in the first script… have to rethink this …

If a problem, just write it to an input text and just keep calling it from there.
I’m sure Petro, Taras or Phil will come up with a more elegant solution though.