Set and check variable in automation after delay

Hi there. I have a specific question for an automation and was not able to find an answer after quite a while of searching. I am a noob regarding HA and i am mostly still using the UI for creating automations.

I have HA setup with Espresense. Now i want to setup a notification when a specific device comes home. I can easily send a notification by creating an automation that is triggered when the status of this device changes from not_home. But unfortunately sometimes the status not_home is set because of a weak signal and the automation is triggered although the device never left. I thought of defining a variable after a period of time after the device left to catch this very short false negatives, but i have no clue how. Maybe someone can help me out?

Kind regards

Alright, i solved the problem without any variable and automations by just increasing the timeout for the not_home status in the mqtt config. Works for me.