Node-Red Vacation timer. Will this work?

I am trying to set up random on/off routines for 8 entities.
Will this work?
I want to start at 4:30PM and end at 11:45PM and have each entity turn on and off at randome times for random lengths of time

VACATION TIMER


ENTITY (all entities are set up the same way)

Did you ever get this to work? What did you do about presence?

No sorry, I never did

I have been using bigtimer nodes for this. Is this a custom timer node?

This is a custom one, yes. Bigtimer is fine, I use it for a ton of things, so I was just looking to simplify a little.

@Stavros, I did find an example that someone else had on reddit - was actually a pretty good idea/implementation https://www.reddit.com/r/homeassistant/comments/gp6z4k/informal_how_to_for_node_red_vacation_timer_with/

@Squishbutt … thanks! I’ll have a look and let you know how it goes

So I will admit, after working on this for a while and trying a few different things, I opted to not use the vacation-timer. I have 14 different lights/switches in the vacation group and each vacation-timer node is good for only one switch. Which means, each vacation-timer node has no knowledge of the other vacation-timer node. I’m not a fan of this, so I did something different.

One of my issues is that the majority of my lights are configured as switches. I also have an irrigation controller, pool, and robot vacuums that use the switch domain, so i had to get a little creative. Anyway, I think I manually created what many of these timers do. Here’s the code if you’re interested:

[{"id":"c0a5e30c.d128c","type":"tab","label":"Vacation Lighting","disabled":false,"info":""},{"id":"e150ca12.186e28","type":"function","z":"c0a5e30c.d128c","name":"Trigger 30% of the time","func":"const random = Math.round(Math.random() * 100);\n\nif(random < 70) {\n    node.status({fill: \"red\", text: random});\n    return null;\n}\nnode.status({fill: \"green\", text: random});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":360,"wires":[["c189c71b.e2bf78"]]},{"id":"c189c71b.e2bf78","type":"ha-get-entities","z":"c0a5e30c.d128c","server":"84a8d823.e15248","name":"Pick 2 random switches","rules":[{"property":"entity_id","logic":"starts_with","value":"switch.","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.ben_room_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.bush_sprinklers","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.cupboard_light_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.extra_aux","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.front_bushes","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.front_lawn","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.front_porch_light_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.kitchen_table_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.little_hall_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.mr_belvedere_schedule","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.new_program","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.new_program_2","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.north_lawn","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.patio_small_light_switch","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.pool_heater","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.pool_light","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.pool_pump","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.rosie_schedule","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.side_yard","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.solar_heater","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.spa_heater","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.spa_light","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.spa_pump","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.tree_sprinklers","valueType":"str"},{"property":"entity_id","logic":"is_not","value":"switch.waterfall","valueType":"str"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":"2","x":750,"y":360,"wires":[["43e41bab.227de4"]]},{"id":"154eb6fc.6b3ba9","type":"ha-get-entities","z":"c0a5e30c.d128c","server":"84a8d823.e15248","name":"Pick one random light","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":740,"y":420,"wires":[["3d2b8ac6.d6eb86"]]},{"id":"14ab8ca4.94b2c3","type":"function","z":"c0a5e30c.d128c","name":"Trigger 25% of the time","func":"const random = Math.round(Math.random() * 100);\n\nif(random < 75) {\n    node.status({fill: \"red\", text: random});\n    return null;\n}\nnode.status({fill: \"green\", text: random});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":420,"wires":[["154eb6fc.6b3ba9"]]},{"id":"9dd9ef0b.1e282","type":"delay","z":"c0a5e30c.d128c","name":"Switch random for \\n 26 to 51 mins","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"26","randomLast":"51","randomUnits":"minutes","drop":false,"x":1230,"y":340,"wires":[["3c0ac01b.0b23f"]]},{"id":"3c0ac01b.0b23f","type":"api-call-service","z":"c0a5e30c.d128c","name":"Turn off switch","server":"84a8d823.e15248","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"{{payload.0.entity_id}},{{payload.1.entity_id}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1440,"y":340,"wires":[[]]},{"id":"3d2b8ac6.d6eb86","type":"api-call-service","z":"c0a5e30c.d128c","name":"Turn on Light","server":"84a8d823.e15248","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"{{payload.entity_id}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":420,"wires":[["c0101aab.97e938"]]},{"id":"c0101aab.97e938","type":"delay","z":"c0a5e30c.d128c","name":"Light random for \\n 29 to 58 mins","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"29","randomLast":"58","randomUnits":"minutes","drop":false,"x":1220,"y":440,"wires":[["9ce9a531.d89e28"]]},{"id":"9ce9a531.d89e28","type":"api-call-service","z":"c0a5e30c.d128c","name":"Turn off light","server":"84a8d823.e15248","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"{{payload.entity_id}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1430,"y":440,"wires":[[]]},{"id":"43e41bab.227de4","type":"api-call-service","z":"c0a5e30c.d128c","name":"Turn on switch","server":"84a8d823.e15248","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"{{payload.0.entity_id}},{{payload.1.entity_id}}","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":360,"wires":[["9dd9ef0b.1e282"]]},{"id":"6b0a2f7f.d3c6b","type":"poll-state","z":"c0a5e30c.d128c","name":"Check every 10 mins \\n to see if we're home","server":"84a8d823.e15248","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"10","updateIntervalUnits":"minutes","outputinitially":false,"outputonchanged":false,"entity_id":"group.peeps","state_type":"str","halt_if":"not_home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"x":140,"y":160,"wires":[["ea0f3aa2.e69138"],[]]},{"id":"ea0f3aa2.e69138","type":"time-range-switch","z":"c0a5e30c.d128c","name":"It's between dusk and 2230","lat":"66.44322","lon":"-224.60464","startTime":"dusk","endTime":"22:30","startOffset":0,"endOffset":0,"x":280,"y":260,"wires":[["14ab8ca4.94b2c3","e150ca12.186e28"],[]]},{"id":"84a8d823.e15248","type":"server","z":"","name":"Home Assistant"}]

Imgur

I use presence-faker for turning on-off lights at random times for a random number of times.

My lighting automations are quite complex, so i use a statemachine to determine which one should be active:

In case the home is in vacation mode:

2 Likes

Dear devastator,
could you please paste your flow code here?
I am very interested in your solution.
Thank you