Repository navigation
Air Humidifier (CJJSQ01ZM)
Version 4.0 API. Namespace MiHomeLib.MiioDevices.
The current class declares model zhimi.humidifier.v1 and market model CJJSQ01ZM. The existing wiki page URL contains the earlier MJJSQ03DY label.
Before using this device you need to get ip/token
Please follow this guide to get them
Construct the device with its IP and token, and dispose it when finished. Constructors make no network requests; the first call that needs the connection makes it. Get methods request fresh values. Every operation is asynchronous and accepts an optional CancellationToken. Commands can change device settings or start physical actions.
using System;
using System.Threading.Tasks;
using MiHomeLib.MiioDevices;
public static class XiaomiAirHumidifierV1WikiExample
{
public static async Task ReadAsync(string ip, string token)
{
using var device = new XiaomiAirHumidifierV1(ip, token);
var status = await device.GetStatusAsync();
Console.WriteLine(status);
}
}The shared discovery API returns miio hello metadata from the local network. Obtain the authenticated device token through the setup guide. The legacy class-specific discovery methods and OnDiscovered event were removed in 4.0.
using System;
using System.Threading.Tasks;
using MiHomeLib.MiioDevices;
public static class XiaomiAirHumidifierV1DiscoveryWikiExample
{
public static async Task DiscoverAsync()
{
var devices = await MiioDiscovery.DiscoverAsync();
foreach (var device in devices)
Console.WriteLine($"{device.Ip} {device.DeviceType} {device.Serial}");
}
}Use GetStatusAsync for a fresh status snapshot. GetTemperatureAsync returns degrees Celsius and GetHumidity/GetTargetHumidity return percentages. Mode and Brightness values are listed below.
Optional LAN discovery is available through MiioDiscovery.DiscoverAsync.
Snapshot properties are local values from that read. For nonrepeatable commands, a lost response can leave the outcome unknown. Inspect device state before deciding whether to resend an action.
-
XiaomiAirHumidifierV1(string ip, string token). -
XiaomiAirHumidifierV1(MiioDeviceOptions options).
All methods are asynchronous and accept an optional CancellationToken. Synchronous methods were removed in 4.0.
-
Task<XiaomiAirHumidifierV1.DeviceStatus> GetStatusAsync(CancellationToken cancellationToken = default)— Reads the current status in one request without retaining a cached state. -
Task<bool> GetPowerStateAsync(CancellationToken cancellationToken = default). -
Task TurnOnAsync(CancellationToken cancellationToken = default). -
Task TurnOffAsync(CancellationToken cancellationToken = default). -
Task<XiaomiAirHumidifierV1.Mode> GetModeAsync(CancellationToken cancellationToken = default). -
Task SetModeAsync(XiaomiAirHumidifierV1.Mode mode, CancellationToken cancellationToken = default). -
Task<float> GetTemperatureAsync(CancellationToken cancellationToken = default). -
Task<int> GetHumidityAsync(CancellationToken cancellationToken = default). -
Task<XiaomiAirHumidifierV1.Brightness> GetBrightnessAsync(CancellationToken cancellationToken = default). -
Task SetBrightnessAsync(XiaomiAirHumidifierV1.Brightness brightness, CancellationToken cancellationToken = default). -
Task<int> GetTargetHumidityAsync(CancellationToken cancellationToken = default). -
Task<bool> GetBuzzerEnabledAsync(CancellationToken cancellationToken = default). -
Task SetBuzzerEnabledAsync(bool enabled, CancellationToken cancellationToken = default)— Sets whether buzzer is enabled on the device. -
Task<bool> GetChildLockEnabledAsync(CancellationToken cancellationToken = default). -
Task SetChildLockEnabledAsync(bool enabled, CancellationToken cancellationToken = default)— Sets whether child lock is enabled on the device.
-
Modevalues areSilent = 0,Medium = 1,High = 2. -
Brightnessvalues areBright = 0,Dim = 1,Off = 2. -
DeviceStatuscontainsbool IsTurnedOn,XiaomiAirHumidifierV1.Mode Mode,float Temperature,int Humidity,XiaomiAirHumidifierV1.Brightness LedBrightness,bool IsBuzzerOn,bool IsChildLockOn,int TargetHumidity.
Wiki home · Release notes · Migration guide
Synchronous methods were removed in 4.0.
Prefer async/await. If the caller cannot be asynchronous, use the following pattern. The example builds the objects it needs and blocks on the asynchronous calls.
var device = new MiHomeLib.MiioDevices.XiaomiAirHumidifierV1(ip, token);
device.TurnOnAsync().GetAwaiter().GetResult();
var isOn = device.GetPowerStateAsync().GetAwaiter().GetResult();
Console.WriteLine(isOn);MiHomeLib does not capture the caller's synchronization context for its internal awaits. Blocking still occupies the calling thread; prefer asynchronous code in UI applications and avoid blocking handlers that need that same thread. GetAwaiter().GetResult() throws the original exception directly.
See the 4.0 migration guide.