Issue with an example cookbook

I’m trying to implement the cookbook outlined here

# AlmAct1 - switch to activate the alarm in Room1
# AlmSnd1 - switch for a buzzer

automation:
- alias: 'Alarm_PIR_Room1'
  trigger:
    platform: state
    entity_id: binary_sensor.PIR1
    to: 'on'
  condition:
    - condition: state
      entity_id: switch.AlmAct1
      state: 'on'
    - condition: state
      entity_id: script.alarm_room1
      state: 'off'
  action:
    # start alarm on movement if alarm activated
    # and the alarm is not triggered
    service: script.turn_on
    entity_id: script.alarm_room1

- alias: 'flash_room1_start'
  trigger:
    platform: state
    entity_id: switch.AlmSnd1
    to: 'on'
  action:
    service: script.turn_on
    entity_id: script.flash_room1

- alias: 'flash_room1_stop'
  trigger:
    platform: state
    entity_id: switch.REL1
    to: 'off'
  condition:
    condition: state
    entity_id: switch.AlmSnd1
    state: 'off'
  action:
    service: script.turn_off
    entity_id: script.flash_room1

script:
  alarm_room1:
    alias: Alarm room1
    sequence:
      - alias: Alarm Room1 Start
        service: homeassistant.turn_on
        data:
          entity_id: switch.AlmSnd1
      - alias: Set Ack Room1
        service: homeassistant.turn_on
        data:
          entity_id: input_boolean.ack1
      - alias: email_Room1
        service: notify.email
        data:
          message: 'Movement alarm in Room1'
      - delay:
          # time interval for alarm sound and light flashing
          seconds: 60
      - alias: Alarm Room1 Stop
        service: homeassistant.turn_off
        data:
          entity_id: switch.AlmSnd1

  flash_room1:
    alias: Flash Room1 On
    sequence:
      - alias: Light Room1 On
        service: homeassistant.turn_on
        data:
          entity_id: switch.REL1
      - delay:
          # time for flash light on
          seconds: 1
      - alias: Light Room1 Off
        service: homeassistant.turn_off
        data:
          entity_id: switch.REL1
      - alias: loop_room1
        service: script.turn_on
        data:
          entity_id: script.flash_loop

  flash_loop:
    alias: Flash loop
    sequence:
      - delay:
          # time for flash light off
          seconds: 1
      - alias: loop_room1
        service: script.turn_on
        data:
          entity_id: script.flash_room1

The issue i’m having is I don’t actually see a line where I add the lights to blink? My home is light.home and i’m not exactly sure where to put that. I tried to replace switch.REL1 with light.home which worked but the issue is every time i turned off the lights it would trigger the blinking :grimacing:. I’ve been testing by just going to the automation section and manually triggering the automations listed above.

I’m almost positive i have to add something to flash_room1 but not exactly where or what.

Still pretty new to home assistant and guidance would be super helpful!

instead of just implementing a cookbook example that you don’t have all of the existing hardware for the better thing to do would be to figure out what you want to have happen to your existing lights when your existing sensor/switches do something. Then use your own entities to do that and just use the cookbook as an example.

Start simple…

what exactly are you trying to accomplish? What entity_id’s do you have?

I couldn’t get the loop to work ever so i ended up with a big ole copy pasta

flash_home_20:
  alias: Flash Apartment (20 times)
  sequence:
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: script.flash_room1
  - wait_template: '{{ is_state(''script.flash_room1'', ''off'') }}'
  - service: light.turn_on

:man_shrugging: works but it’s not pretty

Sorry, why not have an input number
An automation runs, sets number to 20, calls a script (checks number > 0) to flash (decrements the number by 1 and then calls another script)
The other script then calls the flash script again.

Mostly because I have no idea how to do that :slight_smile: haha.

If you have an example that would be helpful so i can clean this up a bit.

I just had a look at the example you listed and basically that’s what it does.
When you try to implement this, what issues are you having ?
What level are you at ?
I see you joined 2 days ago and have read 42 minutes
Are you using a stand alone editor or the built in ones ?
Is your configuration monolithic, split to scripts and automations or to indivual files or even packages ?
Do you want someone to write this for you or help you to do it yourself ?