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?
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 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.
I found out that my panel doesn’t really support night mode 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