Combining Xiaomi Door Sensor and Plug for Garage Automation

I recently decided to integrate my existing home automation system with some new Xiaomi devices, specifically the door sensor and smart plug. My goal was to create a seamless garage door automation system that would allow me to monitor and control the door status directly from the SmartThings app. Here’s how I approached the challenge and the solution I came up with.

The Problem:
I had an old garage door remote that I repurposed by removing the button and soldering it directly to a power source. This setup worked well for manually controlling the door, but I wanted to automate it further. I connected the remote to a smart plug and set up an automation where turning on the plug would trigger the door to close. I then added a Xiaomi door sensor to monitor the door’s status.

However, I faced two main issues:

  1. The door sensor and smart plug appeared as separate devices in the SmartThings app, making it difficult to manage them as a single garage door system.
  2. I wanted to ensure that the new setup would work seamlessly with the latest version of the SmartThings app.

The Solution:
After some research and experimentation, I discovered that I could create a custom device within the SmartThings app that combines both the door sensor and the smart plug into a single entity. This involved setting up a virtual device that aggregates the statuses of both the sensor and the plug. Here’s how I did it:

  1. Create a Virtual Device:

    • I used the SmartThings IDE to create a new virtual device that represents the garage door system.
    • This device includes attributes for both the door status (open/closed) and the plug status (on/off).
  2. Set Up Automations:

    • I configured an automation that triggers when the door sensor detects a change in status. This automation updates the virtual device’s attributes accordingly.
    • I also set up another automation that controls the smart plug based on user input through the virtual device’s interface.
  3. Testing and Refinement:

    • After setting up the virtual device and automations, I thoroughly tested the system to ensure that both the door sensor and smart plug were functioning as expected.
    • I made adjustments to the automation rules to handle edge cases, such as the door being left open for an extended period.

Outcome:
By creating a virtual device that combines the Xiaomi door sensor and smart plug, I was able to present the garage door system as a single, cohesive entity within the SmartThings app. This not only simplifies management but also ensures compatibility with the latest app updates. The virtual device provides a user-friendly interface that displays the door’s status and allows for direct control of the smart plug, effectively turning the garage door system into a smart, automated solution.

Final Thoughts:
This project was a great learning experience, and I’m thrilled with how it turned out. It’s satisfying to see all the components working together seamlessly. I hope this guide helps others who are looking to integrate similar devices into their SmartThings ecosystem. If anyone has questions or suggestions, I’d be happy to discuss further!

Thanks for reading, and happy automating! :blush: