Skip to content

Release Notes 4.0

Sergey Brutsky edited this page Dec 3, 2026 · 1 revision

MiHomeLib 4.0

Version 4.0 completes the asynchronous transition announced in 3.5.0. Constructors no longer touch the network, information reads are explicit, value-change events carry a typed ValueChange<T>, the public API is nullable-aware and inheritance is closed except for the documented MIoT extension point. Applications upgrading from 3.x need source changes; the migration guide describes them step by step.

Breaking changes

  • Asynchronous-only API. All 272 synchronous methods marked obsolete in 3.5.0 were removed. Use the matching ...Async method. Every public asynchronous method except DisposeAsync now ends with CancellationToken cancellationToken = default, and the 3.x overload pairs were merged.
  • Constructors make no network requests. MiotGenericDevice no longer sends miIO.info while initializing, and MQTT gateways no longer open the socket in the constructor. MqttGatewayBase.ConnectAsync connects explicitly; DiscoverDevicesAsync and the first publish connect on demand. Code that relied on information properties being filled by the constructor must call await GetInfoAsync(). ToString() no longer requests the device either: XiaomiAirHumidifierV1 and XiaomiRobotVacuumCleanerV1 describe the model and address, and the state is read with GetStatusAsync().
  • Information properties removed. FirmwareVersion, Hardware, Mac, UptimeSeconds, MiioVersion, Wifi, Network, WifiSettings and NetifSettings are gone from MIoT devices (Mac remains a real property on BLE and Mesh devices). GetInfoAsync() returns a fresh MiioDeviceInfo with the same data.
  • Value-change events use ValueChange<T>. The 33 events listed in the plan now pass Previous, Current and TimestampUtc. Event names and raising conditions did not change. Action events such as clicks, vibration, alarms, discovery and connection notifications keep their old arguments.
  • Nullable reference types. The library builds with nullable diagnostics as errors. GetDeviceById<T> returns T?; gateway Sid, Ip and ProtoVersion are nullable until the first heartbeat; optional options properties are nullable while Ip and Token are not.
  • Closed inheritance. Every concrete device and gateway is sealed; the base classes and transport interfaces expose no protected or public extension surface. MiotGenericDevice is abstract and the only supported base class for custom MIoT devices, with GetPropertyAsync, SetPropertyAsync, CallActionAsync and Logger.
  • Removed obsolete names. SensivityState/SensivityMode/SetSensivityAsync/OnSmokeSensivityModeChanged, the misspelled AqaraOpple...WirelesSwitch classes, the Cyrillic Sound.PoliceСar1/2, string StatusLeft/StatusRight/Status/LastClick, MotionDate, GetDeviceByDid, the gateway SetLoggerFactory methods and the legacy gateway constructors were removed. MotionDateUtc and the typed state properties replace them.
  • Collection and value-type changes. GetDevices() returns IReadOnlyList<GatewaySubDeviceBase>. XiaomiGateway2.RadioChannel is a record (int Id, string Url, int Type). AqaraDualWallSwitch channel events pass ValueChange<SwitchChannelState>.

Features and reliability

  • Deferred MQTT connection: the first operation that needs the broker opens the connection, while the existing reconnect loop still owns recovery after a lost connection. ConnectAsync lets an application verify connectivity before discovery.
  • Timestamped value changes: ValueChange<T>.TimestampUtc is the reception time of the report, so consumers no longer read a separate property to reconstruct when a value changed.
  • Typed state instead of strings: LeftChannel/RightChannel, Contact, LastClick, Channel1/Channel2, PlugState, RelayState and the other state enums make unknown values explicit.
  • Custom MIoT devices have a small, stable contract. SetPropertyAsync<T> and CallActionAsync serialize primitives, strings, enums, JsonNode, arrays and dictionaries of those; unsupported objects throw NotSupportedException instead of using reflection.
  • Documentation examples are compiled: 121 C# blocks from the repository READMEs and the wiki are compiled against the built library, with only signature listings, historical 3.x snippets and multi-file worker service files excluded.

Physical-device validation remains the responsibility of the user for their firmware. The Gateway2 and MQTT behaviour documented on the device pages is unchanged by 4.0; only the API shape changed. Supported targets remain .NET Standard 2.0, .NET Framework 4.6.1 and 4.6.2, and .NET 10.

Wiki home · Migration guide

Clone this wiki locally