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
-
Select the project you created in the tutorial. I called mine home assistant
-
You’ll find the client id and client secret here.
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)

5. Configure LocalTuya and Add P1
-
On the integration, select CONFIGURE
-
Fill in the form using the screenshot below as reference
-
Add a new device
-
Fill in the form using the screenshot below as reference. Enter the IP address of your P1, which will likely be different than mine.
-
Select fan as the platform
-
Now we start mapping Tuya’s internal ID’s to different entities in Home Assistant. I won’t include a screenshot for every ID/entity but I’ll provide the necessary information for each one, which will include:
- the Tuya ID followed by what I named it (i.e. 1: Fan means that the Tuya ID is 1 and I named it “Fan”)
- entity type in HA (sensor, switch, etc)
- other relevant details specific to the entity
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
- entity type: select
- list of options (tuya asks for semicolon separated list):
- auto;sleep;strong;manual
- auto;sleep;strong;manual
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
- entity type: sensor
- unit of measurement: µg/m³
- device class: pm10
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!
- It should looks something like this:
Let me know if you have any questions.










