billimek / home-assistant-config

Personal Configuration for Home Assistant
https://home-assistant.io/
Apache License 2.0
29 stars 4 forks source link

Auto-arm alarm at night #39

Closed billimek closed 5 years ago

billimek commented 5 years ago

Similar to how we handle video cameras going to 'away' mode at night. We want to automatically arm and disarm the home alarm at midnight and 5am.

billimek commented 5 years ago

This should be completed now via node-red: image

billimek commented 5 years ago

exported sanitized flow code for this is:

[{"id":"4aedf9e8.044e08","type":"tab","label":"Alarm","disabled":false,"info":""},{"id":"6cb23d50.77ced4","type":"bigtimer","z":"4aedf9e8.044e08","outtopic":"","outpayload1":"1","outpayload2":"","name":"Midnight every day","comment":"","lat":"33.94519","lon":"-84.45379","starttime":"0","endtime":"15","starttime2":0,"endtime2":0,"startoff":"0","endoff":"0","offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":true,"odd":false,"even":false,"x":139,"y":88.5,"wires":[["c77d382a.cb6bf8"],[],[]]},{"id":"c77d382a.cb6bf8","type":"api-current-state","z":"4aedf9e8.044e08","name":"sensor.anyone_home","server":"8b52884a.b76658","halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"sensor.anyone_home","state_type":"str","outputs":1,"x":389,"y":84,"wires":[["d23e8d4a.f0adb"]]},{"id":"bafec0ae.30733","type":"inject","z":"4aedf9e8.044e08","name":"force-run","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":131,"y":151,"wires":[["c77d382a.cb6bf8"]]},{"id":"d23e8d4a.f0adb","type":"switch","z":"4aedf9e8.044e08","name":"state = \"home\" ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":619,"y":85,"wires":[["8d782ee4.3daf1"]]},{"id":"97f358c3.fa2c48","type":"api-call-service","z":"4aedf9e8.044e08","name":"arm alarm","server":"8b52884a.b76658","service_domain":"alarm_control_panel","service":"alarm_arm_home","data":"{\"entity_id\":\"alarm_control_panel.alarm_panel\",\"code\":\"1234\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":804,"y":150,"wires":[["5358b879.268c18"]]},{"id":"5358b879.268c18","type":"debug","z":"4aedf9e8.044e08","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1016,"y":149,"wires":[]},{"id":"24e58e6b.442df2","type":"bigtimer","z":"4aedf9e8.044e08","outtopic":"","outpayload1":"1","outpayload2":"","name":"5am every day","comment":"","lat":"33.94519","lon":"-84.45379","starttime":"300","endtime":"315","starttime2":0,"endtime2":0,"startoff":"0","endoff":"0","offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":true,"odd":false,"even":false,"x":123,"y":277.5,"wires":[["73c30e71.e8d46"],[],[]]},{"id":"73c30e71.e8d46","type":"api-current-state","z":"4aedf9e8.044e08","name":"sensor.anyone_home","server":"8b52884a.b76658","halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"sensor.anyone_home","state_type":"str","outputs":1,"x":361,"y":272,"wires":[["9352946e.57f958"]]},{"id":"d6646d02.af28b","type":"inject","z":"4aedf9e8.044e08","name":"force-run","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":129,"y":342,"wires":[["73c30e71.e8d46"]]},{"id":"9352946e.57f958","type":"switch","z":"4aedf9e8.044e08","name":"state = \"home\" ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":585,"y":272,"wires":[["f36487b8.7e8c48"]]},{"id":"3e70cbd7.48e594","type":"api-call-service","z":"4aedf9e8.044e08","name":"disarm alarm","server":"8b52884a.b76658","service_domain":"alarm_control_panel","service":"alarm_disarm","data":"{\"entity_id\":\"alarm_control_panel.alarm_panel\",\"code\":\"1234\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":778,"y":338,"wires":[["bf10eb8e.43f3c8"]]},{"id":"bf10eb8e.43f3c8","type":"debug","z":"4aedf9e8.044e08","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":962,"y":338,"wires":[]},{"id":"8d782ee4.3daf1","type":"api-current-state","z":"4aedf9e8.044e08","name":"alarm panel current state","server":"8b52884a.b76658","halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"alarm_control_panel.alarm_panel","state_type":"str","outputs":1,"x":851,"y":85,"wires":[["10bf8c8c.d600b3","857877dc.86e6c8"]]},{"id":"10bf8c8c.d600b3","type":"debug","z":"4aedf9e8.044e08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1070,"y":43,"wires":[]},{"id":"857877dc.86e6c8","type":"switch","z":"4aedf9e8.044e08","name":"state = \"disarmed\" ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"disarmed","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1095,"y":85,"wires":[["97f358c3.fa2c48"]]},{"id":"f36487b8.7e8c48","type":"api-current-state","z":"4aedf9e8.044e08","name":"alarm panel current state","server":"8b52884a.b76658","halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"alarm_control_panel.alarm_panel","state_type":"str","outputs":1,"x":815,"y":272,"wires":[["ac082e65.b8107","df3d8203.e0e19"]]},{"id":"ac082e65.b8107","type":"switch","z":"4aedf9e8.044e08","name":"state != \"disarmed\" ?","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"disarmed","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1055,"y":272,"wires":[["3e70cbd7.48e594"]]},{"id":"df3d8203.e0e19","type":"debug","z":"4aedf9e8.044e08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1030,"y":215,"wires":[]},{"id":"8b52884a.b76658","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]