Integration of Xiaomi SmartMi Evaporative Humidifier

Introduction

I’ve managed to integrate Xiaomi Evaporative Humidifier with Loxone. This is a no-fog, no-mist, no-ultrasound device that costs ~120 EUR and doesn’t need new filter every N months. Has a large 4L water container and is recommended for rooms up to 40m2. This integration is made with ioBroker and MQTT Gateway, both run on LoxBerry.

Presentation

This is how the device looks like. 22x22cm footprint (same as Xiaomi Air Purifier 3H, just ~1/3 lower):



You may pour water in straight through the grilles on top. Device has a water level sensor and it’s available over API. There are some plates inside that rotate and a fan that pushes humidified air out:



This is how it looks in the Loxone app:



Tracker shows last 40 devices status changes. Water level field has statistics enabled. Average level over 1 hours is enough to see water consumption rate:



Maintenance Counter shows current run time and total run time. I use it to see when I should clean the plates in fresh water (or put them to dishwasher). As I’ve created own automation, I made a switch to disable it in case I wanted to set specific mode permanently. There is also a pause switch that actually powers device off and locks my custom automation. Status field is updated over MQTT so pressing physical button on the device or using Xioami Home app results in instant status change in Loxone app.



Diagrams

Diagram #1

Basic device operations. Mainly data monitoring and mode control:



The same diagram #1 but with shown configuration of non-obvious blocks:

Diagram #2

I’m not sure if I should be proud or ashamed of myself  I won’t even try to describe what it does, next screen clarifies 



So I came up with such an algorithm for now (see table below). I use different device modes (Levels 1, 2, 3) depending on Loxone operating mode and current average humidity in the living room. I don't know if it will work well in the long run – I will find out. The control is done with pulses, so if I find current mode to loud I able to manually change it to other and it stay until conditions change (humidity range or operating mode)

Communication

Internals. It was pretty easy this time since I’ve found an ioBroker adapter that worked out of the box:



Configuration requires device IP and token. Obtaining token is not the easiest task but there are some good manuals on the net.
Another challenge is if you have Chinese/ untrusted IoT devices in a separate VLAN. Miio discover doesn’t work then and ioBroker won’t see your Xiaomi device.
I overcame that issue creating a virtual IP within my IOT VLAN and configuring outbound NAT for ioBroker to that virtual IP for all udp/54321 connections to Xiaomi device.



After successful connection humidifier is shown in the list of objects. The rest is easy - configure MQTT-client settings for all relevant objects then add appropriate subscriptions to MQTT Gateway plugin on Loxberry



Summary of MQTT topics I’ve used in integration shown above

MQTT topics used as virtual inputs:

  • iobroker/mihome-humidifier/0/info/humidity

  • iobroker/mihome-humidifier/0/info/depth

  • iobroker/mihome-humidifier/0/control/power

  • iobroker/mihome-humidifier/0/control/mode

Other available but not required:

  • iobroker/mihome-humidifier/0/control/limit_hum

  • iobroker/mihome-humidifier/0/control/buzzer

  • iobroker/mihome-humidifier/0/control/led

MQTT topics used as virtual outputs:

  • loxone/mihome-humidifier/0/control/power

  • loxone/mihome-humidifier/0/control/mode

Other available but not required:

  • loxone/mihome-humidifier/0/control/limit_hum

  • loxone/mihome-humidifier/0/control/buzzer

  • loxone/mihome-humidifier/0/control/led

MQTT Gateway plugin string conversion used:

  • auto=1

  • silent=2

  • medium=3

  • high=4