- Devices: Mi Air Purifier 1 & 2, Pro
- Model identifiers:
zhimi.airpurifier.m1
,zhimi.airpurifier.v1
,zhimi.airpurifier.v2
,zhimi.airpurifier.v3
,zhimi.airpurifier.v6
Air purifiers are turned into devices of type air-purifier and by default support power switching and setting their mode. The Mi Air Purifiers are also sensors and can report the PM2.5 (air quality index), temperature and relative humidity where they are placed.
if(device.matches('type:air-purifier')) {
/*
* This device is an air purifier.
*/
}
// Get if the air purifier is on
device.power()
.then(isOn => console.log('Air purifier on:', isOn))
.catch(...);
// Using async/await
console.log('Air purifier on:', await device.power());
// Switch the air purifier on
device.setPower(true)
.then(...)
.catch(...)
// Switch on via async/await
await device.power(true);
// Read the temperature
device.temperature()
.then(temp => console.log('Temperature:', temp.celsius))
.catch(...);
// Using async/await
const temp = await device.temperature();
console.log('Temperature:', temp.celsius);
// Read the relative humidity
device.relativeHumidity()
.then(rh => console.log('Relative humidity:', rh))
.catch(...);
// Using async/await
const rh = await device.relativeHumidity();
console.log('Relative humidity:', rh);
Power - cap:power
and cap:switchable-power
device.power()
- get if the air purifier is currently activedevice.power(boolean)
- switch the air purifier on, returns a promisedevice.setPower(boolean)
- change the power state of the device, returns a promisedevice.on(power, isOn => ...)
- listen for power changes
Mode - cap:mode
and cap:switchable-mode
The air purifiers have different modes that controls their speed.
device.mode()
- get the current modedevice.mode(string)
- set the current mode of the device, returns a promisedevice.setMode(string)
- set the current mode of the device, returns a promisedevice.modes()
- read-only array indicating the modes supports by the devicedevice.on('modeChanged', mode => ...)
- listen for changes to the current mode
The modes supported change between different models, but most devices support:
idle
, turn the device offauto
, set the device to automatic mode where it controls the speed itselfsilent
, lowest speed, for silent operation or night timefavorite
, favorite level
Sensor - type:sensor
device.temperature()
- get the current temperature, seecap:temperature
for detailsdevice.on('temperature', temp => ...)
- listen to changes to the read temperaturedevice.relativeHumidity()
- get the current relative humidity, seecap:relative-humidity
for detailsdevice.on('relativeHumidityChanged', rh => ...)
- listen to changes to the relative humiditydevice.pm2_5
- get the current PM2.5 (Air Quality Index), seecap:pm2.5
for detailsdevice.on('pm2.5Changed', pm2_5 => ...)
- listen to changes to the PM2.5 value
device.buzzer()
- boolean indicating if the buzzer (beep) is activedevice.buzzer(boolean)
- switch the buzzer on or offdevice.setBuzzer(boolean)
- switch the buzzer on or off
Turn the LED indicator on the device on or off.
device.led()
- if the LED is on or offdevice.led(boolean)
- switch the LED on or off
Change the brightness of the LED on the device.
device.ledBrightness()
- the LED brightness,bright
,dim
oroff
device.ledBrightness(string)
- set the brightness of the LED
device.favoriteLevel()
- get the speed the device should run at when mode isfavorite
. Between 0 and 16.device.favoriteLevel(level)
- set the speed the device should run at when mode isfavorite
. Between 0 and 16.device.setFavoriteLevel(number)
- set the speed for modefavorite