Add Smartmi Air Purifier to Integrations

I want to use the purifer-card.js lovelace custom component, however I am not sure which HACS integration to use for the Smartmi Air Purifier P1:

Smartmi is a Xiaomi company, but nowhere in the Xiaomi Miio integration do I see my Smartmi Air Purifier and in fact, Smartmi has its own standalone app which does not integrate with the Mi Home/Xiaomi MiiO apps at all, at least not on iOS.

I search for Smartmi directly in the Integrations section in the configuration tab in Home Assistant. Nada.

So I go searching for one in HACS and I get several options for Xiaomi integrations which make little sense to me as to which one I need, there are just too many to sort through or scan quickly to see what I need.

Maybe through the Aqara Gateway? Not sure.

Donā€™t really need much handholding with this just need some help being pointed in the right direction. New to HA and just tinkering with things.

Iā€™ve been looking for the same thing

Itā€™s really strange because the purifier card has the capability to add a Smartmi card to Lovelace UI but itā€™s worthless if I canā€™t even find the purifier in integrations/HACS in the first place.

Iā€™ve added it though adding it on HomeKit on my phone then deleting it and adding it in HomeAssistant - itā€™s not perfect though as I donā€™t get all of the controls when itā€™s exposed through HomeAssistant and the air quality readings donā€™t seem to update automatically?

Yeah, itā€™s annoying that xiaomi has so many small ā€œsubā€ brands ā€¦

Also interested in this. Any luck getting readings and controlling this from HA?

I added it via homekit controller too intially but when I did a while back it only had the AQI sensor and not even a switch for the fan. Has that changed? Was going to try it again soon but figured Iā€™d ask anyways.

Donā€™t think it has changedā€¦ Was able to connect to Homekit Controller and initially got AQI readings, but they didnā€™t correspond with actual readings. Also no option to control the device.

If it had talked with the official MiHome app, I guess one could configure it with the Miio integration. But this is not the case. Talked with SmartMi support and they said it was not possible to add the P1 to MiHome due to hardware issues.

I have a Smartmi Air Circulator Fan 2. I was able to control it using localtuya. Youā€™ll need to extract the localKey though.

1 Like

Iā€™ve also successfully added the Smartmi Airpurifier P1 to HA via the HomeKit Controller integration. However, still no fan control. When I go to the device in Devices, I see two sensors in the Sensors section - Air Quality and PM2.5 Density. It also created a Diagnostics section that appears to be useless (unless Iā€™m misunderstanding what the ā€˜PRESSā€™ button does)

Do your values update correctly though? Mine only do upon a HomeAssistant restart and then never againā€¦

Thanks to @redphxā€™s comment, I attempted to get it into HA via LocalTuya and was able to get it integratedšŸŽ‰.

After much trial and error, I got all of the Tuya IDs of the device mapped out to HA entities (except for one, which I donā€™t think is useful anyway). Let me know if anyone is interested in getting this setup in HA and Iā€™ll provide the mappings.

My favorite features that I now have access to are being able to turn off the annoyingly loud sound when interacting with the device and being able to automate the screen brightness! Itā€™s the small things. Having access to the filter lifespan and filter use will also open up a really useful notification automation when itā€™s time to replace the filter.

All updates are instantaneous between HA and the Smartmi Air Purifier P1. I like having it in HomeKit for easily controlling the fan speed via the UI and to quickly see air quality but this opens up a lot of advanced automations for me in node red (HomeKit may send a notification when itā€™s time to change the filter but Iā€™m not sure - just got the purifier yesterday).

2 Likes

Smartmi Air Purifier P1

1 Like

Yes please do share the mappings! That will be extremely useful

Would love to know how you did this; I havenā€™t setup localtuya before and donā€™t know how to pull the localKey. Iā€™m fine using the cloud device lookup but can this be added to Tuya Cloud even?

Congrats. Make sure you donā€™t upgrade its firmware, because Smartmi might block this in future update (happened to Roborock).

How to Integrate Smartmi P1 into Home Assistant via LocalTuya

Quick notes before embarking on this journey:

  • The Tuya integration is not necessary (Iā€™m not using it). However, this process involves setting up a Tuya cloud developer account. Though according to the LocalTuya GitHub:

Cloud API calls are performed only at startup, and when a local_key update is needed.

  • Iā€™ve used this integration for a week now and have setup advanced automations in node red and itā€™s worked extremely well. Communication between HA and the P1 are instantaneous.
  • It also allows access to various settings and features that you would only be able to access/change through the Tuya/Smartmi app (for example, you canā€™t turn off the sound or adjust the display brightness in HomeKit).

1. Add Smartmi P1 to HomeKit

This isnā€™t necessary if your only goal is to get the device in Home Assistant. I use the Home app as my front end (I like the UI) and HA as my backend (all automations are in node red) so I like being able to see and control all of my devices manually through the Home app.

2. Connect the Smartmi P1 to the Tuya Smart app

  • Download the Tuya Smart app on your phone
  • If I remember correctly, when you open the app for the first time, it will ask for permission to allow the app to access devices in the Home app. Make sure you allow it.
  • If you already added the device to HomeKit, in the Tuya app youā€™ll want to select Me > HomeKit Information.
  • You should see a device called Air Purifier which is your P1. Select ā€œBindā€. The device is now connected in Tuya.

3. Obtain Tuya local key, client id, client secret, and device id

  • Watch this tutorial on getting your deviceā€™s local key and device id
  • After youā€™ve done that, you can easily get your client id and client secret. Go to Cloud > Development

4. Install LocalTuya in Home Assistant

  • Install LocalTuya via HACS in Home Assistant (LocalTuya GitHub Installation)
  • Restart HA
  • In HA, go to the Integrations page
  • Select ā€œAdd Integrationā€ and search for LocalTuya and add it
  • You should now see LocalTuya as an integration (you wonā€™t have any devices/entities yet if this is your first device using LocalTuya)
    Pasted image 20220723123606

5. Configure LocalTuya and Add P1

1: Fan

  • Hereā€™s how I setup ID 1, which is the switch that will turn the fan on/off. I called it Fan but you can also call it Air Purifier or whatever else you want. Select SUBMIT when complete.

  • Another window will pop up where you will select the next HA entity type that youā€™ll be mapping. In this case, the next entity weā€™ll setup is the PM2.5 Density, which we want to be a sensor in HA. Select ā€œsensorā€ and unselect ā€œDo not add any more entitiesā€. Youā€™ll want to uncheck this box each time you see this screen until weā€™re finished.

2: PM2.5 Density

  • entity type: sensor
  • unit of measurement: Āµg/mĀ³
  • device class: pm25

3: Mode

19: Timer Remaining

  • entity type: sensor
  • unit of measurement: minutes
  • description: how many minutes are left in the current timer that is set (see ID 103)

101: Sound

  • entity type: switch
  • description: turns on/off beeping sounds when interacting with the air purifier settings

102: PM10 Density

103: Timer

  • entity type: select
  • valid entries (tuya asks for semicolon separated list):
    • 0_hour;1_hour;2_hour;4_hour;8_hour
  • user friendly options (tuya asks for semicolon separated list):
    • off;1 hour;2 hours;4 hours;8 hours

104: Filter Lifespan

  • entity type: sensor
  • description: current filter life remaining in percent

105: Filter Use

  • entity type: sensor (or number)
  • unit of measurement: hours
  • description: number of hours the current filter has been in use. In the Tuya app, this corresponds to ā€œFilter usehā€ under ā€œSettingā€. This can be set as a number that can be adjusted (itā€™s also editable in the Tuya app). However, this number should automatically reset to 0 after following the ā€œResetting the Filter instructions in the manualā€. For that reason, Iā€™ve left it as a sensor.

You can now check the box ā€œDo not add any more entitiesā€. Note that I couldnā€™t figure out what Tuya ID 22 was. I set it as a sensor for awhile but itā€™s value never changed from 0 so I ended up removing it.

6. Done!

Let me know if you have any questions.

18 Likes

Good point. I upgraded the firmware before integrating it. I wonā€™t be upgrading it anymore though.

This was wonderful, thank you so much!!

1 question though, how do you add data points later? For example, I noticed that you have Fan Speed and Screen Brightness, I didnā€™t see an option for the fan speed, and I missed the screen brightness. Is there a way to go back and add those data points or do I need to delete the device and reconfigure the entire setup?

When you click ā€œConfigureā€ you can select ā€œEdit a deviceā€.

Some further data points:
108: Colour
109: Manual Fan speed Setting (seems to be a 0-100 setting)
110: Screen Brightness

And for anyone else like myself who was seeing it already ā€œBindedā€ (bound), in the Tuya app, remove it from the SmartMi app and then try again.

2 Likes