Skip to content
kovapatrik edited this page Feb 25, 2024 · 4 revisions

Unofficial plugin for Midea. This is implemented by building on the Homebridge platform plugin template and the work done by @georgezhao2010 in the midea_ac_lan project for Home Assistant.

Supported devices

Currently supports the following devices:

Device ID Docs
Air Conditioner AC link
Dehumidifier A1 link
Electric Water Heater E2 link
Gas Water Heater E3 link

Device Discovery

Midea devices use different communication protocols. Protocol version 3 needs credentials for each device. Credentials for these Midea devices on your Local Area Network (LAN) must be retrieved from Midea cloud server, this is done through the Settings window in the Homebridge Config User Interface. On opening the settings window, click on Discover Devices and enter the requested information. You can run the discovery without providing your login credentials, however in this case if a protocol version 3 device is found in your network, it cannot be added. If you see *No credentials" instead of an Add or Update button then you must provide your login credentials.

  • Registered app (optional): Name of the Midea mobile app that you registered your userid and password with. Defaults to Midea SmartHome (MSmartHome), but you can also select NetHome Plus or Meiju.
  • Username (optional): Email address / userid that you use to login to the Midea cloud service.
  • Password (optional): Password for Midea cloud service.
  • IP Addresses (optional): Comma- or space-separated list of device IP addresses.

On clicking Discover All Devices the plugin sends a message to the broadcast address for the subnet of each network interface attached to the Homebridge server. Midea devices attached to the network will respond. Network discovery is repeated multiple times (currently 4 times at interval of 2 seconds between each). At the end of the process details of all devices discovered are listed in the Settings window. From there, you can add new devices or update the token/key credentials for existing devices. You can then edit details for each device (for example change the name).

If your Midea device is not connected to the same LAN subnet as your Homebridge server then you must manually add the IP addresses of each device before running discovery. Add a space- or comma-separated list of IP addresses to the entry field above the Discover All devices button.

You must click Save button to update the Homebridge config.json file and restart the plugin.

Midea cloud credentals (Username / Password) are not saved as these are only required for retrieval of each device token/key pair. Once those are known and saved this plugin no longer accesses Midea cloud servers over the internet.

Plugin Initialization

When the plugin initializes it attempts to find all devices attached to the Local Area Network (LAN) by sending a message to the broadcast address of the subnet for each network interface attached to the Homebridge server. Midea devices attached to the network will respond and are checked against devices configured in the plugin platform config.json file. Network discovery is repeated multiple times (currently 4 times at interval of 2 seconds between each).

At the end of the discovery process, if there are devices configured in the devices array with deviceID that was not discovered, then a warning is noted in the log and the plugin will retry every 60 seconds until the missing device comes online.

Unsupported devices

If you have a device not supported by the plugin then useful information will be logged as warnings. If you are interested in developing support for a device please contact the authors by opening an issue.

Deleting a device

If you delete a device in the plugin settings window, or the Homebridge config.json file, then note that this does not delete the cached accessory from Homebridge... the device will still be visible in Homebridge and Apple Home, but it will not respond to any requests or update any data. To remove the device from Apple Home you must use Homebridge Settings and select Remove Single Cached Accessory to complete the deletion. Caution: removing an accessory from Apple Home may impact any automations that are dependent on the accessory, possibly deleting the automations.

Technical Notes

Network Resiliency

Various strategies are employed in an attempt to handle an unstable network. If a failure occurs at any point while accessing the network or Midea devices then the plugin will attempt to reconnect. During testing we have observed that if a Midea device is isolated from the public internet, and therefore unable to connect to Midea cloud servers, it will close the internal LAN connection to this plugin after a few minutes. The plugin is able to recover and reopen this connection. See logging setion below.

Logging

Device status changes, for example temperature or humidity changes are logged into the Homebridge log as are any warnings or errors. This includes errors that the plugin can recover from. If your log is filling up with recoverable errors you can suppress these by setting logRecoverableErrors to false. You can turn on debug log by running Homebridge with debug enabled, in the Homebridge UI you can set this in Homebridge Settings.

By default the plugin does not debug-log all network traffic. If you are developing support for a new device it may be helpful to turn this on by setting verbose to true.

The custom UI settings window performs device discovery on your network. To enable debug log for this process you must enable uiDebug in the settings. Server side debug will log to the Homebridge log, client side debug will log to the browser javascript console.