I have migrated my alarm system to appdaemon. The previous solution based on 350+ lines of automation.yaml and was a pain to maintain.
This system work with any light system (should support color) and with any sensors who report on/off values. I have tested it with xiaomi hub, sensors, buttons.
You can configure these settings:
Key
Description
Default
language
language used for notifcations in text and audio
english
—
—
—
device_trackers
list of tracked devices (for auto arming / disarming)
[]
armed_home_binary_sensors
list of binary sensors to monitor (like doors, motion, sensors) in case you are home
[]
armed_away_binary_sensors
list of binary sensors to monitor (like doors, motion, sensors) in case you are away
[]
water_binary_sensors
list of binary sensors to monitor (like water leakage sensors) all the time
[]
fire_binary_sensors
list of binary sensors to monitor (like water smoke sensors) all the time
[]
fire_temperature_sensors
list of temperature sensors to monitor (like temperature sensors) all the time
[]
armed_home_image_processing_sensors
list of image processing sensors to monitor in case you are home
[]
armed_away_image_processing_sensors
list of image processing sensors to monitor in case you are away
[]
alarm_control_buttons
list of buttons to control (single click arm_away, double click disarm, long pres arm_home)
[]
alarm_lights
list of lights to indicate alarm status (red is triggered, blinking is pending)
[]
alarm_arm_night_after_time
time to arm at evening
23:15:00
alarm_arm_night_before_time
time to disarm at morning
06:00:00
sleep_after_time
start of sleeptime at evening
23:15:00
sleep_before_time
end of sleeptime at morning
06:00:00
vacation_control
input boolean to configure a vacation mode which arms using armed_vacation
None
guest_control
input boolean to configure a babysitter mode which does not auto arm
None
silent_control
input boolean to mute the alarm sound
None
siren_switches
list of siren switches to turn on or off
[]
notify_service
script to call for notification
None
notify_title
title parameter for script
AlarmSystem triggered, possible intruder
cameras
List of cameras (snapshots will be made once alarm is triggered)
[]
camera_snapshot_path
Path for storing camera snapshots
/tmp
camera_snapshot_regex
Regex for camera snapshots
“camera_.*\d+_\d+.jpg”
alexa_monkeys
list of alexa voice monkeys for audio notifications
[]
telegram_user_ids
list of telegram user ids used for notifications
[]
Feel free to report any errors, I will migrate this stuff to a real github repo in the future…
you could explain a little more about which parts are optional and which not.
and for instance i have no clue what the xiaomi hub does or what it has to do with it and if i need it and why.
you have notify_service point to a script?
why isnt that just a name from the notify you want to use?
Mandatory are a list of sensors and a color light otherwise it does not make sense. The whole xiaomi stuff is optional but recommended. It provides you with a cheap alarm siren and some hardware buttons.
The guest control is a ha input which ensures that if you leave home but guests are still there the alarm does not get armed.
The idea is that you normally do not have to arm or disarm the system because everything works automatically.
The notify is a script call because you can extend it this way. I will rename it to triggered script call or something like this. I will also add scene support.
thanks for explaining. wont be of any use for me this way but maybe for someone else.
there are some parts in your code that makes me wonder why though.
in parts like this:
i = 0
for sensor in self._armed_home_sensors:
self.listen_state(
self.trigger_alarm_while_armed_home_callback, sensor, new="on", old="off", duration=i)
i += 1
if i put in 4 sensors like [“sensor.a”,“sensor.b”,“sensor.c”,“sensor.d”]
that code translates to:
For sensors this is not really needed. The idea is that you do not get 4 events at the same time. If you delay them a bit only the first one will trigger an action. The subsequent ones will see that the state is already set and just do nothing. I am not sure if appdaemon will call callbacks at the same time …
now the fourth trigger needs to be in triggered state before it calls the callback.
a callback is called at the moment that a state changes in HA.
you dont change the time that the callback is called by the duration of a state.
with the devicetrackers it does even make less sence.
a duration from 300 or 301 does not make that the events take place at different moments.
if the second devicetracker changes state a second after the first they will still fire the callback at the exact same time.
make a new app like this:
init(...)
self.listen_state(self.callback,"input_boolean.test")
self.listen_state(self.callback2,"input_boolean.test")
def callback(self,...):
self.log("callback 1 is called")
def callback2(self,...):
self.log("callback 2 is called")
you will have 1 event doing 2 things. “at the same time”
Does this work with the Manual alarm control panel with MQTT support in HASS?
I use this panel together with an Android tablet and an MQTT alarm panel app to switch my alarm on and off.
next time, first look at the logs if appdaemon is running correct and if there are errors
i wont hurt to do that on regular basis and it can tell you if there is a problem.
thanks.solvedi used old gist repo without appdaemon v3 support working fine but the documentation is weak… I’d like using my xmpp notification Plantform
Strange issue since last home assistant 99.x The alarsystem does not recognize when device_tracker goes to not_home But when it goes to home… Strange isn’t it?
here the logs:
2019-09-27 15:38:17.950538 INFO alarm_system: Got armed_home sensors ['binary_sensor.door_dining_room_garage', 'binary_sensor.door_entrance', 'binary_sensor.door_garage_garden', 'binary_sensor.garage_door', 'binary_sensor.window_chill_out_corner', 'binary_sensor.door_porch']
2019-09-27 15:38:17.952213 INFO alarm_system: Got armed_away sensors ['binary_sensor.door_dining_room_garage', 'binary_sensor.door_entrance', 'binary_sensor.door_garage_garden', 'binary_sensor.garage_door', 'binary_sensor.window_bathroom_downstairs', 'binary_sensor.window_bathroom_upstairs', 'binary_sensor.window_bedroom', 'binary_sensor.window_chill_out_corner', 'binary_sensor.window_evan', 'binary_sensor.window_bathroom_downstairs', 'binary_sensor.window_kitchen', 'binary_sensor.window_rose', 'binary_sensor.door_porch']
2019-09-27 15:38:17.954035 INFO alarm_system: Got device trackers ['device_tracker.phone_emilie', 'device_tracker.phone_thorsten']
2019-09-27 15:38:17.957056 INFO alarm_system: Got 0 device_trackers home and 2 device_trackers not home
2019-09-27 15:38:17.958331 INFO alarm_system: Got guest_mode False
2019-09-27 15:38:17.959310 INFO alarm_system: Got vacation_mode False
2019-09-27 15:38:17.960288 INFO alarm_system: Got silent mode False
2019-09-27 15:38:17.961231 INFO alarm_system: Got info volume 10
2019-09-27 15:38:17.962188 INFO alarm_system: Got alarm volume 100
2019-09-27 15:38:17.963601 INFO alarm_system: Got notify service notify.thorsten
2019-09-27 15:38:17.965289 INFO alarm_system: Got alarm state disarmed
2019-09-27 15:39:00.007138 INFO alarm_system: Callback alarm_disarm_auto from device_tracker.phone_thorsten:state not_home->home
2019-09-27 15:39:00.008659 INFO alarm_system: Ignoring status home of device_tracker.phone_thorsten because alarm system is in state disarmed
```