I did this with a Virtual Device called Alexa Guard using Universal Virtual Device Switch uDTH - good for Alexa, IFTTT, HSM, and other integrations device driver.
I then use Alexa Routines to turn on Guard when when the Virtual Switch is turned on. I then use Alexa Routine to have my Echo device say "Alexa... I'm Home." to turn off Alexa Guard. I use HSM to turn the Alexa Guard virtual switch On and Off.