Skip to content

Instantly share code, notes, and snippets.

@shbatm
Created February 19, 2020 20:23
Show Gist options
  • Save shbatm/bbee9d73ed30cb3199f46bd23cf66c90 to your computer and use it in GitHub Desktop.
Save shbatm/bbee9d73ed30cb3199f46bd23cf66c90 to your computer and use it in GitHub Desktop.
[{"id":"cf4c09c8.62a618","type":"subflow","name":"Proximity Direction","info":"","category":"","in":[{"x":100,"y":120,"wires":[{"id":"f3d3f8e3.baa6d8"}]}],"out":[{"x":900,"y":100,"wires":[{"id":"39d50f9b.dce93","port":0},{"id":"f3d3f8e3.baa6d8","port":1}]},{"x":900,"y":140,"wires":[{"id":"a83c7954.ef7ff8","port":0},{"id":"f3d3f8e3.baa6d8","port":2}]}],"env":[],"color":"#DDAA99","status":{"x":900,"y":200,"wires":[{"id":"811548e6.c2d138","port":0}]}},{"id":"fb59e76e.78b738","type":"switch","z":"cf4c09c8.62a618","name":"To/From","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"data.event.old_state.state","vt":"msg"},{"t":"gt","v":"data.event.old_state.state","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":120,"wires":[["f1af8369.45e2d","47cc6705.3dbdb8"],["5df4fd11.b2f164","fe55edd.ac4731"]]},{"id":"f1af8369.45e2d","type":"counter","z":"cf4c09c8.62a618","name":"","init":"0","step":"1","lower":"","upper":"2","mode":"increment","outputs":"1","x":660,"y":100,"wires":[["39d50f9b.dce93","811548e6.c2d138"]]},{"id":"5df4fd11.b2f164","type":"counter","z":"cf4c09c8.62a618","name":"","init":"0","step":"1","lower":"","upper":"2","mode":"increment","outputs":"1","x":660,"y":140,"wires":[["a83c7954.ef7ff8","811548e6.c2d138"]]},{"id":"fe55edd.ac4731","type":"change","z":"cf4c09c8.62a618","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[["f1af8369.45e2d"]]},{"id":"47cc6705.3dbdb8","type":"change","z":"cf4c09c8.62a618","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":80,"wires":[["5df4fd11.b2f164"]]},{"id":"39d50f9b.dce93","type":"switch","z":"cf4c09c8.62a618","name":"Valid?","property":"msg","propertyType":"jsonata","rules":[{"t":"hask","v":"countUpperLimitReached","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":100,"wires":[["993299c0.6603a8"]]},{"id":"a83c7954.ef7ff8","type":"switch","z":"cf4c09c8.62a618","name":"Valid?","property":"msg","propertyType":"jsonata","rules":[{"t":"hask","v":"countUpperLimitReached","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":140,"wires":[["993299c0.6603a8"]]},{"id":"811548e6.c2d138","type":"function","z":"cf4c09c8.62a618","name":"Status","func":"if (msg.reset) { return; }\n\nif (msg.data.event.new_state.attributes.dir_of_travel != \"unknown\") {\n status = {\n fill:\"green\",\n shape:\"dot\",\n text:msg.data.event.new_state.attributes.dir_of_travel\n \n };\n msg.payload = status;\n return msg;\n}\n\npayload = \"\";\nif (msg.payload <= msg.data.event.old_state.state) {\n payload = \"Towards \";\n} else {\n payload = \"Away From \";\n}\npayload = payload + \"(\" + msg.count + \")\"\n\nif (\"countUpperLimitReached\" in msg) {\n status = {fill:\"green\",shape:\"dot\",text:payload};\n} else {\n status = {fill:\"red\",shape:\"ring\",text:payload}\n}\nmsg.payload = status;\nreturn msg;","outputs":1,"noerr":0,"x":810,"y":200,"wires":[[]]},{"id":"993299c0.6603a8","type":"debug","z":"cf4c09c8.62a618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1010,"y":120,"wires":[]},{"id":"f3d3f8e3.baa6d8","type":"switch","z":"cf4c09c8.62a618","name":"Dir of Travel?","property":"data.event.new_state.attributes.dir_of_travel","propertyType":"msg","rules":[{"t":"eq","v":"unknown","vt":"str"},{"t":"eq","v":"towards","vt":"str"},{"t":"eq","v":"away_from","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":210,"y":120,"wires":[["fb59e76e.78b738"],["811548e6.c2d138"],["811548e6.c2d138"]]},{"id":"346290c3.fa274","type":"subflow","name":"Notify","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"22b6b85.f725348"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"22b6b85.f725348","type":"api-current-state","z":"346290c3.fa274","name":"Notifiy Enabled?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.enable_notifications","state_type":"habool","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":true,"x":200,"y":80,"wires":[["7c671b57.96a9f4","59799f50.86c22"],[]]},{"id":"a662f1b4.a94d7","type":"api-current-state","z":"346290c3.fa274","name":"Send To","server":"a2277b3b.64d0f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_select.last_one_home","state_type":"str","state_location":"notify_send_to","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":580,"y":100,"wires":[["14b9573c.15be59"]]},{"id":"14b9573c.15be59","type":"switch","z":"346290c3.fa274","name":"Method?","property":"notify_send_to","propertyType":"msg","rules":[{"t":"eq","v":"tim","vt":"str"},{"t":"eq","v":"lindsay","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":740,"y":80,"wires":[["9fd7b435.c53188","7c671b57.96a9f4"],["baab3eda.2388d","7c671b57.96a9f4"],["9fd7b435.c53188","baab3eda.2388d","7c671b57.96a9f4"]]},{"id":"d124ee1a.dcd73","type":"api-call-service","z":"346290c3.fa274","name":"Notify Tim","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_biscuit","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1100,"y":60,"wires":[[]]},{"id":"9fd7b435.c53188","type":"function","z":"346290c3.fa274","name":"Set Data","func":"if (\"android\" in msg.notify_msg) {\n msg.notify_msg.data = msg.notify_msg.android;\n delete msg.notify_msg.android;\n}\nif (\"ios\" in msg.notify_msg) {\n delete msg.notify_msg.ios;\n}\nmsg.payload = { data: msg.notify_msg };\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":60,"wires":[["d124ee1a.dcd73"]]},{"id":"baab3eda.2388d","type":"function","z":"346290c3.fa274","name":"Set Data","func":"if (\"android\" in msg.notify_msg) {\n delete msg.notify_msg.android;\n}\nif (\"ios\" in msg.notify_msg) {\n msg.notify_msg.data = msg.notify_msg.ios;\n delete msg.notify_msg.ios;\n}\n\nmsg.payload = { data: msg.notify_msg }\nreturn msg;","outputs":1,"noerr":0,"x":940,"y":120,"wires":[["eec91a0f.5885a8"]]},{"id":"eec91a0f.5885a8","type":"api-call-service","z":"346290c3.fa274","name":"Notify Lindsay","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_lindsay","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1120,"y":120,"wires":[[]]},{"id":"7c671b57.96a9f4","type":"debug","z":"346290c3.fa274","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":240,"wires":[]},{"id":"59799f50.86c22","type":"switch","z":"346290c3.fa274","name":"Send To Set?","property":"msg","propertyType":"jsonata","rules":[{"t":"hask","v":"notify_send_to","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":400,"y":80,"wires":[["14b9573c.15be59"],["a662f1b4.a94d7"]]},{"id":"da78b56d.dbed78","type":"tab","label":"Presence Detection","disabled":false,"info":""},{"id":"490698e6.393dd8","type":"trigger-state","z":"da78b56d.dbed78","name":"Lindsay","server":"a2277b3b.64d0f8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"person.lindsay","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":120,"y":120,"wires":[["59ea0862.80d228"],[]]},{"id":"90cd6d10.57d53","type":"trigger-state","z":"da78b56d.dbed78","name":"Tim","server":"a2277b3b.64d0f8","entityid":"person.tim","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":130,"y":200,"wires":[["59ea0862.80d228"],[]]},{"id":"59ea0862.80d228","type":"ha-get-entities","z":"da78b56d.dbed78","server":"a2277b3b.64d0f8","name":"People Home","rules":[{"property":"entity_id","logic":"is","value":"person.*","valueType":"re"},{"property":"state","logic":"is","value":"home","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":340,"y":160,"wires":[["bb916032.e1067"]]},{"id":"bb916032.e1067","type":"switch","z":"da78b56d.dbed78","name":"How Many?","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"$count(payload) = 0","vt":"jsonata"},{"t":"jsonata_exp","v":"$count(payload) = 1","vt":"jsonata"},{"t":"jsonata_exp","v":"$count(payload) = 2","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":3,"x":550,"y":160,"wires":[["e244db86.777df8","e3e6d7a9.d3aff8","834ef8b4.a0c048","f9c8d09e.fb59c"],["5429bc2b.1ec4a4","834ef8b4.a0c048","5e9aa29c.8bf59c","cdaf2cf0.c8b17","c0bdb88f.55e578"],["a853c0a1.d4a09","5e9aa29c.8bf59c","5429bc2b.1ec4a4","c200e0d5.4632e"]]},{"id":"a853c0a1.d4a09","type":"api-call-service","z":"da78b56d.dbed78","name":"All Home","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.all_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":860,"y":340,"wires":[[]]},{"id":"5429bc2b.1ec4a4","type":"api-call-service","z":"da78b56d.dbed78","name":"Someone Home On","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.someone_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":900,"y":280,"wires":[[]]},{"id":"e244db86.777df8","type":"api-call-service","z":"da78b56d.dbed78","name":"Nobody Home","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.nobody_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":880,"y":220,"wires":[[]]},{"id":"e3e6d7a9.d3aff8","type":"api-call-service","z":"da78b56d.dbed78","name":"Someone Home Off","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.someone_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":890,"y":100,"wires":[[]]},{"id":"5e9aa29c.8bf59c","type":"api-call-service","z":"da78b56d.dbed78","name":"Nobody Home Off","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.nobody_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":890,"y":40,"wires":[[]]},{"id":"834ef8b4.a0c048","type":"api-call-service","z":"da78b56d.dbed78","name":"All Home Off","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.all_home","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":870,"y":160,"wires":[[]]},{"id":"9a76db6.7ed4d28","type":"comment","z":"da78b56d.dbed78","name":"Basic Presence Detection","info":"","x":170,"y":40,"wires":[]},{"id":"2cd5d297.9d011e","type":"comment","z":"da78b56d.dbed78","name":"Lindsay's Location","info":"","x":130,"y":380,"wires":[]},{"id":"1ad696c.f301569","type":"state-machine","z":"da78b56d.dbed78","name":"Not-so-binary Status","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["Home","Departed","Away","Arrived","Extended Away"],"transitions":[{"name":"not_home","from":"Home","to":"Departed"},{"name":"not_home","from":"Arrived","to":"Departed"},{"name":"Timeout","from":"Departed","to":"Away"},{"name":"Timeout","from":"Arrived","to":"Home"},{"name":"Timeout","from":"Away","to":"Extended Away"},{"name":"home","from":"Away","to":"Arrived"},{"name":"home","from":"Extended Away","to":"Arrived"},{"name":"home","from":"Departed","to":"Home"},{"name":"reset","from":"*","to":"Home"}],"x":500,"y":540,"wires":[["22e9a355.d059fc","fee1bf6f.62891","fa5662fd.2e8a4"]]},{"id":"6c546654.d99778","type":"inject","z":"da78b56d.dbed78","name":"Depart","topic":"","payload":"not_home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":600,"wires":[["1ad696c.f301569"]]},{"id":"70800f5d.1df79","type":"inject","z":"da78b56d.dbed78","name":"Arrive","topic":"","payload":"home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":560,"wires":[["1ad696c.f301569"]]},{"id":"6e22846.197187c","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"Timeout","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":640,"wires":[["1ad696c.f301569"]]},{"id":"52681cd4.c865e4","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":680,"wires":[["1ad696c.f301569"]]},{"id":"22e9a355.d059fc","type":"switch","z":"da78b56d.dbed78","name":"Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Arrived","vt":"str"},{"t":"eq","v":"Departed","vt":"str"},{"t":"eq","v":"Away","vt":"str"},{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Extended Away","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":710,"y":540,"wires":[["eb28f007.3b281"],["eb28f007.3b281"],["4e9e5bb9.aa6794"],[],[]]},{"id":"fee1bf6f.62891","type":"api-call-service","z":"da78b56d.dbed78","name":"Update Status","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.lindsay_location","data":"{\"option\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":740,"y":600,"wires":[[]]},{"id":"cb823ed4.cd4db","type":"trigger-state","z":"da78b56d.dbed78","name":"Lindsay Status","server":"a2277b3b.64d0f8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"person.lindsay","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"xgvucav759","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"tnrz984o7dd","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"home"},{"outputId":"p86uftktd2a","messageType":"payload","messageValue":"not_home","messageValueType":"str","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is_not","comparatorValue":"home"}],"outputinitially":false,"state_type":"str","x":140,"y":440,"wires":[[],[],["1ad696c.f301569"],["1ad696c.f301569"]]},{"id":"c1b7d05c.63aa3","type":"state-machine","z":"da78b56d.dbed78","name":"Not-so-binary Status","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["Home","Departed","Away","Arrived","Extended Away"],"transitions":[{"name":"not_home","from":"Home","to":"Departed"},{"name":"Timeout","from":"Departed","to":"Away"},{"name":"Timeout","from":"Arrived","to":"Home"},{"name":"Timeout","from":"Away","to":"Extended Away"},{"name":"home","from":"Away","to":"Arrived"},{"name":"home","from":"Extended Away","to":"Arrived"},{"name":"home","from":"Departed","to":"Home"},{"name":"reset","from":"*","to":"Home"},{"name":"not_home","from":"Arrived","to":"Departed"}],"x":500,"y":860,"wires":[["e2245d9c.45343","92d309e6.0e06d8","b401be82.dc293"]]},{"id":"5621bd7c.b928d4","type":"inject","z":"da78b56d.dbed78","name":"Depart","topic":"","payload":"not_home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":980,"wires":[["c1b7d05c.63aa3"]]},{"id":"cf18fab1.4e9f98","type":"inject","z":"da78b56d.dbed78","name":"Arrive","topic":"","payload":"home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":940,"wires":[["c1b7d05c.63aa3"]]},{"id":"4b33f5a4.cac98c","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"Timeout","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":1020,"wires":[["c1b7d05c.63aa3"]]},{"id":"5fe915b8.24c82c","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":1060,"wires":[["c1b7d05c.63aa3"]]},{"id":"e2245d9c.45343","type":"api-call-service","z":"da78b56d.dbed78","name":"Update Status","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.tim_location","data":"{\"option\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":740,"y":920,"wires":[[]]},{"id":"38e7c571.297f7a","type":"comment","z":"da78b56d.dbed78","name":"Tim's Location","info":"","x":110,"y":760,"wires":[]},{"id":"cdaf2cf0.c8b17","type":"ha-get-entities","z":"da78b56d.dbed78","server":"a2277b3b.64d0f8","name":"Someone Out-of-Town?","rules":[{"property":"entity_id","logic":"is","value":"input_select\\.(tim|lindsay)_location","valueType":"re"},{"property":"state","logic":"is","value":"Extended Away","valueType":"str"}],"output_type":"count","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":450,"y":340,"wires":[["ba0a602d.e26c6"]]},{"id":"ba0a602d.e26c6","type":"switch","z":"da78b56d.dbed78","name":"How Many?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":340,"wires":[["a853c0a1.d4a09"]]},{"id":"90cca187.82538","type":"api-current-state","z":"da78b56d.dbed78","name":"Get Other Person","server":"a2277b3b.64d0f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1330,"y":220,"wires":[["636a48eb.537e38"]]},{"id":"f9c8d09e.fb59c","type":"change","z":"da78b56d.dbed78","name":"Other Person","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"entity_id\": ( topic = \"person.tim\") ? \"person.lindsay\" : \"person.tim\" }","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":220,"wires":[["90cca187.82538"]]},{"id":"636a48eb.537e38","type":"switch","z":"da78b56d.dbed78","name":"Time Since Departure","property":"data.timeSinceChangedMs","propertyType":"msg","rules":[{"t":"gt","v":"900000","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1540,"y":220,"wires":[["dd74d995.819608"],["c200e0d5.4632e"]]},{"id":"a0a6d480.86a4a8","type":"api-call-service","z":"da78b56d.dbed78","name":"Set Last Home","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.last_one_home","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1980,"y":220,"wires":[[]]},{"id":"c200e0d5.4632e","type":"change","z":"da78b56d.dbed78","name":"Set Option: Both","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"option\":\"both\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1780,"y":240,"wires":[["a0a6d480.86a4a8"]]},{"id":"dd74d995.819608","type":"change","z":"da78b56d.dbed78","name":"Set Option: Name","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"data\":{\t \"option\": $substringAfter(data.entity_id, '.')\t\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1770,"y":200,"wires":[["a0a6d480.86a4a8"]]},{"id":"3b6a8eeb.7753f2","type":"comment","z":"da78b56d.dbed78","name":"Determine Last Person to Leave","info":"","x":1190,"y":140,"wires":[]},{"id":"a6b15f0e.c9dcb","type":"comment","z":"da78b56d.dbed78","name":"Bed Sensor","info":"","x":110,"y":1120,"wires":[]},{"id":"2eab2f0b.c2814","type":"ha-get-entities","z":"da78b56d.dbed78","server":"a2277b3b.64d0f8","name":"People Home","rules":[{"property":"entity_id","logic":"is","value":"person.*","valueType":"re"},{"property":"state","logic":"is","value":"home","valueType":"str"}],"output_type":"count","output_empty_results":false,"output_location_type":"msg","output_location":"people_home","output_results_count":1,"x":350,"y":1200,"wires":[["47222279.fda10c"]]},{"id":"5a2dbf02.d57e2","type":"trigger-state","z":"da78b56d.dbed78","name":"People in Bed","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_bed_sensor"},{"property":"icon","value":"mdi:hotel"}],"entityid":"sensor.people_in_bed","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"9qoc6qvci1s","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"num","x":140,"y":1200,"wires":[["2eab2f0b.c2814"],[]]},{"id":"67b209fe.af1038","type":"comment","z":"da78b56d.dbed78","name":"Everyone In Bed - Good Night Mode","info":"","x":200,"y":3120,"wires":[]},{"id":"b792b8b5.b7fd48","type":"api-call-service","z":"da78b56d.dbed78","name":"Disable Alexa TTS","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.enable_tts","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":3140,"wires":[[]]},{"id":"f0e4f347.9a5fb","type":"comment","z":"da78b56d.dbed78","name":"Everyone Out of Bed","info":"","x":150,"y":3220,"wires":[]},{"id":"a5c4db73.d19018","type":"link in","z":"da78b56d.dbed78","name":"Bed Good Morning Mode","links":["7667eb77.ba4914"],"x":95,"y":3280,"wires":[["bc582252.5ae6"]]},{"id":"41ee5624.980888","type":"api-call-service","z":"da78b56d.dbed78","name":"Enable Alexa TTS","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.enable_tts","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":3320,"wires":[[]]},{"id":"fd24bb24.0710f8","type":"api-current-state","z":"da78b56d.dbed78","name":"Save TTS State","server":"a2277b3b.64d0f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.enable_tts","state_type":"str","state_location":"enable_tts_last_state","override_payload":"global","entity_location":"","override_data":"none","blockInputOverrides":true,"x":840,"y":3140,"wires":[["b792b8b5.b7fd48"]]},{"id":"2214e49a.81da1c","type":"function","z":"da78b56d.dbed78","name":"Restore TTS State","func":"var last_state=global.get('enable_tts_last_state') || \"on\";\nnode.log(last_state);\nif (last_state !== \"off\") {\n return msg;\n}\n","outputs":1,"noerr":0,"x":670,"y":3320,"wires":[["41ee5624.980888"]]},{"id":"4afe22af.0cc99c","type":"delay","z":"da78b56d.dbed78","name":"Rate Limit","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"12","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":660,"y":3140,"wires":[["fd24bb24.0710f8","9a9482d0.ff39c"]]},{"id":"9a9482d0.ff39c","type":"api-call-service","z":"da78b56d.dbed78","name":"ISY All Off","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.all_off","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":3180,"wires":[[]]},{"id":"99cfbb0b.8aa818","type":"change","z":"da78b56d.dbed78","name":"RESET","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3140,"wires":[["4afe22af.0cc99c"]]},{"id":"22845a13.2ace86","type":"comment","z":"da78b56d.dbed78","name":"House Occupancy Mode","info":"","x":150,"y":1380,"wires":[]},{"id":"8d1a9a0b.114898","type":"state-machine","z":"da78b56d.dbed78","name":"Not-so-binary Status","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["Home","Departed","Away","Arrived","Extended Away","Returning"],"transitions":[{"name":"not_home","from":"Home","to":"Departed"},{"name":"Timeout","from":"Departed","to":"Away"},{"name":"Timeout","from":"Arrived","to":"Home"},{"name":"Timeout","from":"Away","to":"Extended Away"},{"name":"home","from":"Away","to":"Arrived"},{"name":"home","from":"Extended Away","to":"Arrived"},{"name":"home","from":"Departed","to":"Home"},{"name":"home","from":"Returning","to":"Arrived"},{"name":"returning","from":"Extended Away","to":"Returning"},{"name":"returning","from":"Away","to":"Returning"},{"name":"returning","from":"Departed","to":"Returning"},{"name":"reset","from":"*","to":"Home"}],"x":440,"y":1480,"wires":[["879306ef.baeaa8","ae6fcb27.07d948","3d8e2bdc.df3004"]]},{"id":"1809a170.16638f","type":"inject","z":"da78b56d.dbed78","name":"Depart","topic":"","payload":"not_home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1660,"wires":[["8d1a9a0b.114898"]]},{"id":"b49e3843.65f518","type":"inject","z":"da78b56d.dbed78","name":"Arrive","topic":"","payload":"home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1620,"wires":[["8d1a9a0b.114898"]]},{"id":"4a36a5cd.f89e5c","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"Timeout","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1700,"wires":[["8d1a9a0b.114898"]]},{"id":"45ece777.421e88","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1740,"wires":[["8d1a9a0b.114898"]]},{"id":"879306ef.baeaa8","type":"switch","z":"da78b56d.dbed78","name":"Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Arrived","vt":"str"},{"t":"eq","v":"Returning","vt":"str"},{"t":"eq","v":"Departed","vt":"str"},{"t":"eq","v":"Away","vt":"str"},{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Extended Away","vt":"str"}],"checkall":"false","repair":false,"outputs":6,"x":650,"y":1480,"wires":[["7882346.1f277cc","fe45ab0a.f55018"],["7882346.1f277cc"],["fe45ab0a.f55018"],["507e4229.4041ac","d887aa5.10f0858"],[],[]]},{"id":"ae6fcb27.07d948","type":"api-call-service","z":"da78b56d.dbed78","name":"Update Status","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.home_status","data":"{\"option\":\"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":680,"y":1600,"wires":[[]]},{"id":"d13b0e42.2f779","type":"trigger-state","z":"da78b56d.dbed78","name":"Somebody Home","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_house_occupancy_mode"},{"property":"icon","value":"mdi:home"}],"entityid":"input_boolean.someone_home","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"4iizbzpwjv","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":3,"customoutputs":[{"outputId":"xnkej80fq5l","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"home"}],"outputinitially":false,"state_type":"str","x":170,"y":1460,"wires":[["8d1a9a0b.114898"],[],["a7da32f5.2fe65"]]},{"id":"39fab1f9.c6ee4e","type":"api-current-state","z":"da78b56d.dbed78","name":"Is Baby Tree On?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.baby_tree","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":850,"y":3220,"wires":[["bb926291.3631f"],[]]},{"id":"bb926291.3631f","type":"api-call-service","z":"da78b56d.dbed78","name":"Dim Baby Tree","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.baby_tree","data":"{\"transition\":1,\"brightness_pct\":30}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1060,"y":3220,"wires":[[]]},{"id":"f566244d.91ae78","type":"api-current-state","z":"da78b56d.dbed78","name":"Are Lamps On?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.bedside_lamps","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":840,"y":3260,"wires":[["60490356.b821ec"],[]]},{"id":"60490356.b821ec","type":"api-call-service","z":"da78b56d.dbed78","name":"Dim Lamps","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.lamps","data":"{\"transition\":1,\"brightness_pct\":30}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":3260,"wires":[[]]},{"id":"477387c.4d86678","type":"comment","z":"da78b56d.dbed78","name":"Proximity Alert - Approaching Home","info":"","x":180,"y":1780,"wires":[]},{"id":"7286170f.b36888","type":"trigger-state","z":"da78b56d.dbed78","name":"Proximity Detection Tim","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_proximity_detection_tim"},{"property":"icon","value":"mdi:compass"}],"entityid":"proximity.tim_home","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"3ssdmhhv08o","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"num","x":170,"y":1840,"wires":[["e677de6b.2c814"],[]]},{"id":"e09bc347.0799e","type":"switch","z":"da78b56d.dbed78","name":"Distance from Home","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"3000","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":1840,"wires":[["d6bc61dd.6c016","951d6a46.0be1a8"]]},{"id":"fc0cfa95.edf888","type":"ha-entity","z":"da78b56d.dbed78","name":"Someone Nearby Home","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"outputs":1,"entityType":"binary_sensor","config":[{"property":"name","value":"Someone Nearby Home"},{"property":"device_class","value":"presence"},{"property":"icon","value":"mdi:map-marker-distance"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[{"property":"last_prox_update","value":"topic","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","x":1450,"y":1900,"wires":[[]]},{"id":"3d65c322.53cbdc","type":"api-current-state","z":"da78b56d.dbed78","name":"Someone Else Home?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"input_boolean.someone_home","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":true,"x":940,"y":1920,"wires":[["4687f1a7.1c6ed"],[]]},{"id":"d6bc61dd.6c016","type":"change","z":"da78b56d.dbed78","name":"Set Status","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":1840,"wires":[["fc0cfa95.edf888"]]},{"id":"4687f1a7.1c6ed","type":"change","z":"da78b56d.dbed78","name":"Set Status","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":1920,"wires":[["fc0cfa95.edf888"]]},{"id":"d64fc81f.0333b8","type":"switch","z":"da78b56d.dbed78","name":"Distance from Home","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"3000","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":1920,"wires":[["3d65c322.53cbdc"]]},{"id":"a7da32f5.2fe65","type":"api-current-state","z":"da78b56d.dbed78","name":"Error Check Somoene Nearby Home","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is_not","override_topic":false,"entity_id":"binary_sensor.someone_nearby_home","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":true,"x":750,"y":1720,"wires":[["d6bc61dd.6c016"],[]]},{"id":"4d5dc065.da655","type":"api-current-state","z":"da78b56d.dbed78","name":"Tim's Home?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"person.tim","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1230,"y":1780,"wires":[["c518325d.e12ba"],[]]},{"id":"951d6a46.0be1a8","type":"switch","z":"da78b56d.dbed78","name":"Who?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"proximity.lindsay_home","vt":"str"},{"t":"eq","v":"proximity.tim_home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":1800,"wires":[["4d5dc065.da655"],[]]},{"id":"ea2c8567.e6fee8","type":"subflow:346290c3.fa274","z":"da78b56d.dbed78","name":"","env":[],"x":1990,"y":1780,"wires":[]},{"id":"197d1678.b34fda","type":"template","z":"da78b56d.dbed78","name":"Notify Message","field":"notify_msg","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"title\": \"On My Way!\",\n \"message\": \"Lindsay is almost home.\"\n}","output":"json","x":1660,"y":1780,"wires":[["dd545d7a.fe165"]]},{"id":"dd545d7a.fe165","type":"change","z":"da78b56d.dbed78","name":"Send To","rules":[{"t":"set","p":"notify_send_to","pt":"msg","to":"tim","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1840,"y":1780,"wires":[["ea2c8567.e6fee8"]]},{"id":"1e3be3f8.9972dc","type":"trigger-state","z":"da78b56d.dbed78","name":"Someone Returning","server":"a2277b3b.64d0f8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.someone_approaching_home","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"bn3faehe2a6","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"bool","comparatorValue":"true"},{"id":"qj7o86ilzei","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is_not","comparatorValueDatatype":"bool","comparatorValue":"true"}],"constraintsmustmatch":"all","outputs":3,"customoutputs":[{"outputId":"c73sa0mhd8b","messageType":"payload","messageValue":"returning","messageValueType":"str","comparatorPropertyType":"always","comparatorPropertyValue":"","comparatorType":"is_not","comparatorValue":""}],"outputinitially":false,"state_type":"habool","x":160,"y":1540,"wires":[[],[],["8d1a9a0b.114898"]]},{"id":"2c1c7dfa.50e272","type":"comment","z":"da78b56d.dbed78","name":"HVAC Control","info":"","x":110,"y":2480,"wires":[]},{"id":"507e4229.4041ac","type":"api-call-service","z":"da78b56d.dbed78","name":"Start HVAC Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.hvac_timeout","data":"{ \"duration\": \"00:50:00\" }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":1560,"wires":[[]]},{"id":"7882346.1f277cc","type":"link out","z":"da78b56d.dbed78","name":"","links":["135eb5f6.4cb8ea"],"x":815,"y":1440,"wires":[]},{"id":"135eb5f6.4cb8ea","type":"link in","z":"da78b56d.dbed78","name":"","links":["7882346.1f277cc"],"x":195,"y":2580,"wires":[["2bf3ce49.bb8a32","9e29d6ff.ea4958"]]},{"id":"dce4a190.8795f","type":"comment","z":"da78b56d.dbed78","name":"Returning","info":"","x":120,"y":2580,"wires":[]},{"id":"d7db47b4.bb58d8","type":"inject","z":"da78b56d.dbed78","name":"Force Off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":980,"y":1980,"wires":[["4687f1a7.1c6ed"]]},{"id":"2e206bbb.5f2fc4","type":"inject","z":"da78b56d.dbed78","name":"Force On","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":980,"y":1860,"wires":[["d6bc61dd.6c016"]]},{"id":"4124a027.6ff99","type":"server-events","z":"da78b56d.dbed78","name":"Timer Finished","server":"a2277b3b.64d0f8","event_type":"timer.finished","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_timer_handlers"},{"property":"icon","value":"mdi:camera-timer"}],"x":140,"y":2920,"wires":[["945b928d.c3b8c"]]},{"id":"945b928d.c3b8c","type":"switch","z":"da78b56d.dbed78","name":"Which Timer?","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"timer.hvac_timeout","vt":"str"},{"t":"eq","v":"timer.lindsay_status","vt":"str"},{"t":"eq","v":"timer.tim_status","vt":"str"},{"t":"eq","v":"timer.house_status","vt":"str"},{"t":"eq","v":"timer.bed_status","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":6,"x":340,"y":2920,"wires":[["ee954b17.f0bbb8"],["5bb60ae7.4f5e94"],["59b65a78.25b5c4"],["49567517.1569fc"],["826d8928.ce65b8"],[]]},{"id":"e9fd956c.114ab8","type":"api-current-state","z":"da78b56d.dbed78","name":"Gypsy Home?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.gypsy","state_type":"str","state_location":"gypsy_state","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":true,"x":360,"y":2700,"wires":[["6aefc4e3.48000c","48d44809.a054d8"],["6aefc4e3.48000c","da8438d8.bdc1a8"]]},{"id":"c6d128d0.8f5b28","type":"inject","z":"da78b56d.dbed78","name":"Reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":2540,"wires":[["2bf3ce49.bb8a32"]]},{"id":"b1432855.474528","type":"ha-entity","z":"da78b56d.dbed78","name":"HVAC Away Mode Active","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"outputs":1,"entityType":"binary_sensor","config":[{"property":"name","value":"HVAC Away Mode Active"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:fan-off"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","x":930,"y":2640,"wires":[[]]},{"id":"6aefc4e3.48000c","type":"change","z":"da78b56d.dbed78","name":"ON","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":2660,"wires":[["b1432855.474528"]]},{"id":"2bf3ce49.bb8a32","type":"api-current-state","z":"da78b56d.dbed78","name":"HVAC Away Mode Active?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.hvac_away_mode_active","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":370,"y":2580,"wires":[["cc609ca3.a3702","c5a23dce.471ed"],[]]},{"id":"cc609ca3.a3702","type":"change","z":"da78b56d.dbed78","name":"OFF","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":2620,"wires":[["b1432855.474528"]]},{"id":"de30cccd.b210d","type":"ISY Program","z":"da78b56d.dbed78","name":" HVAC.Away Mode","controller":"5a6617e5.87dae8","programId":"002D","x":910,"y":2580,"wires":[[]]},{"id":"c5a23dce.471ed","type":"change","z":"da78b56d.dbed78","name":"runElse","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"runElse","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":2580,"wires":[["de30cccd.b210d"]]},{"id":"2ac43c3c.f08f54","type":"inject","z":"da78b56d.dbed78","name":"Manual Timeout","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":2700,"wires":[["e9fd956c.114ab8"]]},{"id":"da8438d8.bdc1a8","type":"api-call-service","z":"da78b56d.dbed78","name":"HVAC Away Mode","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.hvac_away_mode","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":770,"y":2760,"wires":[[]]},{"id":"48d44809.a054d8","type":"api-call-service","z":"da78b56d.dbed78","name":"HVAC Gypsy Mode","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.hvac_gypsy_mode","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":770,"y":2700,"wires":[[]]},{"id":"cd794626.1f1d78","type":"trigger-state","z":"da78b56d.dbed78","name":"Skynet Alarm","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_alarm_camera_control"},{"property":"icon","value":"mdi:cctv"}],"entityid":"alarm_control_panel.skynet_alarm","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":5,"customoutputs":[{"outputId":"a6b6ehj52bc","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"armed_home"},{"outputId":"ye40lcdc89","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"armed_away"},{"outputId":"228h920ceeoi","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"disarmed"}],"outputinitially":true,"state_type":"str","x":130,"y":2320,"wires":[[],[],["a4d2f19a.20cd3","44f7d6.df0da82c"],["73eed635.16bc08","44f7d6.df0da82c","890a8ab9.fa38b8"],["8d04c696.d24c58","76109fce.9821a"]]},{"id":"a4d2f19a.20cd3","type":"api-call-service","z":"da78b56d.dbed78","name":"Assume Gypsy is Home","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.gypsy","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":390,"y":2280,"wires":[["c68ad2de.771ca"]]},{"id":"73eed635.16bc08","type":"api-call-service","z":"da78b56d.dbed78","name":"Assume Gypsy is Away","server":"a2277b3b.64d0f8","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.gypsy","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":390,"y":2340,"wires":[["e2f9186b.a7af68"]]},{"id":"e2f9186b.a7af68","type":"ha-wait-until","z":"da78b56d.dbed78","name":"Nobody Home","server":"a2277b3b.64d0f8","outputs":2,"entityId":"input_boolean.nobody_home","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"10","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":660,"y":2340,"wires":[[],[]]},{"id":"76109fce.9821a","type":"ha-wait-until","z":"da78b56d.dbed78","name":"Someone Home","server":"a2277b3b.64d0f8","outputs":2,"entityId":"input_boolean.someone_home","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"10","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":660,"y":2400,"wires":[["2e73846e.248abc"],[]]},{"id":"a184e06b.38d66","type":"ha-wait-until","z":"da78b56d.dbed78","name":"Wait for Arming","server":"a2277b3b.64d0f8","outputs":2,"entityId":"alarm_control_panel.skynet_alarm","property":"state","comparator":"is","value":"armed_.*","valueType":"re","timeout":"10","timeoutUnits":"seconds","entityLocation":"alarm_state","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":460,"y":2060,"wires":[[],["955e1536.f7b648"]]},{"id":"67afed61.104254","type":"comment","z":"da78b56d.dbed78","name":"Alarm Auto-Set","info":"","x":120,"y":2020,"wires":[]},{"id":"8d04c696.d24c58","type":"change","z":"da78b56d.dbed78","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2400,"wires":[["e2f9186b.a7af68","c68ad2de.771ca"]]},{"id":"44f7d6.df0da82c","type":"change","z":"da78b56d.dbed78","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2240,"wires":[["76109fce.9821a"]]},{"id":"964ad036.7f04d","type":"api-call-service","z":"da78b56d.dbed78","name":"Arm Alarm","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"alarm_control_panel","service":"","entityId":"alarm_control_panel.skynet_alarm","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1050,"y":2060,"wires":[[]]},{"id":"9852481d.1ff768","type":"trigger-state","z":"da78b56d.dbed78","name":"House Mode Change to Away","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_alarm_auto_set_on_depart"},{"property":"icon","value":"mdi:bell-alert"}],"entityid":"input_select.home_status","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"3d44rpl9gtf","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"Away"},{"id":"ii92sh06pgm","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"Away"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":190,"y":2060,"wires":[["a184e06b.38d66"],["c6f65598.2d25d8"]]},{"id":"955e1536.f7b648","type":"api-current-state","z":"da78b56d.dbed78","name":"Gypsy Home?","server":"a2277b3b.64d0f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.gypsy","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":true,"x":680,"y":2060,"wires":[["22c8f6e3.9e764a"]]},{"id":"c6f65598.2d25d8","type":"change","z":"da78b56d.dbed78","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2120,"wires":[["a184e06b.38d66"]]},{"id":"22c8f6e3.9e764a","type":"function","z":"da78b56d.dbed78","name":"Home/Away","func":"if (msg.payload) {\n msg.payload = { \"service\": \"alarm_arm_home\", \"service_name\": \"Armed Home\" };\n} else {\n msg.payload = { \"service\": \"alarm_arm_away\", \"service_name\": \"Armed Away\" }; \n}\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":2060,"wires":[["964ad036.7f04d","bad5c6be.1b59e8"]]},{"id":"bad5c6be.1b59e8","type":"template","z":"da78b56d.dbed78","name":"Notify Message","field":"notify_msg","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"title\": \"Alarm Armed\",\n \"message\": \"Nobody Home for more than 15 minutes without setting the alarm. Alarm has been set to {{payload.service_name}}.\",\n \"data\": {\n \"tag\": \"alarm-armed\"\n }\n}","output":"json","x":1060,"y":2120,"wires":[["13419317.a69d3d"]]},{"id":"13419317.a69d3d","type":"subflow:346290c3.fa274","z":"da78b56d.dbed78","name":"","env":[],"x":1230,"y":2120,"wires":[]},{"id":"c68ad2de.771ca","type":"ha-wait-until","z":"da78b56d.dbed78","name":"Nobody Home","server":"a2277b3b.64d0f8","outputs":2,"entityId":"input_boolean.nobody_home","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"10","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":660,"y":2280,"wires":[["890a8ab9.fa38b8"],["91d07dbd.0e33f"]]},{"id":"890a8ab9.fa38b8","type":"api-call-service","z":"da78b56d.dbed78","name":"Enable All Cameras","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.living_room_camera_enabled, switch.bedroom_camera_enabled","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":910,"y":2280,"wires":[[]]},{"id":"91d07dbd.0e33f","type":"api-call-service","z":"da78b56d.dbed78","name":"Enable Living Room Camera","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.living_room_camera_enabled","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":940,"y":2320,"wires":[[]]},{"id":"2e73846e.248abc","type":"api-call-service","z":"da78b56d.dbed78","name":"Disable All Cameras","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.living_room_camera_enabled, switch.bedroom_camera_enabled","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":920,"y":2400,"wires":[[]]},{"id":"7062972.4418c68","type":"comment","z":"da78b56d.dbed78","name":"Alarm & Camera Control","info":"","x":150,"y":2200,"wires":[]},{"id":"1b6a83b.c1fa27c","type":"trigger-state","z":"da78b56d.dbed78","name":"Proximity Detection Lindsay","server":"a2277b3b.64d0f8","exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"nr_proximity_detection_lindsay"},{"property":"icon","value":"mdi:compass"}],"entityid":"proximity.lindsay_home","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"3ssdmhhv08o","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"num","x":180,"y":1900,"wires":[["77ba705f.cb454"],[]]},{"id":"e677de6b.2c814","type":"subflow:cf4c09c8.62a618","z":"da78b56d.dbed78","name":"","env":[],"x":410,"y":1840,"wires":[["e09bc347.0799e"],["d64fc81f.0333b8"]]},{"id":"77ba705f.cb454","type":"subflow:cf4c09c8.62a618","z":"da78b56d.dbed78","name":"","env":[],"x":410,"y":1900,"wires":[["e09bc347.0799e"],["d64fc81f.0333b8"]]},{"id":"c518325d.e12ba","type":"api-current-state","z":"da78b56d.dbed78","name":"Linday's Not Home?","server":"a2277b3b.64d0f8","version":1,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"person.lindsay","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":1440,"y":1780,"wires":[["197d1678.b34fda"],[]]},{"id":"c0bdb88f.55e578","type":"function","z":"da78b56d.dbed78","name":"Get Person Home","func":"function is_home(entity) {\n return entity.state === \"home\";\n}\n\nentity = msg.payload.filter(is_home)[0].entity_id;\nmsg.data = { \"entity_id\": entity };\nreturn msg;","outputs":1,"noerr":0,"x":1170,"y":180,"wires":[["dd74d995.819608"]]},{"id":"835eadc6.1dd2c","type":"trigger-state","z":"da78b56d.dbed78","name":"Tim Status","server":"a2277b3b.64d0f8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"person.tim","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"xgvucav759","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"}],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"tnrz984o7dd","messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"home"},{"outputId":"p86uftktd2a","messageType":"payload","messageValue":"not_home","messageValueType":"str","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is_not","comparatorValue":"home"}],"outputinitially":false,"state_type":"str","x":150,"y":820,"wires":[[],[],["c1b7d05c.63aa3"],["c1b7d05c.63aa3"]]},{"id":"301aa4be.15bdcc","type":"state-machine","z":"da78b56d.dbed78","name":"Bed Status","triggerProperty":"payload","triggerPropertyType":"msg","stateProperty":"payload","statePropertyType":"msg","outputStateChangeOnly":true,"throwException":false,"states":["Empty","Someone Entered","All Entered","Goodnight Mode","All in Bed","Someone Got Up","All Got Up","Good Morning Mode"],"transitions":[{"name":"1 of 1","from":"Empty","to":"All Entered"},{"name":"1 of 2","from":"Empty","to":"Someone Entered"},{"name":"2 of 2","from":"Someone Entered","to":"All Entered"},{"name":"2 of 2","from":"Empty","to":"All Entered"},{"name":"1 of 2","from":"All Entered","to":"Someone Entered"},{"name":"0 of 1","from":"All Entered","to":"Empty"},{"name":"0 of 2","from":"All Entered","to":"Empty"},{"name":"timeout","from":"All Entered","to":"Goodnight Mode"},{"name":"complete","from":"Goodnight Mode","to":"All in Bed"},{"name":"1 of 2","from":"All in Bed","to":"Someone Got Up"},{"name":"2 of 2","from":"Someone Got Up","to":"All in Bed"},{"name":"0 of 1","from":"All in Bed","to":"All Got Up"},{"name":"1 of 1","from":"All Got Up","to":"All in Bed"},{"name":"0 of 2","from":"All in Bed","to":"All Got Up"},{"name":"0 of 2","from":"Someone Got Up","to":"All Got Up"},{"name":"timeout","from":"All Got Up","to":"Good Morning Mode"},{"name":"complete","from":"Good Morning Mode","to":"Empty"},{"name":"reset","from":"*","to":"Empty"}],"x":700,"y":1200,"wires":[["3d793d66.9d3602","3172ae7e.c29e32"]]},{"id":"47222279.fda10c","type":"change","z":"da78b56d.dbed78","name":"Trigger","rules":[{"t":"set","p":"payload","pt":"msg","to":"$string(payload) & \" of \" & $string(people_home)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1200,"wires":[["301aa4be.15bdcc"]]},{"id":"3d793d66.9d3602","type":"switch","z":"da78b56d.dbed78","name":"State?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Empty","vt":"str"},{"t":"eq","v":"Someone Entered","vt":"str"},{"t":"eq","v":"All in Bed","vt":"str"},{"t":"eq","v":"Someone Got Up","vt":"str"},{"t":"eq","v":"All Entered","vt":"str"},{"t":"eq","v":"Goodnight Mode","vt":"str"},{"t":"eq","v":"All Got Up","vt":"str"},{"t":"eq","v":"Good Morning Mode","vt":"str"}],"checkall":"false","repair":false,"outputs":8,"x":860,"y":1200,"wires":[["9c2e797d.6e5f68"],["9c2e797d.6e5f68"],["9c2e797d.6e5f68"],["9c2e797d.6e5f68"],["a739ad0.b406c5"],["e869143a.29ade8"],["ae3ffd2a.851f6"],["7667eb77.ba4914"]]},{"id":"f0bdeac5.2013b8","type":"link in","z":"da78b56d.dbed78","name":"Bed Status State Machine","links":["9d117bd2.d99e78","8700591a.a8b8e8","698dfc73.26ea64","c3f6e989.f23018","7dfaa7e7.b333c8","2983e1f4.3a449e"],"x":570,"y":1160,"wires":[["301aa4be.15bdcc"]]},{"id":"a739ad0.b406c5","type":"time-range-switch","z":"da78b56d.dbed78","name":"Night Time?","lat":"29.80495","lon":"-95.42369","startTime":"21:00","endTime":"05:00","startOffset":0,"endOffset":0,"x":1040,"y":1180,"wires":[["d2a5c5a6.d41928"],[]]},{"id":"ae3ffd2a.851f6","type":"time-range-switch","z":"da78b56d.dbed78","name":"Morning Time?","lat":"29.80495","lon":"-95.42369","startTime":"04:00","endTime":"12:00","startOffset":0,"endOffset":0,"x":1050,"y":1260,"wires":[["d2a5c5a6.d41928"],["7bbfbda9.59d9d4"]]},{"id":"5e205a22.96b3e4","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":540,"y":1240,"wires":[["301aa4be.15bdcc"]]},{"id":"795b1535.b0555c","type":"comment","z":"da78b56d.dbed78","name":"Good Morning Mode","info":"","x":1110,"y":1300,"wires":[]},{"id":"ef264973.851278","type":"link in","z":"da78b56d.dbed78","name":"House Occupancy State Machine","links":["8b5409a3.b62cb8","318c9016.bd723"],"x":235,"y":1420,"wires":[["8d1a9a0b.114898"]]},{"id":"f74cb5a9.59eaa8","type":"api-call-service","z":"da78b56d.dbed78","name":"Start Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.lindsay_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1190,"y":500,"wires":[[]]},{"id":"eb28f007.3b281","type":"change","z":"da78b56d.dbed78","name":"10 min","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"00:10:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":500,"wires":[["5308a4b4.7e611c"]]},{"id":"4e9e5bb9.aa6794","type":"change","z":"da78b56d.dbed78","name":"24 hr","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"24:00:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":540,"wires":[["5308a4b4.7e611c"]]},{"id":"fa5662fd.2e8a4","type":"api-call-service","z":"da78b56d.dbed78","name":"Cancel Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"cancel","entityId":"timer.lindsay_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":730,"y":660,"wires":[[]]},{"id":"23601ad7.2bab06","type":"link in","z":"da78b56d.dbed78","name":"Lindsay Status Machine","links":["5bb60ae7.4f5e94"],"x":75,"y":520,"wires":[["7d60efd6.76b3c"]]},{"id":"5bb60ae7.4f5e94","type":"link out","z":"da78b56d.dbed78","name":"Lindsay Status Timer Finished","links":["23601ad7.2bab06","758c8ff4.a331b","997e1ad3.d2cd88"],"x":515,"y":2920,"wires":[]},{"id":"7d60efd6.76b3c","type":"change","z":"da78b56d.dbed78","name":"Timer Finished","rules":[{"t":"set","p":"payload","pt":"msg","to":"Timeout","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":520,"wires":[["1ad696c.f301569"]]},{"id":"92d309e6.0e06d8","type":"switch","z":"da78b56d.dbed78","name":"Status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Arrived","vt":"str"},{"t":"eq","v":"Departed","vt":"str"},{"t":"eq","v":"Away","vt":"str"},{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Extended Away","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":710,"y":860,"wires":[["589c6769.ab99f8"],["589c6769.ab99f8"],["71b0e8d.5604418"],[],[]]},{"id":"292baad7.d53206","type":"api-call-service","z":"da78b56d.dbed78","name":"Start Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.tim_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1190,"y":820,"wires":[[]]},{"id":"b401be82.dc293","type":"api-call-service","z":"da78b56d.dbed78","name":"Cancel Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"cancel","entityId":"timer.tim_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":730,"y":980,"wires":[[]]},{"id":"a61ca0a8.70c25","type":"change","z":"da78b56d.dbed78","name":"Timer Finished","rules":[{"t":"set","p":"payload","pt":"msg","to":"Timeout","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":900,"wires":[["c1b7d05c.63aa3"]]},{"id":"bf74ea3e.178a38","type":"link in","z":"da78b56d.dbed78","name":"Tim Status Machine","links":["59b65a78.25b5c4","722d87c4.1eb788"],"x":75,"y":900,"wires":[["a61ca0a8.70c25"]]},{"id":"59b65a78.25b5c4","type":"link out","z":"da78b56d.dbed78","name":"Tim Status Timer Finished","links":["bf74ea3e.178a38","9493eb58.a3e5f8"],"x":515,"y":2960,"wires":[]},{"id":"3d8e2bdc.df3004","type":"api-call-service","z":"da78b56d.dbed78","name":"Cancel Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"cancel","entityId":"timer.house_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":1660,"wires":[[]]},{"id":"fe45ab0a.f55018","type":"change","z":"da78b56d.dbed78","name":"10 min","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"00:10:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":1480,"wires":[["b7bb91bb.61299"]]},{"id":"21a5e333.83219c","type":"api-call-service","z":"da78b56d.dbed78","name":"Start Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.house_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1190,"y":1480,"wires":[[]]},{"id":"49567517.1569fc","type":"change","z":"da78b56d.dbed78","name":"Timer Finished","rules":[{"t":"set","p":"payload","pt":"msg","to":"Timeout","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":3000,"wires":[["318c9016.bd723"]]},{"id":"318c9016.bd723","type":"link out","z":"da78b56d.dbed78","name":"House Status Timer Finished","links":["ef264973.851278"],"x":695,"y":3000,"wires":[]},{"id":"745c3a4d.f8ca94","type":"comment","z":"da78b56d.dbed78","name":"Timer Finishing Events","info":"","x":140,"y":2840,"wires":[]},{"id":"ee954b17.f0bbb8","type":"link out","z":"da78b56d.dbed78","name":"HVAC Timer Finished","links":["c010cde1.36392"],"x":515,"y":2880,"wires":[]},{"id":"c010cde1.36392","type":"link in","z":"da78b56d.dbed78","name":"HVAC Away Mode","links":["ee954b17.f0bbb8"],"x":215,"y":2740,"wires":[["e9fd956c.114ab8"]]},{"id":"9c2e797d.6e5f68","type":"api-call-service","z":"da78b56d.dbed78","name":"Cancel Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"cancel","entityId":"timer.bed_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1040,"y":1120,"wires":[[]]},{"id":"9e29d6ff.ea4958","type":"api-call-service","z":"da78b56d.dbed78","name":"Reset HVAC Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"cancel","entityId":"timer.hvac_timeout","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":350,"y":2640,"wires":[[]]},{"id":"a1ac186c.cc00e8","type":"comment","z":"da78b56d.dbed78","name":"Arrived / Returning","info":"","x":930,"y":1660,"wires":[]},{"id":"31aa0dda.0b5b12","type":"api-call-service","z":"da78b56d.dbed78","name":"Start Timer","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.bed_status","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1420,"y":1120,"wires":[[]]},{"id":"826d8928.ce65b8","type":"change","z":"da78b56d.dbed78","name":"Timer Finished","rules":[{"t":"set","p":"payload","pt":"msg","to":"timeout","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":3040,"wires":[["8700591a.a8b8e8"]]},{"id":"8700591a.a8b8e8","type":"link out","z":"da78b56d.dbed78","name":"Bed Status Timer Finished","links":["f0bdeac5.2013b8"],"x":695,"y":3040,"wires":[]},{"id":"a234bbe9.834bd8","type":"link in","z":"da78b56d.dbed78","name":"Bed Goodnight Mode","links":["e869143a.29ade8"],"x":95,"y":3160,"wires":[["f73a7a41.10b638"]]},{"id":"f73a7a41.10b638","type":"change","z":"da78b56d.dbed78","name":"complete","rules":[{"t":"set","p":"payload","pt":"msg","to":"complete","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":3160,"wires":[["698dfc73.26ea64"]]},{"id":"698dfc73.26ea64","type":"link out","z":"da78b56d.dbed78","name":"Bed Goodnight Mode Finished","links":["f0bdeac5.2013b8"],"x":315,"y":3160,"wires":[]},{"id":"e869143a.29ade8","type":"link out","z":"da78b56d.dbed78","name":"Start Goodnight Mode","links":["a234bbe9.834bd8","6c6a4fd1.e5ba4"],"x":985,"y":1220,"wires":[]},{"id":"7667eb77.ba4914","type":"link out","z":"da78b56d.dbed78","name":"Start Good Morning Mode","links":["a5c4db73.d19018"],"x":985,"y":1300,"wires":[]},{"id":"22eb0410.6c55cc","type":"comment","z":"da78b56d.dbed78","name":"Goodnight Mode","info":"","x":1100,"y":1220,"wires":[]},{"id":"bc582252.5ae6","type":"change","z":"da78b56d.dbed78","name":"complete","rules":[{"t":"set","p":"payload","pt":"msg","to":"complete","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":3280,"wires":[["2983e1f4.3a449e"]]},{"id":"2983e1f4.3a449e","type":"link out","z":"da78b56d.dbed78","name":"Bed Good Morning Mode Finished","links":["f0bdeac5.2013b8"],"x":315,"y":3280,"wires":[]},{"id":"cd447c5a.2a698","type":"delay","z":"da78b56d.dbed78","name":"","pauseType":"delay","timeout":"1000","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1020,"y":820,"wires":[["292baad7.d53206"]]},{"id":"5308a4b4.7e611c","type":"delay","z":"da78b56d.dbed78","name":"","pauseType":"delay","timeout":"1000","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1020,"y":500,"wires":[["f74cb5a9.59eaa8"]]},{"id":"b7bb91bb.61299","type":"delay","z":"da78b56d.dbed78","name":"","pauseType":"delay","timeout":"750","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1030,"y":1480,"wires":[["21a5e333.83219c"]]},{"id":"589c6769.ab99f8","type":"change","z":"da78b56d.dbed78","name":"10 min","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"00:10:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":820,"wires":[["cd447c5a.2a698"]]},{"id":"71b0e8d.5604418","type":"change","z":"da78b56d.dbed78","name":"24 hr","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"24:00:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":860,"wires":[["cd447c5a.2a698"]]},{"id":"d887aa5.10f0858","type":"change","z":"da78b56d.dbed78","name":"24 hr","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"24:00:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":1520,"wires":[["b7bb91bb.61299"]]},{"id":"7bbfbda9.59d9d4","type":"change","z":"da78b56d.dbed78","name":"10 min","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"00:10:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":1260,"wires":[["31aa0dda.0b5b12"]]},{"id":"d2a5c5a6.d41928","type":"change","z":"da78b56d.dbed78","name":"2 min","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"duration\":\"00:02:00\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":1120,"wires":[["31aa0dda.0b5b12"]]},{"id":"3172ae7e.c29e32","type":"ha-entity","z":"da78b56d.dbed78","name":"Bed Status","server":"a2277b3b.64d0f8","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_bed_status"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:hotel"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","x":850,"y":1280,"wires":[[]]},{"id":"ffd6d2b5.3dde7","type":"api-current-state","z":"da78b56d.dbed78","name":"Reset","server":"a2277b3b.64d0f8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.people_in_bed","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":290,"y":1260,"wires":[["2eab2f0b.c2814"]]},{"id":"3673be89.78b692","type":"inject","z":"da78b56d.dbed78","name":"","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1260,"wires":[["ffd6d2b5.3dde7"]]},{"id":"a2277b3b.64d0f8","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"5a6617e5.87dae8","type":"isy-controller","z":"","name":"ISY","ip":"192.168.10.18","useHttps":false}]
#################################################################
# #
# Presence Detection #
# #
#################################################################
---
# homeassistant:
# customize:
input_boolean:
guests:
name: Guest Mode
icon: mdi:account-group
gypsy:
name: Gypsy Home
icon: mdi:dog
vacation:
name: Vacation Mode
icon: mdi:airplane-takeoff
all_home:
name: All Home
icon: mdi:account-multiple
someone_home:
name: Someone Home
icon: mdi:account-multiple-outline
nobody_home:
name: Nobody Home
icon: mdi:account-off
# mdi:account-off-outline
garage_occupancy:
name: Garage Occupancy
icon: mdi:garage
# Alternate: mdi:garage-alert
first_floor_occupancy:
name: 1st Floor Occupancy
icon: mdi:home-floor-1
second_floor_occupancy:
name: 2nd Floor Occupancy
icon: mdi:home-floor-2
master_bed_occupancy:
name: Master Bed Occupancy
icon: mdi:hotel
master_bath_occupancy:
name: Master Bath Occupancy
icon: mdi:shower
input_select:
home_status:
name: House Occupancy Mode
icon: mdi:home-account
options:
- Home
- Departed
- Away
- Arrived
- Returning
- Extended Away
tim_location:
name: "Tim Location"
options:
- Home
- Departed
- Away
- Work
- Arrived
- Extended Away
lindsay_location:
name: "Lindsay Location"
options:
- Home
- Departed
- Away
- Work
- Arrived
- Extended Away
last_one_home:
name: Last Person Home
options:
- tim
- lindsay
- both
binary_sensor:
- platform: mqtt
name: "Bookcase BT Monitor"
state_topic: "btmonitor/bookcase/status"
payload_on: "online"
payload_off: "offline"
device_class: "connectivity"
- platform: mqtt
name: "OctoPi BT Monitor"
state_topic: "btmonitor/octopi/status"
payload_on: "online"
payload_off: "offline"
device_class: "connectivity"
- platform: mqtt
name: "Lithium BT Monitor"
state_topic: "btmonitor/lithium/status"
payload_on: "online"
payload_off: "offline"
device_class: "connectivity"
- platform: mqtt
name: "MagicMirror BT Monitor"
state_topic: "btmonitor/magicmirror/status"
payload_on: "online"
payload_off: "offline"
device_class: "connectivity"
sensor:
- platform: mqtt
state_topic: "skynet/home_status/delay"
name: House Mode Delay Timer
- platform: mqtt
state_topic: "skynet/garage/open_since"
name: Garage Door Left Open
- platform: template
sensors:
people_in_bed:
friendly_name: "People In Bed"
value_template: >-
{% if states('sensor.bed_sensor_raw_weight') | float < 250.0 %}
0
{% elif states('sensor.bed_sensor_raw_weight') | float < 357.0 %}
1
{% else %}
2
{% endif %}
timer:
hvac_timeout:
name: HVAC Timeout
duration: "00:50:00"
lindsay_status:
duration: '00:10:00'
tim_status:
duration: '00:10:00'
house_status:
duration: '00:10:00'
bed_status:
duration: '00:02:00'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment