Hello everyone, I have been learning NodeRed these past few weeks and my first project is to determine my house “status” depending on the time of the day AND whether or not we are home. I am defining 4 different “status” modes : Day, Evening, Bedtime and Away. I figure that a lot of my home automations can stem from those 4 statuses. For example whether lights are on or off, alarms and cameras on or off, etc…so I want to get this right.
So I started with 4 Input booleans for the Status, plus an additional one depending if the house is empty or one of us is at home. I use Life360 as the tracker to determine this portion.
I want to be able to toggle these Status(es) based on time of the day AND based on presence. Plus I want to be able to toggle them manually as well (for example toggle Bedtime when we actually go to bed as opposed to a set time of the evening -11PM in my automation-).
My flow is pasted below. I am a beginner and therefore hope that I can get some constructive ideas on how to make it better (it is working though) and perhaps it can also help a fellow beginner that would want to get started on the same.
Thanks !
[{"id":"5f937561.f25ebc","type":"tab","label":"Home status","disabled":false,"info":""},{"id":"bdae643f.ae50c8","type":"api-call-service","z":"5f937561.f25ebc","name":"Set status to Away","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.house_away","data":"{ \"entity_id\": \"input_boolean.house_away\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":870,"y":660,"wires":[["45bb5a5f.c39834","9824dc47.49b27"]]},{"id":"45bb5a5f.c39834","type":"api-call-service","z":"5f937561.f25ebc","name":"Day to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_day","data":"{ \"entity_id\": \"input_boolean.house_day\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1140,"y":680,"wires":[[]]},{"id":"9824dc47.49b27","type":"api-call-service","z":"5f937561.f25ebc","name":"Bedtime to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_night","data":"{ \"entity_id\": \"input_boolean.house_night\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1160,"y":800,"wires":[[]]},{"id":"7a5e1418.069b0c","type":"comment","z":"5f937561.f25ebc","name":"Set Home Status","info":"","x":80,"y":40,"wires":[]},{"id":"62c713fb.3a652c","type":"bigtimer","z":"5f937561.f25ebc","outtopic":"","outpayload1":"ON","outpayload2":"OFF","name":"5:30AM-Sunset Timer","comment":"","lat":"37.1135","lon":"-121.992","starttime":"330","endtime":"5004","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"ON","outtext2":"OFF","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":false,"odd":false,"even":false,"x":140,"y":140,"wires":[["419699db.c08128"],[],[]]},{"id":"419699db.c08128","type":"switch","z":"5f937561.f25ebc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":140,"wires":[["72e90d12.816444"],["6b137983.945628"]]},{"id":"b6beb32c.2792b","type":"api-call-service","z":"5f937561.f25ebc","name":"Normal Day to On","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.house_day","data":"{ \"entity_id\": \"input_boolean.house_day\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":870,"y":140,"wires":[["1cc8ddde.031232","56c0425.1d1b9bc","ac1e8b4f.578c78"]]},{"id":"e0f5762f.d95948","type":"api-call-service","z":"5f937561.f25ebc","name":"Bedtime to On","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.house_night","data":"{ \"entity_id\": \"input_boolean.house_night\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":860,"y":480,"wires":[["ed84e20.a840f2","5f04d2ed.4db88c","20da7ee2.ecbb52"]]},{"id":"528e21da.dfda8","type":"server-state-changed","z":"5f937561.f25ebc","name":"Carole Home","server":"26d3779.c1c8688","version":1,"entityidfilter":"device_tracker.life360_carole","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":110,"y":480,"wires":[[],["a7974f94.50702"]]},{"id":"e33c6a0b.561368","type":"server-state-changed","z":"5f937561.f25ebc","name":"Mario Home","server":"26d3779.c1c8688","version":1,"entityidfilter":"device_tracker.life360_mario_viamin","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":110,"y":540,"wires":[[],["a7974f94.50702"]]},{"id":"6af47b72.75b244","type":"server-state-changed","z":"5f937561.f25ebc","name":"Nick Home","server":"26d3779.c1c8688","version":1,"entityidfilter":"device_tracker.life360_nicolas_viamin","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":100,"y":600,"wires":[[],["a7974f94.50702"]]},{"id":"30824f73.63b39","type":"server-state-changed","z":"5f937561.f25ebc","name":"Lalou Home","server":"26d3779.c1c8688","version":1,"entityidfilter":"device_tracker.life360_alexandra_viamin","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":110,"y":660,"wires":[[],["a7974f94.50702"]]},{"id":"769dd45a.60fcfc","type":"server-state-changed","z":"5f937561.f25ebc","name":"Vic Home","server":"26d3779.c1c8688","version":1,"entityidfilter":"device_tracker.life360_victoria_viamin","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":100,"y":720,"wires":[[],["a7974f94.50702"]]},{"id":"c7bf82f1.68751","type":"comment","z":"5f937561.f25ebc","name":"Based on time","info":"","x":110,"y":100,"wires":[]},{"id":"ed84e20.a840f2","type":"api-call-service","z":"5f937561.f25ebc","name":"Normal Day to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_day","data":"{ \"entity_id\": \"input_boolean.house_day\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1170,"y":460,"wires":[[]]},{"id":"5f04d2ed.4db88c","type":"api-call-service","z":"5f937561.f25ebc","name":"Evening to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_evening","data":"{ \"entity_id\": \"input_boolean.house_evening\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1160,"y":520,"wires":[[]]},{"id":"20da7ee2.ecbb52","type":"api-call-service","z":"5f937561.f25ebc","name":"Away to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_away","data":"{ \"entity_id\": \"input_boolean.house_away\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1150,"y":580,"wires":[[]]},{"id":"1cc8ddde.031232","type":"api-call-service","z":"5f937561.f25ebc","name":"Night to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_night","data":"{ \"entity_id\": \"input_boolean.house_night\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1150,"y":20,"wires":[[]]},{"id":"56c0425.1d1b9bc","type":"api-call-service","z":"5f937561.f25ebc","name":"Evening to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_evening","data":"{ \"entity_id\": \"input_boolean.house_evening\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1160,"y":80,"wires":[[]]},{"id":"ac1e8b4f.578c78","type":"api-call-service","z":"5f937561.f25ebc","name":"Away to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_away","data":"{ \"entity_id\": \"input_boolean.house_away\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1150,"y":140,"wires":[[]]},{"id":"f0f998b9.7d77c8","type":"time-range-switch","z":"5f937561.f25ebc","name":"Between 5:30AM and 11PM","lat":"37.1135","lon":"-121.992","startTime":"5:30","endTime":"23:00","startOffset":0,"endOffset":0,"x":420,"y":700,"wires":[["b31bcc84.385d8"],["e0f5762f.d95948"]]},{"id":"74140a28.773fb4","type":"server-state-changed","z":"5f937561.f25ebc","name":"Bedtime is toggled on","server":"26d3779.c1c8688","version":1,"entityidfilter":"input_boolean.house_night","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":920,"y":560,"wires":[["ed84e20.a840f2","5f04d2ed.4db88c","20da7ee2.ecbb52"],[]]},{"id":"fde2f05b.90048","type":"server-state-changed","z":"5f937561.f25ebc","name":"Normal Day is toggled on","server":"26d3779.c1c8688","version":1,"entityidfilter":"input_boolean.house_day","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":930,"y":200,"wires":[["1cc8ddde.031232","56c0425.1d1b9bc","ac1e8b4f.578c78"],[]]},{"id":"19aeb4aa.47ae5b","type":"api-call-service","z":"5f937561.f25ebc","name":"Evening to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_evening","data":"{ \"entity_id\": \"input_boolean.house_evening\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1160,"y":740,"wires":[[]]},{"id":"b31bcc84.385d8","type":"time-range-switch","z":"5f937561.f25ebc","name":"Between 5:30AM and sunset","lat":"37.1135","lon":"-121.992","startTime":"5:30","endTime":"sunset","startOffset":0,"endOffset":0,"x":440,"y":540,"wires":[["b6beb32c.2792b"],["859aef2d.ab775"]]},{"id":"859aef2d.ab775","type":"api-call-service","z":"5f937561.f25ebc","name":"Evening to On","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.house_evening","data":"{ \"entity_id\": \"input_boolean.house_evening\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":860,"y":300,"wires":[["e4f4194c.cda8f8","d612a037.1aaae","9a40eb51.b255e8"]]},{"id":"6b137983.945628","type":"bigtimer","z":"5f937561.f25ebc","outtopic":"","outpayload1":"ON","outpayload2":"OFF","name":"Sunset-11PM Timer","comment":"","lat":"37.1135","lon":"-121.992","starttime":"5004","endtime":"1380","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"ON","outtext2":"OFF","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":false,"odd":false,"even":false,"x":190,"y":260,"wires":[["299e8137.26bf0e"],[],[]]},{"id":"299e8137.26bf0e","type":"switch","z":"5f937561.f25ebc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":340,"wires":[["71957424.d00dbc"],["4359adc8.410a94"]]},{"id":"e4f4194c.cda8f8","type":"api-call-service","z":"5f937561.f25ebc","name":"Normal Day to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_day","data":"{ \"entity_id\": \"input_boolean.house_day\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1170,"y":260,"wires":[[]]},{"id":"d612a037.1aaae","type":"api-call-service","z":"5f937561.f25ebc","name":"Night to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_night","data":"{ \"entity_id\": \"input_boolean.house_night\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1150,"y":320,"wires":[[]]},{"id":"9a40eb51.b255e8","type":"api-call-service","z":"5f937561.f25ebc","name":"Away to Off","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_away","data":"{ \"entity_id\": \"input_boolean.house_away\" }","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"flow","mustacheAltTags":false,"x":1150,"y":380,"wires":[[]]},{"id":"98da7fa9.774b","type":"server-state-changed","z":"5f937561.f25ebc","name":"Evening is toggled on","server":"26d3779.c1c8688","version":1,"entityidfilter":"input_boolean.house_evening","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":920,"y":360,"wires":[["9a40eb51.b255e8","d612a037.1aaae","e4f4194c.cda8f8"],[]]},{"id":"616fdb21.183f94","type":"server-state-changed","z":"5f937561.f25ebc","name":"Away is toggled on","server":"26d3779.c1c8688","version":1,"entityidfilter":"input_boolean.house_away","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":910,"y":740,"wires":[["45bb5a5f.c39834","19aeb4aa.47ae5b","9824dc47.49b27"],[]]},{"id":"a7974f94.50702","type":"ha-get-entities","z":"5f937561.f25ebc","server":"26d3779.c1c8688","name":"How many are home ?","rules":[{"property":"entity_id","logic":"is","value":"device_tracker.life360_*","valueType":"re"},{"property":"state","logic":"is","value":"home","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":340,"y":880,"wires":[["7b5ac19c.b12af"]]},{"id":"7b5ac19c.b12af","type":"switch","z":"5f937561.f25ebc","name":"Someone in","property":"payload","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":880,"wires":[["9f5a64a8.086038"],["540b3fb.77ba1c","bdae643f.ae50c8"]]},{"id":"b50f5b7c.a47158","type":"inject","z":"5f937561.f25ebc","name":"ON","topic":"msg.payload","payload":"True","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":980,"wires":[["a7974f94.50702"]]},{"id":"540b3fb.77ba1c","type":"api-call-service","z":"5f937561.f25ebc","name":"Turn On House Empty","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.house_empty","data":"{ \"entity_id\" : \"input_boolean.house_empty\" }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":882,"y":882,"wires":[[]]},{"id":"9f5a64a8.086038","type":"api-call-service","z":"5f937561.f25ebc","name":"Turn Off House Empty","server":"26d3779.c1c8688","version":1,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.house_empty","data":"{ \"entity_id\" : \"input_boolean.house_empty\" }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":500,"y":800,"wires":[["f0f998b9.7d77c8"]]},{"id":"72e90d12.816444","type":"api-current-state","z":"5f937561.f25ebc","name":"House is not empty","server":"26d3779.c1c8688","version":1,"outputs":2,"halt_if":"false","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.house_empty","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":100,"wires":[["b6beb32c.2792b"],["bdae643f.ae50c8"]]},{"id":"71957424.d00dbc","type":"api-current-state","z":"5f937561.f25ebc","name":"House is not empty","server":"26d3779.c1c8688","version":1,"outputs":2,"halt_if":"false","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.house_empty","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":240,"wires":[["859aef2d.ab775"],["bdae643f.ae50c8"]]},{"id":"4359adc8.410a94","type":"api-current-state","z":"5f937561.f25ebc","name":"House is not empty","server":"26d3779.c1c8688","version":1,"outputs":2,"halt_if":"false","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.house_empty","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":590,"y":380,"wires":[["e0f5762f.d95948"],["bdae643f.ae50c8"]]},{"id":"2e4f0991.ee6186","type":"comment","z":"5f937561.f25ebc","name":"Based on Presence","info":"","x":110,"y":420,"wires":[]},{"id":"26d3779.c1c8688","type":"server","z":"","name":"Home Assistant"}]