Not tested but might give you some ideas.
[{"id":"de366a74.117718","type":"ha-get-entities","z":"d172fd28.b50b3","server":"","name":"contacts","rules":[{"property":"entity_id","logic":"includes","value":"binary_sensor.door_back_contact, binary_sensor.door_front_contact, binary_sensor.door_garage_contact, binary_sensor.door_mailbox_contact","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"contacts","output_results_count":1,"x":284,"y":512,"wires":[["5cd957b0.532e28"]]},{"id":"5cd957b0.532e28","type":"api-current-state","z":"d172fd28.b50b3","name":"door status","server":"","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.door_front_contact","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":454,"y":512,"wires":[["9b92059.ee365f8"],["17fa7cb7.854d23"]]},{"id":"9b92059.ee365f8","type":"api-call-service","z":"d172fd28.b50b3","name":"Lock Door","server":"","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.front_door","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":464,"wires":[["a10d44e4.867d38"]]},{"id":"17fa7cb7.854d23","type":"function","z":"d172fd28.b50b3","name":"format","func":"let status;\nconst openDoors = msg.contacts.map(door => door.attributes.friend_name).join(\" ,\");\n\nif(msg.frontDoor.attributes.lock_state === \"locked\") {\n if(openDoors) {\n status = `Home locked, but the ${openDoors} are open.`;\n } else {\n status = \"Home Secured\"; \n }\n} else {\n status = `Home unlocked`;\n if(openDoors) {\n status = `${status} and the ${openDoors} are open`;\n }\n}\n\nmsg.payload = status;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":512,"wires":[["92b94630.92e118"]]},{"id":"63ff7e9.bf39d8","type":"inject","z":"d172fd28.b50b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":138,"y":512,"wires":[["de366a74.117718"]]},{"id":"a10d44e4.867d38","type":"ha-wait-until","z":"d172fd28.b50b3","name":"Wait for door to lock","server":"","outputs":2,"entityId":"lock.front_door","entityIdFilterType":"exact","property":"attributes.lock_state","comparator":"is_not","value":"unlocked","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"frontDoor","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":820,"y":464,"wires":[["17fa7cb7.854d23"],["17fa7cb7.854d23"]]},{"id":"92b94630.92e118","type":"debug","z":"d172fd28.b50b3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1158,"y":512,"wires":[]}]
without a function node
[{"id":"16cf4c8c.6f8133","type":"ha-get-entities","z":"d172fd28.b50b3","server":"","name":"contacts","rules":[{"property":"entity_id","logic":"includes","value":"binary_sensor.door_back_contact, binary_sensor.door_front_contact, binary_sensor.door_garage_contact, binary_sensor.door_mailbox_contact","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"contacts","output_results_count":1,"x":300,"y":720,"wires":[["1c95b4f0.f2d05b"]]},{"id":"1c95b4f0.f2d05b","type":"api-current-state","z":"d172fd28.b50b3","name":"door status","server":"","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.door_front_contact","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":486,"y":720,"wires":[["702744f5.8b4bfc"],["167451f2.e0665e"]]},{"id":"702744f5.8b4bfc","type":"api-call-service","z":"d172fd28.b50b3","name":"Lock Door","server":"","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.front_door","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":694,"y":720,"wires":[["40369aac.0d8a94"]]},{"id":"65b73412.a62d6c","type":"inject","z":"d172fd28.b50b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":122,"y":720,"wires":[["16cf4c8c.6f8133"]]},{"id":"40369aac.0d8a94","type":"ha-wait-until","z":"d172fd28.b50b3","name":"Wait for door to lock","server":"","outputs":2,"entityId":"lock.front_door","entityIdFilterType":"exact","property":"attributes.lock_state","comparator":"is_not","value":"unlocked","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"frontDoor","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":948,"y":720,"wires":[["167451f2.e0665e"],["167451f2.e0665e"]]},{"id":"76134262.52c20c","type":"template","z":"d172fd28.b50b3","name":"Format Friendly Name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":724,"y":768,"wires":[["de05ba8.d4d5548"]]},{"id":"de05ba8.d4d5548","type":"join","z":"d172fd28.b50b3","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":898,"y":768,"wires":[["7d2d900e.403ad"]]},{"id":"7d2d900e.403ad","type":"change","z":"d172fd28.b50b3","name":"door open msg","rules":[{"t":"set","p":"openDoors","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1056,"y":768,"wires":[["92b2957.f645168"]]},{"id":"167451f2.e0665e","type":"switch","z":"d172fd28.b50b3","name":"doors open?","property":"contacts.length","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":134,"y":768,"wires":[["37b80f05.b4449"],["f103cb09.3d1508"]]},{"id":"e7d6262a.c24358","type":"split","z":"d172fd28.b50b3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":466,"y":768,"wires":[["76134262.52c20c"]]},{"id":"92b2957.f645168","type":"switch","z":"d172fd28.b50b3","name":"door locked?","property":"frontDoor.attributes.lock_state","propertyType":"msg","rules":[{"t":"eq","v":"locked","vt":"str"},{"t":"eq","v":"unlocked","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":694,"y":816,"wires":[["e565c834.4b8e28"],["ac090d29.f2f34"]]},{"id":"37b80f05.b4449","type":"change","z":"d172fd28.b50b3","name":"to payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"contacts","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":768,"wires":[["e7d6262a.c24358"]]},{"id":"f103cb09.3d1508","type":"switch","z":"d172fd28.b50b3","name":"door locked?","property":"frontDoor.attributes.lock_state","propertyType":"msg","rules":[{"t":"eq","v":"locked","vt":"str"},{"t":"eq","v":"unlocked","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":816,"wires":[["f5a31293.e15e"],["ab19218.ec783e"]]},{"id":"f5a31293.e15e","type":"change","z":"d172fd28.b50b3","name":"Home Secured","rules":[{"t":"set","p":"payload","pt":"msg","to":"Home Secured","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":496,"y":816,"wires":[["749a3998.eea828"]]},{"id":"e565c834.4b8e28","type":"template","z":"d172fd28.b50b3","name":"Home locked with doors open","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Home locked, but the {{openDoors}} are open.","output":"str","x":930,"y":816,"wires":[["749a3998.eea828"]]},{"id":"ab19218.ec783e","type":"change","z":"d172fd28.b50b3","name":"Home Unlocked","rules":[{"t":"set","p":"payload","pt":"msg","to":"Home unlocked","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":496,"y":864,"wires":[["749a3998.eea828"]]},{"id":"ac090d29.f2f34","type":"template","z":"d172fd28.b50b3","name":"Home unlocked with doors open","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Home unlocked and the {{openDoors}} are open.","output":"str","x":930,"y":864,"wires":[["749a3998.eea828"]]},{"id":"749a3998.eea828","type":"debug","z":"d172fd28.b50b3","name":"do stuff","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1148,"y":912,"wires":[]}]