Thanks for all your help @jimpower ! You’re a legend!
I tweaked your last one a bit to get it working 100%.
- I added a 5 second delay to the light boolean, because it was indeed turning on with the bottom sequence (like you said).
- I removed the motion boolean off from the lower sequence as it was turning this off, even when the trigger was the motion.
- Light switch halt entity is the Light boolean, not the switch directly.
- Removed “halt if state: off” from the Switch in the bottom sequence, as the off trigger wasn’t coming through.
- Removed the Switch turning itself On/off, as they are not needed.
Here is the final flow:
And for anyone wanting the code:
[{"id":"8cc2a8db.59dbd8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"4e5e6da3.8a75b4","type":"switch","z":"8cc2a8db.59dbd8","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":390,"y":310,"wires":[["4879bbf5.16eee4","f7475019.95049"],[]]},{"id":"f7475019.95049","type":"stoptimer","z":"8cc2a8db.59dbd8","duration":"10","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":610,"y":330,"wires":[["a62f7504.7f4858"],[]]},{"id":"66b47b7a.927ec4","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"OFF","server":"9582d396.920b1","service_domain":"switch","service":"turn_off","data":"{\"entity_id\": \"switch.plug_158d0001a68b97\"}","mergecontext":"","x":1260,"y":330,"wires":[[]]},{"id":"99136a52.8e2d48","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"ON","server":"9582d396.920b1","service_domain":"switch","service":"turn_on","data":"{\"entity_id\": \"switch.plug_158d0001a68b97\"}","mergecontext":"","x":1260,"y":250,"wires":[[]]},{"id":"a23777e1.4ac7f8","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Already On?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"switch.plug_158d0001a68b97","x":790,"y":270,"wires":[["99136a52.8e2d48","baf43cfa.8bb2e","b2321988.bc8fd8"]]},{"id":"eaa82eb5.ab02","type":"server-state-changed","z":"8cc2a8db.59dbd8","name":"Motion","server":"9582d396.920b1","entityidfilter":"binary_sensor.motion_sensor_158d00012cbb78","entityidfiltertype":"substring","haltifstate":"","x":190,"y":310,"wires":[["4e5e6da3.8a75b4"]]},{"id":"4879bbf5.16eee4","type":"time-range-switch","z":"8cc2a8db.59dbd8","name":"After Sunset?","lat":"-27.465328","lon":"153.024548","startTime":"sunsetStart","endTime":"sunrise","startOffset":"","endOffset":"","x":600,"y":270,"wires":[["a23777e1.4ac7f8"],[]]},{"id":"6e855221.f8275c","type":"server-state-changed","z":"8cc2a8db.59dbd8","name":"Light Switch","server":"9582d396.920b1","entityidfilter":"switch.plug_158d0001a68b97","entityidfiltertype":"exact","haltifstate":"","x":210,"y":440,"wires":[["4ca49a29.1b1c64"]]},{"id":"a62f7504.7f4858","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Still Motion?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"binary_sensor.motion_sensor_158d00012cbb78","x":790,"y":330,"wires":[["871057b4.0715d8"]]},{"id":"4ca49a29.1b1c64","type":"switch","z":"8cc2a8db.59dbd8","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":390,"y":440,"wires":[["a328cea1.dca05"],["64c9a1fc.198f6"]]},{"id":"871057b4.0715d8","type":"api-current-state","z":"8cc2a8db.59dbd8","name":"Light on from Switch?","server":"9582d396.920b1","halt_if":"on","override_topic":true,"override_payload":true,"entity_id":"input_boolean.light_manual","x":980,"y":330,"wires":[["66b47b7a.927ec4","496b28b6.375aa8"]]},{"id":"baf43cfa.8bb2e","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Motion On","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\": \"input_boolean.light_auto\"}","mergecontext":"","x":1220,"y":210,"wires":[[]]},{"id":"496b28b6.375aa8","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Motion Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\": \"input_boolean.light_auto\"}","mergecontext":"","x":1220,"y":290,"wires":[[]]},{"id":"a328cea1.dca05","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light On","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_on","data":"{\"entity_id\": \"input_boolean.light_manual\"}","mergecontext":"","x":610,"y":420,"wires":[[]]},{"id":"64c9a1fc.198f6","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\":\"input_boolean.light_manual\"}","mergecontext":"","x":610,"y":460,"wires":[[]]},{"id":"de84c6e8.e8dc08","type":"api-call-service","z":"8cc2a8db.59dbd8","name":"Boolean Light Off","server":"9582d396.920b1","service_domain":"input_boolean","service":"turn_off","data":"{\"entity_id\": \"input_boolean.light_manual\"}","mergecontext":"","x":1220,"y":170,"wires":[[]]},{"id":"b2321988.bc8fd8","type":"delay","z":"8cc2a8db.59dbd8","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":170,"wires":[["de84c6e8.e8dc08"]]}]