Using Sensors and Double Take to detect presence

Hello friends! I apologize if I created a duplicate topic or wrote the wrong one, but I need your help.
Help me write a complex automation system.
My task:
create a greeting automation when determining the identity. It seemed that everything was simple, but it’s not. I really want my smart home to identify me upon arrival at the house, using Double Take, MQTT, Frigate, Deep Stack. Then the greeting was automated. After that, the house, with the help of an installed component and a motion sensor (or door control), monitored my presence at home.
But if I leave the house and the system fails to detect me at the set time, the Home Assistant will forget about my presence. This is done so that after my return, the system will welcome me again.
P.S. The greeting can be replaced with any other automation.
My system:
Installed Home assistant on iCore 5 and connected CCTV cameras. Double Take, MQTT, Frigate, Deep Stack are installed. The system works, determines the identity.

I have little experience in programming, and I managed to write a simple automation. For example, upon my arrival, the Home Assistant recognizes me and makes a greeting.
How to make a permanent control? How do I make the Home Assistant understand when I left home? And do it all in one automation! Please tell me where you can get the necessary information or help me write automation. Thank you for any help!