Alarm / not_home / still disarmed

Hi All. Im trying to make a alert that triggers in these set conditions.

- alias: 'Alarm is not activated'
  trigger:
    - platform: state
      entity_id: group.familydevices
      from: home
      to: not_home
      for:
        minutes: 5
  condition:
    condition: state
    entity_id: alarm_control_panel.alarm
    state: disarmed
  action:
    - service: notify.notify
      data: 
        message: 'Alarm not aktivated'

Included this cause this is what i have for one alert right now. But it like it to continue alerting us over and over.
I read the alert component but did not realy get it. seems like i had to create a input_boolean but then i tried to understnad how i would get that to trigger os the same things as my automasation and by then i was lost.

Allso tried to google and search here on the forum to try finding someone thats done the same. Might be im searching the wrong things. Anyone that can guide me on the right path?

This might be what you’re looking for.

Yeh as i said in the post i have read the Alert component help. But cant realy make out how to combine it with what i have and etc. read that 8 times now and still cant figure it out. I cant make mutch sens out of it. and i have full out automasation going for my light and notifications for allot of stuff. Im just realy trying to figure out how to repeat the automasation. Kinda.

think ive figured it out.

Automasation:

- alias: 'Alarm is not activated'
  trigger:
    - platform: state
      entity_id: group.familydevices
      from: home
      to: not_home
      for:
        minutes: 5
  condition:
    condition: state
    entity_id: alarm_control_panel.alarm
    state: disarmed
  action:
    - service: notify.notify
      data: 
        message: 'Alarm not aktivated'
    - service: input_select.select_option
      data_template:
        entity_id: input_select.alarm_status_dropdown
        option: Gone

- alias: 'alert off on alarm'
  trigger:
    - platform: state
      entity_id: group.familydevices
      to: home
    - platform: state
      entity_id: alarm_control_panel.alarm
      to: armed_away
  action:
    - service: input_select.select_option
      data_template:
        entity_id: input_select.alarm_status_dropdown
        option: Home

Config:

alert:
  alarmnoton:
    name: Warning! Alarm not armed!
    entity_id: input_select.alarm_status_dropdown
    state: 'Gone'
    repeat:
      - 5
      - 10
      - 15
      - 30
    notifiers:
     - notify.phone1
     - notify.phone2

input_select:

alarm_status_dropdown:
  name: Alarm status
  options:
    - Home
    - Gone
  initial: Home

Sorry, I missed that part that you had tried the Alert component. I had never used it so I set it up tonight to play with it.

Glad you got it working.

My approach would be to create a template binary sensor that is ‘on’ when no one is at home for at least 5 minutes AND the alarm is still disarmed. And then create an alert for that sensor. This would no longer require any automation.

binary_sensor:
  - platform: template
    sensors:
      forgot_alarm_when_leaving:
        friendly_name: 'Forgot Alarm When Leaving'
        value_template: >
          {{ is_state('group.familydevices', 'not_home') and
             is_state('alarm_control_panel.alarm', 'disarmed') }}
        delay_on:
          minutes: 5

alert:
  forgot_alarm_when_leaving:
    name: 'Alarm not aktivated'
    done_message: 'Alarm aktivated'
    entity_id: binary_sensor.forgot_alarm_when_leaving
    state: 'on'
    repeat: 
      - 5
    notifiers:
      - notify

or: skip the delay_one in the sensor AND use skip_first in the alert

2 Likes

Seems like a solid Idee, Less code. But i keep getting

Configuration invalid
Invalid config for [binary_sensor.template]: invalid template (TemplateSyntaxError: unexpected '}', expected ')') for dictionary value @ data['sensors']['forgot_alarm_when_leaving']['value_template']. Got "{{ is_state('group.familydevices', 'not_home' and\n   is_state('alarm_control_panel.alarm', 'disarmed') }}\n". (See ?, line ?). Please check the docs at https://home-assistant.io/components/binary_sensor.template/

Seems to have done it. If im not thingking wrong

binary_sensor:
  - platform: template
    sensors:
      forgot_alarm_when_leaving:
        friendly_name: 'Forgot Alarm When Leaving'
        value_template: >
          {{ is_state('group.familydevices', 'not_home' and
             is_state('alarm_control_panel.alarm', 'disarmed')) }}
        delay_on:
          minutes: 5

Testing now to see if it works.

My first is_state was missing a closing bracket ‘)’. I have updated my post to correct this.

1 Like

Oh ok. Ty for the reply and help of the code! Ill update it and see how the testing goes.

Pretty cool. I’m going to use this as well. If you have iOS, you can make it an actionable alert (not sure about andoid), where you could just enable the alarm right then.

Not tested, but something like this

configuration.yaml
ios:
  push:
    categories:
      - name: Activate Alarm
        identifier: 'activate_alarm'
        actions:
          - identifier: 'ACTIVATE'
            title: 'Activate'
            activationMode: 'background'
            authenticationRequired: no
            destructive: yes
            behavior: 'default'
          - identifier: 'IGNORE'
            title: 'Ignore'
            activationMode: 'background'
            authenticationRequired: no
            destructive: yes
			
Automation
- alias: Alarm off but no one is home
  trigger:
  - platform: state
    entity_id: binary_sensor.forgot_alarm_when_leaving
    to: 'on'
  action:
  - service: notify.ios_whoever
    data:
      message: "Looks like you're gone but the alarm is still off"
	  title: "Alarm not armed"
      data:
        push:
          category: "activate_alarm"

- alias: Activate Alarm
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: ACTIVATE
  action:
  - service: not sure what goes here for alarm_control_panel
    entity_id: alarm_control_panel.alarm
1 Like

No message is sent to the phone. ive checked the group and alarm pannel and the criteria is meet.
Something must not be right, as it should be for the code. tripple checked the alarm panel and group and thats correct. and there state is correct.

Ive allso tried lowering and removing any delay to see if it triggers and spams me. But still nothing.
Its like the alarm dont understand that the sensor is on. or that the whole funktion if off.

Found the problem. the problem was that you cant have
notifiers:
- notify.notify
correct is:
notifiers:
- notify
And it makes sens sins its asking what to notify. not what funktion to use.
My final codes was as followed

binary_sensor:
  - platform: template
    sensors:
      forgot_alarm_when_leaving:
        friendly_name: 'Forgot Alarm When Leaving'
        value_template: >-
          {{ is_state('group.familydevices', 'not_home') 
             and is_state('alarm_control_panel.alarm', 'disarmed') }}
        delay_on:
          minutes: 5

alert:
  forgot_alarm_when_leaving:
    name: 'Alarm not aktivated'
    done_message: 'Alarm aktivated'
    entity_id: binary_sensor.forgot_alarm_when_leaving
    state: 'on'
    repeat: 
      - 5
    notifiers:
      - notify

thx for the help metbril.

1 Like

Thanks. I have updated my example above.

Ive notice one problem with this setup that i kinda find wierd.

With this setup. For example when im sleeping. We werry often get the warning that we left home and alarm is off. Sins were home sleeping and have not left the zone i dont get why it does that. and its 10 min untill it hits.

If you use a device tracker like NMAP, device will appear to be offline if they loose network access. Phones will disconnect from Wifi from time to time. This will render your device tracker as ‘not_home’. This will in turn enable the alarm. I think.

Pretty much. This is why it’s a good practice to use a group of device trackers for something like a user. You kind of need the redundancy more than say with something like a tv.

Yeh whats instresting is that im not using that. Featching that info from my router. But i allso enabled gps tracking so i hope that solves it.

that is similar to nmap

try setting up a few different ones, ping, wifi, gps, whatever and then creating a single group out of those entities. ie dad-ping, dad-nmap, dad-phone and then creating the group group.dad-trackers that has those 3 in it. That way if 2 out of the 3 are home it still says home. If 1 out of the 3 drops off it still says home. All three would need to be not_home to be considered not_home.