New to HA, need help with alarm triggers

Hi all. New to HA and having a few small issues regarding coding, im not able to add another phone to notify when the alarm first goes into pending without getting errors, any help greatly appreciated, thanks.

#konnected alarm
- alias: "Alarm - Trigger when sensors go off"
  trigger:
    - platform: state
      entity_id: binary_sensor.tamper
      to: 'on'
    - platform: state
      entity_id: binary_sensor.hallway
      to: 'on'
    - platform: state
      entity_id: binary_sensor.bar_garage
      to: 'on'
    - platform: state
      entity_id: binary_sensor.kitchen
      to: 'on'
    - platform: state
      entity_id: binary_sensor.lounge
      to: 'on'
    # Add more triggers here for other doors/windows
  condition:
    # Only trigger the alarm if it's armed
    condition: or
    conditions:
      - condition: state
        entity_id: alarm_control_panel.alarm
        state: armed_home
      - condition: state
        entity_id: alarm_control_panel.alarm
        state: armed_away
  action:
    service: alarm_control_panel.alarm_trigger
    entity_id: alarm_control_panel.alarm

- alias: "Alarm - Triggered"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      to: "triggered"
  action:
    - service: homeassistant.turn_on
      entity_id: switch.siren

- alias: "Alarm - Pending"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      from: "armed_away" # No need for armed_home, there's no pending delay there.
      to: "pending"
  action:
    - delay: 00:00:05 # Small delay for "Announce" automation to run.
    - service: notify.mobile_app_Steveiphone
      data:
        message: ALARM TRIGGERED! PLEASE DISARM!
    - service: notify.alexa_media
      data:
        target:
          - media_player.steven_s_echo_dot
        data:
          type: announce
        message: "Please disarm the alarm"
    # Start a timer to repeat the warning
    - service: timer.start
      entity_id: timer.alarm_pending

- alias: "Alarm - Pending Repeat"
  trigger:
    - platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.alarm_pending
  condition:
    condition: state
    entity_id: alarm_control_panel.alarm
    state: pending
  action:
    - service: notify.alexa_media
      data:
        target:
         - media_player.steven_s_echo_dot
        data:
          type: announce
        message: "Disarm the alarm now or i will fucking deafen you!"
        
        
        
    # Restart the timer
    - service: timer.start
      entity_id: timer.alarm_pending

- alias: "Alarm - Disarmed"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      to: "disarmed"
  action:
    # Turn off the siren once the alarm is disarmed
    - service: homeassistant.turn_off
      entity_id: switch.siren
    # Stop the warning repeat timer
    - service: timer.cancel
      entity_id: timer.alarm_pending

Blockquote

Also any help regarding making an Tuya led strip scene for when the alarm goes into pending state and switching off after 30 seconds would also be greatly appreciated.

thanks in advance!

Dont think you should have a capital “S” here ?

Nah that part is fine as my phone is named with a capital S on HA, as i say that coding all works ok but when i try to duplicate

    - service: notify.mobile_app_Steveiphone
      data:
        message: ALARM TRIGGERED! PLEASE DISARM!

to look like

    - service: notify.mobile_app_Steveiphone
      data:
        message: ALARM TRIGGERED! PLEASE DISARM!
    - service: notify.mobile_app_Sophieiphone
      data:
        message: ALARM TRIGGERED! PLEASE DISARM!

i get errors.

Ah OK, sorry.

What error are you getting?
Do the two notify.mobile_app_xxxxx notifications BOTH work on there own?
(if you replace Steveiphone with only Sophieiphone) does it still work?

Also have you considered simply making a group notify for the two of you?

yeah changing the name works just cant make them work with that code, sorry im new what is group notify :rofl:

No problem, take a look here:

For alarm related notifications I have for example, the following in config.yaml:

notify:
  - platform: group
    name: alarm_notify_group
    services:
      - service: mobile_app_mary_iphone
      - service: mobile_app_john_iphone

Then in an automation and or script action I would have something like this:

- service: notify.alarm_notify_group
  data:
    title: 'Title of message.....'
    message: 'Message.......'

Also just in case, it may be worth putting single qoutes around your ‘message’ particularly when using any special characters.

Otherwise can you post up what errors you are getting, as this may help fault find?

Thanks, thats pretty neat however this method is also now fetching errors :confused:

my code now looks like

- alias: "Alarm - Pending"
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarm
      from: "armed_away" # No need for armed_home, there's no pending delay there.
      to: "pending"
  action:
    - delay: 00:00:05 # Small delay for "Announce" automation to run.
    - service: notify.alarm_notify_group
  data:
    title: 'Alarm Triggered!'
    message: 'Please Disarm!'
    - service: notify.alexa_media
      data:
        target:
          - media_player.steven_s_echo_dot
        data:
          type: announce
        message: "Please disarm the alarm"
    # Start a timer to repeat the warning
    - service: timer.start
      entity_id: timer.alarm_pending

- alias: "Alarm - Pending Repeat"

and the error ive got

bad indentation of a mapping entry at line 55, column 5:
- service: notify.alexa_media
^

Indentation is wrong.

    - service: notify.alarm_notify_group
  data:
    title: 'Alarm Triggered!'
    message: 'Please Disarm!'

It should be like the following:

    - service: notify.alarm_notify_group
      data:
        title: 'Alarm Triggered!'
        message: 'Please Disarm!'

Edit: if you are ever in doubt, then a useful tip is to go to Developer Tools, Services and fill out the service and data in question in the Ui and then click on “GO TO YAML MODE” to see the underlying yaml formatting and spacing etc

perfect that works, thank you! still not sure what is different between those two other than that the “data:” field is slightly forwards lol

Have you any idea about me using my alarm to trigger a Tuya led strip with a red/blue flashing scene for like 30 seconds ? never quite expected to find all this so hard since i used to do java coding years ago haha

That is exactly what is wrong and looking back at your original post you will note the same issue with indentation.

In yaml indentation has to be 100% correct or it simply won’t compute.

Glad you got it sorted.

I don’t use tuya and or led strips so probably not the best person to ask. Use developer tools, services and start from there.