Require password to wake computer by specific condition
You can use ControlPlane:


Add a context named home from the contexts tab.
Enable the nearby WiFi network evidence source from the evidence sources tab.
Go to the rules tab and add a nearby WiFi network rule that sets the context to home.
Add two screen saver password actions from the actions tab:




Another option is to add a line like this to crontab:

* * * * * system_profiler SPAirPortDataType|grep -q 'network name'&amp;&amp;x=false||x=true;osascript -e 'tell application "System Events" to tell security preferences to set require password to wake to '$x