Smart Home Automation

Home Assistant Trigger Smart Plug

Home Automation Experts
6 min read

I’ve got a pretty sweet smart home setup, with over 200 devices connected to my Home Assistant hub. One of the features I use daily is automated lighting - it’s amazing how much of a difference it makes to walk into a room and have the lights turn on automatically. Recently, I decided to take it to the next level by configuring my system to trigger smart plug power-on only when a motion sensor detects movement and my smart lock is unlocked. It wasn’t as straightforward as I thought, but after some trial and error, I got it working seamlessly.

Configuring Home Assistant to Trigger Smart Plug Power-On with Motion Sensors

To get started, you’ll need to have a few devices set up in your Home Assistant system: a motion sensor (I’m using a Zigbee-based Philips Hue sensor), a smart plug (my favorite is the TP-Link HS110), and a smart lock (I’ve got a August Smart Lock Pro). The first step is to configure your motion sensor to trigger an automation in Home Assistant. I’ve found that the best way to do this is by using the “Device Trigger” feature, which allows you to specify exactly what device events should trigger your automation. For example, I’ve set my Philips Hue motion sensor to trigger an event whenever it detects movement - this event is then used to turn on my smart plug.

I’ve got two of these sensors set up in my home, one in the living room and one in the hallway, and they’re both configured to detect movement within a 5-meter radius. This means that whenever someone walks into either of these rooms, the sensor will detect their presence and trigger the automation. It’s pretty handy, especially when you’ve got your hands full - I’ve lost count of how many times I’ve walked into my living room with a tray of drinks or a plate of food, and had the lights turn on automatically.

Using Smart Locks to Enhance Home Assistant Trigger Smart Plug Power-On

The next step is to integrate your smart lock into the automation. This is where things get a bit more complex - you’ll need to configure your smart lock to provide a “locked” or “unlocked” state to Home Assistant, which can then be used as a condition for triggering your smart plug. I’ve found that the August Smart Lock Pro works really well with Home Assistant, and provides a reliable locked/unlocked state that I can use in my automations. For example, I’ve set up an automation that checks whether my front door is unlocked before turning on the lights - this means that if someone tries to trigger the motion sensor while the door is still locked, nothing will happen.

One thing to note here is that you’ll need to make sure your smart lock is configured correctly in Home Assistant. This involves adding the lock as a device, and then configuring it to provide the locked/unlocked state. I’ve found that this can be a bit fiddly, especially if you’re not familiar with the August Smart Lock Pro’s API - but once you’ve got it set up, it works like a charm. For instance, I’ve got my lock configured to update its state every 10 seconds, which means that Home Assistant always has an accurate picture of whether the door is locked or unlocked.

Combining Motion Sensors and Smart Locks to Trigger Smart Plug Power-On

Now that you’ve got your motion sensor and smart lock set up, it’s time to combine them into a single automation. This involves creating a new automation in Home Assistant that checks both the motion sensor’s state and the smart lock’s state before triggering the smart plug. I’ve found that the best way to do this is by using the “And” condition in Home Assistant’s automation editor - this allows you to specify multiple conditions that must all be true before the automation triggers.

For example, my automation checks whether the motion sensor has detected movement (using the “Device Trigger” feature) and whether the smart lock is unlocked (using the locked/unlocked state provided by the August Smart Lock Pro). If both of these conditions are true, then the automation triggers the smart plug to turn on. It’s a pretty simple setup, but it works really well - I’ve got my lights set up to turn on whenever I walk into a room and the front door is unlocked, which makes it feel like my home is really looking out for me.

Troubleshooting Common Issues with Home Assistant Trigger Smart Plug Power-On

One thing to watch out for when setting up this automation is that your motion sensor and smart lock are both configured correctly. I’ve found that if either of these devices isn’t set up properly, the automation won’t work as expected - for example, if your motion sensor is too sensitive, it may trigger the automation even when there’s no one in the room. To avoid this, make sure you test your automation thoroughly before relying on it.

I’ve also found that it’s a good idea to add some logging to your automation, so you can see what’s happening when things go wrong. For instance, I’ve added a log message to my automation that prints out the state of the motion sensor and smart lock whenever the automation triggers - this makes it easy to see why the automation didn’t work as expected. By doing this, I’ve been able to identify and fix issues with my automation much more quickly - for example, I recently discovered that my motion sensor was malfunctioning and triggering the automation randomly, which was causing my lights to turn on and off unexpectedly.

Advanced Configurations for Home Assistant Trigger Smart Plug Power-On

If you’re feeling adventurous, there are a few advanced configurations you can try to enhance your automation. One thing I’ve done is add a delay to my automation, so that the smart plug doesn’t turn on immediately when the motion sensor detects movement. This gives me time to walk into the room and get settled before the lights come on - it’s a small touch, but it makes a big difference.

I’ve also experimented with using multiple motion sensors to trigger my automation. For example, I’ve got two motion sensors set up in my living room - one near the door, and one near the couch. By using both of these sensors, I can create an automation that only triggers when someone is actually in the room, rather than just walking past the door. It’s a bit more complex to set up, but it works really well - I’ve found that my lights are now much less likely to turn on unnecessarily.

To get started with this setup, you’ll need to configure your motion sensors to provide separate device triggers in Home Assistant. You can then use these triggers to create an automation that checks the state of both sensors before turning on the smart plug. For instance, I’ve set up my automation to trigger only when both motion sensors have detected movement within a 30-second window - this ensures that the lights only come on when someone is actually in the room.

Get started with configuring Home Assistant to trigger your smart plug power-on only when a motion sensor detects movement and your smart lock is unlocked - with a little patience and practice, you can create a seamless and automated smart home experience.

Tags: #Home Assistant #Smart Plugs #Motion Sensors #Smart Locks
Share: X / Twitter Facebook

Related Articles