Alexa arming my alarm system in Stay or Night mode based on presence?

Hi (again x2),

Going deeper in my home automation (it really is a rabbit hole!), I already have Alexa arm my alarm panel in Stay mode through a HA script (and a Home Assistance Cloud account) but now I want to go a step further. Based on the presence of someone, I want to arm the panel in Night mode (person home) or in Stay mode (that person is not home). According to the script doc, conditions stop the execution of the script if the conditions fails. In my case, I want more like a if then else type of scenario. Is there a way to implement that?

Thanks,
Sylvain

Night mode based on time of day right ?
Trigger time
Condition
Person home

Away mode
Trigger
Persons not home
Condition
No movement >
Time since not home > 5 mins

You will need to use a value_template to render true if you using multiple persons

No, night mode if the person is present (motion detection is in her room in the basement so it’s ignored in Night arm). If she’s not home, then arm is Stay mode which will monitor that motion detector.

I though of using something like this but not sure how to set it up in Home Assistant if at all possible:

Script launched by Alexa:
var night=0
timer start 10 seconds (or some other number that will kick in after this script has run its course)
condition person home?
yes arm in night mode
night=1
end of script

When the timer end:
condition night==0?
yes arm in stay mode
end of timer script

That’s the best I could think of doing it and it’s a bit (ok, lot) convoluted…

I didn’t have a motion trigger or condition on the night mode algorithm.

Away/Stay
So I’m sleeping still in bed heavy night partying and the timer ends in the morning and now it’s armed and as soon as I go and take a leak cause im busting it will go off. Hangover and ringing I’m my ears.

You don’t need Alexa to do this at all. I have an ADT Alarm Panel and I leverage Life360 presence detectors to arm my system. You probably don’t want to arm/disarm based on motion sensors, because just sitting quietly (or sleeping as you point out) will then trigger the alarm to arm. It’s much better to leverage presence detection.

If you wanted to also have it arm while you’re home, automatically, then you’d just do that if all people are home AND it’s after a certain time AND before a certain time (and automatically disarm at the latter).

Here’s what my arm away automation looks like:

- alias: Arm Alarm when Away
  trigger:
  - entity_id: group.rob_and_deb
    from: home
    platform: state
    to: not_home
  action:
  - service: alarm_control_panel.alarm_arm_away
    entity_id: all
  - service: light.turn_off
    entity_id: group.interior_lights
  - service: notify.pushover
    data:
      message: ADT Alarm Active

I leverage a group with all of my “people” in it. So, it will only arm when my wife and I are both out of the home.

I also have an automation to disarm…

I don’t arm the system until I either do it on the control panel (mostly never) or I say ‘Alexa good night’ which does a bunch of things, including arm the system. Now, I don’t want to arm in Stay mode if my daughter is downstairs and I want the presence detector to figure that out.

My kids are growing up and don’t always sleep at home so doing an automation like you said if everyone is at home won’t work here. I like the way I want to set it up and basically need help to set it up that way, thanks.

Ended up with this. Couldn’t fully try it because it’s pass 1am and everyone else is :sleeping:

'1577771604633':
  alias: StayArm
  sequence:
  - data:
      message: Alarm panel in STAY mode
    service: notify.mobile_app_pixel_3_xl
  - entity_id: alarm_control_panel.alarme_de_la_maison
    service: alarm_control_panel.alarm_arm_home
  - condition: state
    entity_id: person.catherine
    state: not_home
  - data:
      message: with basement ARMED
    service: notify.mobile_app_pixel_3_xl
  - delay: 00:01:03
  - data:
      keypress: '*1'
    entity_id: alarm_control_panel.alarme_de_la_maison
    service: envisalink.alarm_keypress

I found out that my panel doesn’t really support night mode :rage: so I’m doing a zone rearming (after the panel has armed itself) if the basement is unoccupied and as a fail check, only rearm the zone if there is currently no movement. The notify is just for debug purposes until I have time to fully test it.

This is the code I had until I realized I had a much simpler way of doing it since I didn’t need an ‘if then else’ scenario… Wasted too much time on a code I didn’t need. Well, I’ve learned how to do if then else in scripts anyway so not a total lost :slight_smile:

'1577771604633':
  alias: StayArm
  sequence:
  - service: script.turn_on
    data_template:
      entity_id: >
        {% if is_state('person.catherine', 'home') %}
          script.1578021444101
        {% else %}
          script.1578023063726
        {% endif %}
'1578021444101':
  alias: StayArm with basement bypassed
  sequence:
  - data:
      message: StayArm with basement bypassed
    service: notify.mobile_app_pixel_3_xl
  - data: {}
    entity_id: alarm_control_panel.alarme_de_la_maison
    service: alarm_control_panel.alarm_arm_home
'1578023063726':
  alias: StayArm with basement armed
  sequence:
  - data:
      message: StayArm with basement armed
    service: notify.mobile_app_pixel_3_xl
  - data: {}
    entity_id: alarm_control_panel.alarme_de_la_maison
    service: alarm_control_panel.alarm_arm_home
  - delay: 00:01:03
  - condition: state
    entity_id: binary_sensor.mouvement_cave
    state: 'Off'
  - data:
      keypress: '*1'
    entity_id: alarm_control_panel.alarme_de_la_maison
    service: envisalink.alarm_keypress

Bed time for me too, 6am comes fast enough…

Looks great, hope it works out!