After I got my Xiaomi kit, I integrated the Gateway and Button pretty quickly into my Smart-Home set up. The Door/Window sensors, on the other hand, took a little more time to figure out. However, it ended up being worth it in the end. These sensors changed the game by making automations that respond to actions; as opposed to buttons, time, or your voice. This, I feel, is my first entry into true Home Automation, instead of just having smart devices.
There are two Door/Window sensors that are compatible with the Xiaomi Gateway; a first generation and second generation version. With my Door/Window sensors, I wanted to try a couple of things. First, I wanted to be able to monitor the front door. With this, I figured I could set up a very, very, very basic alarm system. Secondly, I wanted to monitor the bedroom door. I was already using the Gateway as a night light in the bathroom at night. With the Door/Window sensor, I could automate that as well as my morning lights routine.
This guide will show you:
- How to connect the Door/Window Sensors to the Xiaomi Gateway.
- How to add the Sensors to your Home Assistant front end.
- How to use the Door/Window Sensors in automations.
- Make a simple Door alarm.
- How to add your own “ringtones” to the Xiaomi Gateway
The Xiaomi Door/Window Sensors
I used Google Translate to provide a Shoddily Translated English Manual for the Xiaomi Door/Window Sensor
Setting up the Door/Window Sensors
- Setting up the Door/Window Sensor is identical to setting up the Button:
- Push the button on the Gateway 3 times.
- Be careful, holding the button down for 5 seconds will reset the Gateway.
- Push the button on the Gateway 3 times.
- If the Notification volume is still on, the Gateway will prompt you to connect the sensor.
- Use a pin or sim card tool to push into the hole in the bottom of the Sensor.
- It should now be connected.
- You can check within the App or by restarting Home Assistant searching for it in the Developer Tool’s States page.
- Now that the Door/Window sensor is connected, you can confirm its connection still works wherever you put it by pushing the hole with a pin again. This will cause the Gateway to confirm if it’s still connected.
- Note: Once connected to the Gateway, the violet light on the sensor will stop flashing when it switches on or off.
Adding the Sensors to your Front End.
- To add the sensors to your front end, you can use a Template Sensor in your configuration.yaml. Mine is in my sensors.yaml file.
- Below are how I added both sensors to my front end.
- For the binary Door/Window sensors, “off” is when the sensor is closed, and “on” is open. I wanted my front end to say “Open” and “Closed” as well as change the icon to match the state of the door.
- This is how it will look when added to your front end.
- Now let’s put the sensors to work.
Automated Night Light & Home Wake-Up Script
- My first move in automation, was to use the Gateway as a Night Light in the bathroom.
- First, you’ll want to open your automation.yaml file.
- This first part, makes the light turn on when the bedroom door opens.
- Then, it shuts off when the door is closed.
- You can add both automations to a group, so that only the group needs to be called when activating these automations.
- When added to a group, the automations can all be accessed by clicking the automation group.
- Now, I can activate the Night Light automation by turning on group.evening_night_light within the bedtime script from a previous post.
- The automation will stay on throughout the night.
- Notice I also tied the bedroom door sensor to the end of my bedtime script.
- These sensors can have multiple uses.
- Now, my lamp will stay on in the living room, until I close the bedroom door to go to bed.
- With the addition of this new sensor, I also changed my whole Morning Wake Up automation.
- This new routine doesn’t use the time to turn lights on. Instead, it will turn on my lights when I open the bedroom door, after my usual 5:15 wake up time.
- It also turns off the Night Light automation group as well as turning itself off.
- This creates a nice smooth string of actions that all go into effect after I tell Alexa that I’m going to bed. It goes like this:
- Tell Alexa it’s time for bed (this can be done with a custom Alexa skill or by using the Alexa Routines)
- The bedroom turns on
- The living room turns off (except the main lamp, which turns off when the bedroom door closes)
- Night Light & Morning Wake up automations turn on
- When I go to bed and shut the door, the rest of the living room shuts off
- Throughout the night, if the bedroom door is open, the night light turns on
- After 5:15, when the bedroom door is opened, the living room turns on, and the Night Light and Morning routine automations are all
- turned off.
Make A Simple Alarm
- Creating a simple alarm using the Xiaomi Gateway and Door/Window Sensors is really easy
- First, open your automations.yaml file to begin a new automation.
- This automation uses the sensor on my front door. When opened, the Gateway will play whichever sound I choose. That’s it!
- I also added a script to my front end for turning off and silencing the alarm.
- I used the MDI Icons “alarm-light” and “volume-off” when customizing the entities.
- You can now tie in your alarm to any of your other automations. I am considering tying it to the rest of my Bedtime/Wake up routine to go off if someone opens the door while we’re sleeping.
BONUS: You can add your own “ringtones” to the Xiaomi Gateway!
I wanted to have a better alarm sound than the one I used creating the automation above. You can add your own sounds to the Gateway through the MiHome app. I used an alarm that I found amongst these different alarm sounds.
- Navigate to the Gateway in the MiHome app
- Choose “Device” from the top of the screen
- Select the Gateway
- Select Ringtone Settings
- Choose one of the Ringtone Types
- Touch the “+ Add Ringtone” at the bottom of the page
- Choose your desired file and touch “Yes”
- Your file will now be available at the top of the page as a “Custom Ringtone.”
- To access your custom ringtones in Home Assistant, reference them starting with ringtone_id 10001.
The Xiaomi Gateway and Door/Window sensors are a great addition to any Smart-Home set up. The sensors dramatically increase the possibilities of home automation and are very affordable. They took me a little more time to add to the system, but that is just because they are capable of doing so much. I highly recommend them. If these guides have been helpful to you, please share them! If you have any questions, please reach out to me in the comments. Thanks for visiting!
If you’re interested in getting started with the Xiaomi Gateway, I recommend starting with one of the kits.
Different Gateway Kits Available
- I purchased my Gateway with the Smart Home Aqara Security Kit. This came with the Gateway, a Button, and 2 Door/Window Sensors (as pictured above), but there are other kits available.
- The Xiaomi 5 in 1 Smart Home Security Kit includes the Gateway, a Button, a Door/Window Sensor, a Motion Sensor, and the Outlet (Zigbee Version).
- Lastly, there’s the Xiaomi mijia 6 in 1 Smart Home Security Kit, which includes The Gateway, a Button, a Door/Window Sensor, a Motion Sensor, an Outlet (Zigbee Version), and a Temperature Humidity Sensor.
All of the parts can also be purchased individually:
- Xiaomi Aqara Gateway.
- Temperature and Humidity Sensor (1st and 2nd generation)
- Motion Sensor (1st and 2nd generation)
- The 1st generation Motion Sensor is available with this Gateway kit
- Door and Window Sensor (1st and 2nd generation)
- Button (1st and 2nd generation)
- Plug aka Socket (Zigbee version only, reports power consumed, power load, state and if device in use)
- Wall Plug (reports power consumed, power load and state)
- Aqara Wall Switch (Single)
- Aqara Wall Switch (Double)
- Aqara Wireless Switch (Single)
- Aqara Wireless Switch (Double)
- Cube – Magic Controller
- Smoke Detector (reports alarm and density)
- Gateway (Light, Illumination Sensor, Ringtone play)
- Intelligent Curtain
- Water Leak Sensor