Skip to content

Automate Air Purification with Xiaomi Air Purifier and Home Assistant

Automate Clean Air? text with air purifier and home assistant logo and Kiril Peyanski thinking

Today I will talk about something super important, especially with the current state of the world and that is the air quality in our homes.

Recently, I became concerned that the air quality in my house is not good enough. Partly because of the winter season in my region and more likely, because of the reading of my DIY IKEA Air Quality Smart Sensor (IKEA Air Quality Sensor in Home Assistant: How to Make IKEA Vindriktning Smart) which allowed me to track and monitor the PM2.5 particles and air quality in my home in real-time.

What are my Air Purifier Requirements?

Due to the above factors it quickly became clear that it was time to invest in an air purifier. 

But, I didn’t want just any air purifier. I wanted something that would integrate seamlessly with my Home Assistant, and that’s where the Xiaomi Smart Air Purifier 4 line up came in.

Xiaomi Air Purifier Line Up?

I’m saying Xiaomi line up, because there are several different models that are pretty similar and the main difference is their area of coverage.

These models are: Xiaomi Air Purifier 4 Lite, 4 & 4 Pro.

Automate Air Purification with Xiaomi Air Purifier and Home Assistant 1
These are the Home Assistant compatible models of the series: Xiaomi Air Purifier 4, Xiaomi Air Purifier 4 Pro, Xiaomi Air Purifier 4 Lite

Xiaomi Air Purifier Line Up specs

These are the basic differences between the Xiaomi models and their specs

Automate Air Purification with Xiaomi Air Purifier and Home Assistant 2Automate Air Purification with Xiaomi Air Purifier and Home Assistant 3Automate Air Purification with Xiaomi Air Purifier and Home Assistant 4Automate Air Purification with Xiaomi Air Purifier and Home Assistant 5
Air Purifier 4 ProAir Purifier 4 Air Purifier 4 LiteAir Purifier 4 Compact
ModelAC-M15- SCAC-M16-SCAC-M17- SCAC-M18-SC
Particle CADR500m³/h400m³/h380m³/h230m³/h
Net WeightApprox. 6.8 kgApprox. 6.6 kgApprox. 6.0 kgApprox. 2.2kg
Item Dimensions275×275×680 mm250×250×555mm240×240×533mmΦ220 x 355mm
Noise Level≤65dB (A)≤31.9dB (A)≤35.8dB (A)≤ 60dB(A)
Effective coverage area35-60m²28-48m²26-45m²16-27m²
Xiaomi Air Purifier 4 Line Up Specifications

The Xiaomi air purifiers met all of my criteria, including:

  • integrating with my Smart Home hub that is Home Assistant,
  • being relatively inexpensive,
  • being able to clean the tiniest PM2.5 particles in the air,
  • using easily replaceable and inexpensive HEPA filters. 

I also looked at a few other models before deciding on the Xiaomi Purifier. I considered some Philips & Levoit air purifiers, but the Philips was too expensive & I couldn’t find an easy way to integrate both Levoit & Philips with Home Assistant.

Xiaomi Smart Air Purifier 4 Lite

The Xiaomi Smart Air Purifier 4 line up on the other hand seemed to tick all of my marks. I chose to buy Xiaomi Smart Air Purifier 4 lite, because it fits my room size and from now on I will talk mainly about it. But please bare in mind that the same steps for the Home Assistant Integration and the same features will be available for the other 2 models of the line up that are Xiaomi Smart Air Purifier 4 and 4 Pro, remember they are just more powerful.

You can check the current price of some of the Xiaomi 4 models and their full specifications in the affiliate links below:

How I set my Xiaomi Smart Air Purifier 4 Lite?

Once I received my new air purifier, I place it up in my combined Kitchen + living room area which is about 40 square meters in total. I was impressed with how easy it was to set it up. Basically, I set it on Auto and that was it.

Xiaomi Smart Air Purifier 4 Lite set on Auto mode
Xiaomi Smart Air Purifier 4 Lite set on A, which is the Auto mode

I was also impressed with how quickly it improved the air quality in my space. The fan is clearly hearable only when something is cooking in the kitchen, but it quickly become silent again when the readings goes below some threshold. The integrated display is a great feature as it allows me to see the air quality in real-time so I can take deep breaths more confidently. 

Home Assistant?

I was also super happy with the Xiaomi Air Purifier and Home Assistant integration procedure.

It was extremely easy!

Before I show you that, I want to say some words about Home Assistant, you may not know about it and this is such a pity as Home Assistant is the best free Smart Home hub/system available at the moment.

If you want to learn about how to install one and what are the official Home Assistant installation types + 1 super simple way to get started on a PC in under 5 minutes, then go and register for my upcoming Home Assistant webinar. It is completely free of charge!

You can reserve your seat at my other website – https://automatelike.pro/webinar

Why Xiaomi Air Purifier and Home Assistant integration is needed?

Something important before I show you how I managed to Integrate my Xiaomi Air Purifier with Home Assistant.

You may ask yourself why I need this integration in a first place, as I can just leave the Xiaomi Air Purifier on Auto mode and it will be all good?

That is true, you can leave it like that, but what if you want to open your windows?

If you live on a place like this you probably don't need Air Purifier, but you never know, you have to check the PM2.5.
If you live on a place like this you probably don’t need Air Purifier, but you never know, you have to check the PM2.5.

You can’t purify all of the air in the world right? And that is a pure waste of energy and HEPA filters if you know what I mean.

Also what if you want to turn the Xiaomi Purifier only when you are in the room? You can’t do that only with the functions of the Xiaomi Purifier. But you can create some simple Home Assistant automation that can stop the purifier when a door or window sensor report an open state or you can start the air purifier when movement is detected and stop it when no movement is detected for some period.

I will show you later in the article how such Home Assistant automations can be done super easily, but before that I will show my Integration steps of the Xiaomi Air Purifier with Home Assistant. 

How to add Xiaomi Air Purifier in Home Assistant?

These are all the steps that I did to add the Xiaomi Smart Air Purifier 4 Lite in Home Assistant:

  • First, I had to add my Xiaomi Smart Air Purifier 4 Lite in the Xiaomi Home Mobile App:
    • For that I had to press the Reset/Brightness button on the back of the purifier until I hear a beep:
      Automate Air Purification with Xiaomi Air Purifier and Home Assistant 6
    • Then, to search for a new device within the Xiaomi Home App:
      Automate Air Purification with Xiaomi Air Purifier and Home Assistant 7
    • To follow the app instructions, which are super easy.

Quick Tip: Add the Xiaomi purifier in the same network as your Home Assistant is, as the integration won’t work across different subnets or VLANs. 

The Home Assistant integration needs adding the device in Xiaomi Home App to be done first, so an access token can be later retrieved and used as you’ll see in few seconds.

Then I’ll go to my Home Assistant:

  • I’ll press the “c” button to invoke the command search bar,
  • I will type integrations and I will select Navigate Integrations,
  • Then, I will then click on Add Integration button in the lower right corner
  • After that, I will search for Xiaomi, I will select the Xiaomi Miio integration
  • I will enter my Xiaomi Home App credentials, so the Xiaomi Access Token to be auto retrieved for me. 
Automate Air Purification with Xiaomi Air Purifier and Home Assistant 8

Quick Tip: Don’t worry after that initial authorisation the communication and the control from Home Assistant to the Air Purifier and vice versa is entirely local. 

I will click on Submit button and that is it, I’m ready with the Xiaomi Air Purifier Home Assistant integration.

If I check the Home Assistant integration, I will find a new Xiaomi device with the following entities.

Selecting a Xiaomi Server and checking the Air Purifier Entities in Home Assistant
Selecting a Xiaomi Server and checking the Air Purifier Entities in Home Assistant

Do you need some help?

Before I go the the Home Assistant automations I want to give you something. It is my free Smart Home Glossary which is coming as a PDF and it contains over 60 Smart Home words and abbreviations and their simple, but useful explanations.

You can download it instantly from my other website – https://automatelike.pro/glossary

How to create a Home Assistant automation that will stop the Xiaomi Air Purifier when no motion is detected?

As I mentioned before, the great benefit of doing the Xiaomi Air Purifier Home Assistant integration is the possibility to create automations.

I will show you an example Home Assistant automation that will stop the purifier when no motion is detected for some short period. As a motion sensor I will use Shelly Motion 2. If you want to know more about it check this article of mine – Shelly Motion 2 Review & Home Assistant Integration

Anyways, here is my Xiaomi Air Purifier Home Assistant automation. You just have to change the entity_id & device_id with yours to try it out:

alias: Stop Air Purifier when no motion is detected for 10mins
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.shellymotionsensor_60a4239a677c_motion
    to: "off"
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition:
  - condition: device
    device_id: d8fbc9875e1309cc592ed1e16f2cf32b
    domain: fan
    entity_id: fan.xiaomi_smart_air_purifier_4_lite
    type: is_on
action:
  - type: turn_off
    device_id: d8fbc9875e1309cc592ed1e16f2cf32b
    entity_id: fan.xiaomi_smart_air_purifier_4_lite
    domain: fan
mode: single

Making an automation in Home Assistant that will start the Xiaomi Air Purifier when movement is detected is as easy.

  • Just duplicate the first one,
  • Change a bit the trigger & the action of the automation,
  • Save the automation under new name.

And you can start saving from electricity and HEPA filters.

alias: Start Air Purifier when motion is detected
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.shellymotionsensor_60a4239a677c_motion
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - condition: device
    device_id: d8fbc9875e1309cc592ed1e16f2cf32b
    domain: fan
    entity_id: fan.xiaomi_smart_air_purifier_4_lite
    type: is_off
action:
  - type: turn_on
    device_id: d8fbc9875e1309cc592ed1e16f2cf32b
    entity_id: fan.xiaomi_smart_air_purifier_4_lite
    domain: fan
mode: single

I Need some help with Xiaomi Air Purifier Compact and Home Assistant integration

I need some help here!

I also bought one more Xiaomi Air Purifier, which is even smaller and cheaper, designed for smaller rooms up to 27 square meters.

Xiaomi Mi Smart Air Purifier 4 Compact
Xiaomi Mi Smart Air Purifier 4 Compact

The exact model is Xiaomi Mi Smart Air Purifier 4 Compact, but it seems that it cannot be integrated as easily as the other bigger models due to some reason.

This is the error that I received when I'm trying to add the Xiaomi Mi Smart Air Purifier 4 Compact in Home Assistant.
This is the error that I received when I’m trying to add the Xiaomi Mi Smart Air Purifier 4 Compact in Home Assistant.

I guess some manual configuration needs to be done or probably update of the integration is needed. I didn’t have time to investigate this further, so if you happen to know a solution – let me know in the comments section.  

Xiaomi Air Purifier Line Up summary

Other than that and overall, I’m extremely happy with my purchases and I highly recommend the Xiaomi Smart Air Purifier 4 line to anyone who is looking to improve the air quality in their home. Not only they are affordable and easy to set up, but they also are integrating seamlessly with Home Assistant, which makes them even more convenient to use.

As I already mentioned Xiaomi offers several models of air purifiers with slightly different features, coverage areas and prices, so you can find one that fits your specific needs and budget – the links to all of them + their filters can be found below:

I think that air purifiers are great investment in your health, but I’m also interesting what do you think? Share you thoughts in the comments. 

I’m Kiril, thanks for reading and take care of the air quality in your Smart Home. Bye!

5 thoughts on “Automate Air Purification with Xiaomi Air Purifier and Home Assistant”

  1. Hello, I’m really considering the Xiaomi Air Purifier Compact for my house but I’d like to integrate it into HA too. Are there any news on this topic? Thank you

    1. I didn’t heard anything new yet, but I didn’t search for new info either… I hope that someone will jump and enlighten us.

        1. Hi all,
          I found a solution to getting the Compact model working in HA. Have a look at this page: https://community.home-assistant.io/t/mi-air-purifier-4-compact/487880

          For me, the key step was to select ‘cloud’ rather than ‘automatic’. At this point, most of the entities show up nicely (fan on/off, filter time left, filter life left %, filter time used and most importantly for me, Environment PM2.5 density). This allowed me to create automations to switch the purifier on and off when the air quality is above/below certain values. This works flawlessly for me now.

          I have been trying to get the other attributes to sho (eg: motor RPM etc). They are visible when I click on the Air Purifier entity, but I have not been able to make a template to show them in their own entity.

          In case it helps anyone, here are a couple of my basic automations:

          – id: ‘xxxxxxxx’
          alias: Turn on purifier when air is dirty
          description: ”
          trigger:
          – platform: numeric_state
          entity_id: fan.zhimi_cpa4_055a_air_purifier
          for:
          hours: 0
          minutes: 0
          seconds: 30
          attribute: environment.pm2_5_density
          above: 11
          condition: []
          action:
          – service: fan.turn_on
          data: {}
          target:
          entity_id: fan.zhimi_cpa4_055a_air_purifier
          mode: single

          – id: ‘xxxxx’
          alias: Turn off purifier when air is clean
          description: ”
          trigger:
          – platform: numeric_state
          entity_id: fan.zhimi_cpa4_055a_air_purifier
          for:
          hours: 0
          minutes: 1
          seconds: 0
          attribute: environment.pm2_5_density
          below: 11
          condition:
          – condition: state
          entity_id: switch.mystrom_ender3v2
          state: ‘off’
          action:
          – service: fan.turn_off
          data: {}
          target:
          entity_id: fan.zhimi_cpa4_055a_air_purifier
          mode: single

          1. Many thanks for sharing your solution to getting the Compact model working in Home Assistant. Your post is very helpful, and I appreciate the time and effort you took to share your insights with the community.

            Once again thank you so much!

Leave a Reply

Your email address will not be published. Required fields are marked *