How to customize a script for a Xiaomi moisturizer: from basic rules to complex automation

Xiaomi’s humidifiers are among the most popular devices in the smart home ecosystem, thanks to a combination of affordable prices, accurate operation and extensive automation capabilities. However, many users are limited to manual control, without even knowing that the device is able to maintain an optimal microclimate without constant monitoring. Setting up scenarios allows you to connect the humidifier with other sensors (for example, hygrometers or thermostats), run it on a schedule or when indoor conditions change.

In this article, we’ll explore all the ways to create scenarios for Xiaomi humidifiers, from simple rules in the Mi Home app to complex logic through Home Assistant or Yandex Alice. You’ll learn how to set up automatic on-setting at low humidity, synchronize with air conditioning or heater, and avoid errors that make scenarios fail.

What Xiaomi Humidifier Models Support Scenarios

Not all Xiaomi devices integrate equally well into the smart home system, and scripting depends on the model, firmware version, and Mi Home regional server.

  • πŸ”Ή Full support for automation: Xiaomi Smartmi Air Humidifier 2/3, Xiaomi Mi Air Humidifier Pro, Xiaomi Deerma Humidifier JSQ. These models have built-in humidity sensors and support all types of scenarios in the Mi Home.
  • πŸ”Έ Limited support: Xiaomi Viomi Air Humidifier (requires manual addition to Home Assistant), Xiaomi Zhimi Air Humidifier CA1 (It only works with a Chinese server).
  • πŸ”Ά No Script Support: Budget Models Without Wi-Fi (Xiaomi) CJXJSQ) Xiaomi Mi Air Humidifier 1 without firmware updates).

To check your model’s compatibility, open the Mi Home app, go to Profile β†’ Settings β†’ Region and make sure you choose a China server (for most models) or Europe/Russia server (for global versions).If your model doesn’t show up in the supported list, try changing the region or updating the firmware through Mi Home β†’ Device β†’ Three Dots β†’ Software Update.

⚠️ Note: Xiaomi Humidizers purchased in China may not work with European Mi Home servers due to manufacturer restrictions, in which case, Home Assistant or alternative firmware will be required to customize scripts.

Preparing for customization: what to do before creating scenarios

Before you start automation, make sure that the device is properly connected to the network and synchronized with the application.

Update the device to the latest version

Connect the humidifier to a 2.4GHz Wi-Fi network (5GHz not supported)

Make sure there is enough water in the tank (some scenarios don’t work when the tank is low)

Check the calibration of the built-in humidity sensor (compare readings with an external hygrometer)

Turn off the energy-saving mode on the router (it can break the connection to the device)-->

So, you pay special attention to calibrating the humidity sensor, and in cheap Xiaomi models, it can be overvalued or undervalued, to check the accuracy of the humidity sensor.

  1. Place the humidifier next to an external hygrometer (e.g., Xiaomi Mijia Bluetooth Temperature and Humidity Sensor).
  2. Run the test: in Mi Home go to Device β†’ Settings β†’ Sensor calibration.
  3. If the difference is greater than 5%, manually calibrate the sensor through Additional settings β†’ Adjust readings.

It is also recommended to attach the device to the room in Mi Home, which will allow you to create scenarios with reference to a specific room (for example, turn on the humidifier in the bedroom only at night).

  1. Open the map of the house in Mi Home.
  2. Drag the moisturizer icon to the desired room.
  3. Save the changes.
πŸ“Š What kind of Xiaomi humidifier do you have?
Smartmi Air Humidifier 2
Mi Air Humidifier Pro
Deerma JSQ
Viomi
Another model
I don't know.

Creating a baseline scenario in the Mi Home app

The easiest way to automate the humidifier is to use the built-in script builder in the Mi Home, which allows you to link the device to other sensors or set a schedule without programming. Let's take a step-by-step look at how to set up automatic on at low humidity:

  1. Open the Mi Home app and go to Scripts β†’ Create a script.
  2. Select the script type: Automatic (to react to events) or Manual (to run on a button).

Add in the action.

  • πŸ’§ Select your humidifier from the list of devices.
  • Set the mode: Turn on or set the humidity level to 50%.
  • Save the script and give it a name, like β€œDay hydration.”

For a more flexible setup, you can add several conditions, for example, to turn on the humidifier only if:

  • πŸ•’ Time from 22:00 to 07:00 (night mode).
  • 🏠 No one is home (according to the Mi Home geozone).
  • 🌑️ The temperature in the room is above 20Β°C (to avoid condensation).
Type of scriptExample of useEssential devices
By humidity.Turn on the humidifier at humidity < 40%Humidifier + humidity sensor
Scheduled.Work from 20:00 to 08:00 dailyJust a moisturiser.
Geo-fence.Turn off the humidifier when everyone is out of the houseMoisturizer + smartphone with Mi Home
Temperature.Include only if temperature > 18Β°CHumidifier + temperature sensor

⚠️ Note: Mi Home has a limit on the number of active scripts to no more than 20. If the limit is reached, delete the unnecessary rules or move them to Home Assistant.

Advanced Scenarios: Connecting with Other Devices

The basic rules in Mi Home cover only the simplest tasks. For complex automation (for example, synchronizing the humidifier with an air conditioner or heater), you will need to use third-party platforms:

  • 🏠 Home Assistant: Allows you to create scenarios with multiple conditions, cycles and delays. Supports all Xiaomi models through Xiaomi Miio integration.
  • πŸ€– Yandex Alice: Comfortable for voice control and simple rules (e.g., "Alice, turn on the humidifier for 1 hourΒ»).
  • 🌐 Node-RED: Visual editor for creating complex logical chains (e.g., if humidity is present) < 30% And temperature > 25Β°C, then turn on the humidifier for 30 minutesΒ»).

Consider an example of setting up in Home Assistant for automatic microclimate control:

  1. Install Xiaomi Miio integration through Settings β†’ Devices and Services β†’ Add Integration.
  2. Get your humidifier token with the help of miio-cli utility or Miot Spec service.
  3. Create automation in Settings β†’ Automation β†’ Create:
Alias: "Smart microclimate in the bedroom"


trigger:




- platform: numeric_state




entity_id: sensor.bedroom_humidity




below: 40




condition:




- condition: time




after:"22:00:00"




before:"07:00:00"




action:




- service: humidifier.set_mode




target:




entity_id: humidifier.bedroom_humidifier




data:




mode:"auto"




target_humidity: 50

This scenario would include a humidifier in the bedroom at night if the humidity dropped below 40% and maintain it at 50%.

condition:


- condition: state




entity_id: climate.bedroom_ac




state:"cool"

πŸ’‘

If the humidifier is often turned on for no reason, check the location of the humidity sensor. It should not be near steam sources (kitchen, bathroom) or on a draft.

Mistakes and Problems: Why Scenarios Don't Work

Even well-tuned scenarios can fail, and here are the most common reasons and ways to address them:

Problem.Possible causeDecision
The script doesn't work.The device is offline.Check Wi-Fi connection, reboot router
The humidifier is turned on too oftenWrong humidity thresholdIncrease hysteresis (the difference between switching on/off)
The script is running with a delayMi Home server is overloadedUse local scripts in Home Assistant
The device is not displayed in the listIncompatible Region in Mi HomeChange your server to China or update your firmware

If the humidifier does not respond to commands from the script, check:

  1. Internet availability (the device must be online).
  2. Permissions in Mi Home: Go to Profile β†’ Settings β†’ Notifications and enable Automation.
  3. Device Logs: In Home Assistant, open Developer Tools β†’ Logs and find Miio-related errors.
What to do if the humidifier is not calibrated?
If the humidity sensor shows incorrect values even after calibration, try resetting the device to factory settings: 1. Turn off the humidifier from the network. 2. Press the power button for 10 seconds. 3. Connect to the network and reset from scratch. If the problem remains, the sensor itself may be defective - in this case, contact the service center.

Optimization of water and electricity consumption

Automating your humidifier not only increases comfort, it also helps you save resources, and here are some tips on how to reduce your water and energy consumption without compromising your climate:

  • πŸ’§ Use hysteresis: set the difference between on and off thresholds at least 5%. For example, turn on at 40%, turn off at 45.
  • ⏳ Limit your running time: In the scenario add the condition Maximum duration: 2 hours to avoid overhydration.
  • 🌿 Sync with plants: If there are flowers in the room that require high humidity, create a separate scenario with priority for them.
  • β˜€οΈ Take into account the time of day: at night, humidity naturally rises, so you can reduce the target threshold from 50% to 45%.

For maximum savings, link the humidifier to the window opening sensor. If the window is open, the humidity in the room drops quickly, and the device will work idle. To avoid this, add a condition to the scenario:

condition:


- condition: state




entity_id: binary_sensor.window_contact




state: "off" #Window closed

πŸ’‘

The use of distilled or filtered water reduces scale formation and prolongs the life of the humidifier, as well as reduces the electricity consumption for heating.

Integration with voice assistants (Alice, Google Assistant, Siri)

You can control the humidifier not only through the app, but also through your voice, and you need to connect it to one of the voice assistants, and let's look at Alice's Yandex.

  1. Open the Yandex app and go to Devices β†’ Add the device.
  2. Choose Xiaomi and log in through your Mi Home account.
  3. After synchronization, tell Alice: "Switch on the humidifier for 1 hour"; "Set the humidity in the bedroom at 50%"; "Switch off the humidifier when the humidity reaches 45%."

Google Assistant or Siri will require you to connect Mi Home via Google Home or Apple HomeKit, respectively. Note that not all Xiaomi models support HomeKit – this may require middleware like Home Assistant or HomeBridge.

⚠️ Attention: Voice commands have a delay of 1-3 seconds due to cloud processing. For critical tasks (for example, emergency shutdown), use local scenarios.

FAQ: Answers to Frequent Questions

Can you customize a scenario for a humidifier without a humidity sensor?
Yes, but it will require an external sensor (e.g. Xiaomi Mijia Bluetooth or Aqara Temperature and Humidity Sensor) to connect it to the Mi Home or Home Assistant and use its readings in the script. Without the sensor, you can only create a timetable.
Why does the humidifier turn on at night, although the humidity is normal?
It's likely that the sensor settings are lost or that Scenario is geofenced (for example, if you come home late). β†’ History of execution) and adjust the conditions.
How to reset all scripts to factory settings?
Mi Home doesn't have a massive script reset function. You have to manually delete them: Open scripts. Click three dots next to each script. Choose Delete. To reset the humidifier settings, hold the power button for 10 seconds.
Can I use a Xiaomi humidifier with HomeKit?
Officially, no, because Xiaomi doesn't certify its devices for Apple's HomeKit. However, there are workarounds: Use Home Assistant with HomeKit Controller integration; install HomeBridge on Raspberry Pi; and connect the humidifier via the miio plugin. Both methods require server configuration skills.
How often should I update the humidifier firmware?
Xiaomi Humidifier Updates are rarely released (1-2 times a year) and usually fix critical bugs or add support for new features. Check for updates every 3-6 months through Mi Home β†’ Device β†’ Software Update. Do not update the firmware on beta – this can lead to unstable work.