We like using plug-in air fresheners around the house, but we often forget to unplug them and end up buying refills more frequently than we need to. I wanted to automate when they turn on and off using Apple Home.
My first thought was to use an in-wall smart plug, but most of the options available at the time required a neutral wire. My house is old and does not have neutral wires in those boxes, so I needed a plug that would work with the existing wall outlets instead. I chose the VOCOlinc SmartBar Wi-Fi Plug (VP5X) because it had native HomeKit support.
I also wanted to be able to turn the air freshener on at any time and have it switch off automatically after 45 minutes. Apple Home did not offer that timer behaviour for smart plugs, but it did for switches. To bridge that gap, I used the Homebridge Dummy plugin to create a virtual switch that controls the smart plug. The plugin is simple, easy to configure, and has been reliable for this use case.
Download and install Homebridge for your platform from https://homebridge.io. I run it on my Synology NAS. Once it is installed, the Homebridge interface should be available at http://localhost:8581/.
Open the Plugins page, search for “Homebridge Dummy,” and install it.
Give the virtual switch a name, enable Stateful, save the configuration, and restart Homebridge. That is all the Homebridge configuration this project requires.
The first automation lets me turn on the air freshener whenever I want and ensures it turns off automatically after 45 minutes. I used an Accessory Is Controlled automation so that turning on the dummy switch also turns on the VOCOlinc smart plug. The 45-minute time limit is applied through the switch-based automation.
The second automation runs the air freshener on a schedule. I created an A Time of Day Occurs automation that turns on the dummy switch at 2:00 p.m. every day. Because the dummy switch and smart plug are linked, that also turns on the air freshener.
Once the smart plug's 45-minute timer finished, the smart plug turned off but the dummy switch remained on. I added another automation so that when the smart plug turns off, the dummy switch turns off as well.
I then created one final Accessory Is Controlled automation so that manually turning off the dummy switch also turns off the smart plug. With both directions synchronized, I can use the dummy switch as the single control for the air freshener without worrying about the smart plug's state.