[Time trigger manual alarm] Notification once during automation

Hello,

I would like to create an automation for the manual alarm. However, the notification is indefinitely sent.
The goal is to activate the alarm_night at 23:00:00, check if i’m present and send me (once) a notification that says it’s armed.

Here is the configuration that i’ve done, i’ve certainly some lack of knowledge related to the trigger and condition :

- id: 'alarm armed night'
  alias: Alarm Armed Night
  trigger:
  - platform: state
    entity_id: device_tracker.iphone
    to: 'home'
  - platform: time
    at: '23:00:00'
  action:
    - service: automation.turn_on
      entity_id: automation.front_door_open
    - service: alarm_control_panel.alarm_arm_night
      entity_id: alarm_control_panel.ha_alarm
    - service: notify.iphone
      data: 
        title: "[NIGHT ALARM] Alarm is armed - {{states.alarm_control_panel.ha_alarm.state}}"
        message: "Night Alarm is armed - {{states.alarm_control_panel.ha_alarm.state}}"

Thank for your help.

the trigger works as a … trigger for the automation.
From your post you don’t want to trigger the automation when you come home, you want the automation to run at 23:00 on the condition that you’re home (that’s the hint)
Also you want to send a notification using a template, you should therefore use data_template, not just data
Last, you should try and use states("domain.entity") instead of states.domain.entity.state If your entity is not available, you’ll end up with an error in your logs. The former will handle the entity state being unavailable.
Last but not least automation.turn_on will activate the automation, but will not trigger it. Just wanted to make sure you understood this
Therefore try the below. It’s not tested but I think it should work:

- id: 'alarm armed night'
  alias: Alarm Armed Night
  trigger:
    - platform: time
      at: '23:00:00'
  condition:
    - condition: state
      entity_id: device_tracker.iphone
      state: 'home'
  action:
    - service: automation.turn_on
      entity_id: automation.front_door_open
    - service: alarm_control_panel.alarm_arm_night
      entity_id: alarm_control_panel.ha_alarm
    - service: notify.iphone
      data_template: 
        title: "[NIGHT ALARM] Alarm is armed - {{states('alarm_control_panel.ha_alarm')}}"
        message: "Night Alarm is armed - {{states('alarm_control_panel.ha_alarm')}}"

Hello,

Thank you for your reply, it’s easier to understand now.
I was on a wrong way.

However, i’m checking for something else related to the presence detection because the bluetooth is not stable.
Have you got a suggestion ?

Axel