How to Set Up Fans to Turn Off When Leaving and Resume Upon Return

I’ve been exploring ways to optimize my smart home setup, and one feature I wanted to implement was having my fans turn off when I leave the house and automatically resume their previous settings when I return. After some research and experimentation, I figured out a reliable method using Home Assistant’s geofencing integration. Here’s how I did it and what I learned along the way!

First, I set up a geofence around my home using my phone’s location services. This allows Home Assistant to detect when I’m leaving or returning. Then, I created a rule in the automation editor that triggers when I exit the geofence. The rule records the current state and brightness level of each fan and then turns them off. When I return home, another rule kicks in, restoring the fans to their previous settings.

One challenge I faced was ensuring that the rule accurately captures the fan settings before turning them off. I discovered that using the input_number component to store the brightness levels worked perfectly. This way, the automation can reference these stored values when restoring the fans.

I also found that using the state attribute to track whether a fan was on or off before leaving was essential. This ensures that fans that were already off remain off, preventing any unintended behavior.

After setting this up, I tested it thoroughly by leaving and returning home multiple times. The automation worked flawlessly, and I was impressed by how seamless the transition was. My family noticed the convenience immediately, and it’s become a staple feature in our smart home setup.

If anyone has questions about implementing this or suggestions for improvement, I’d love to hear from you! Happy automating! :star2: