Skip to content

Finding Your Unit and Token

Niklas Linz edited this page Oct 3, 2026 · 1 revision

Finding your unit and token

Before you can talk to a unit you need three things: its IP address, its device id, and for V3 units a token and key. This page gets you all three. You only do it once.

The examples use made-up values (192.168.1.50, id 151732605161920). Replace them with your own.

1. Find the unit

The machine running this has to be on the same network as the air conditioner.

Command line:

java -jar midea-ac-1.0.0.jar discover
DeviceInfo[id=151732605161920, type=0xAC, ip=192.168.1.50:6444, model=00000Q1A, protocol=V3, mac=a0b1c2d3e4f5]

In code:

List<DeviceInfo> units = MideaDiscovery.discover(Duration.ofSeconds(5));

If nothing shows up, your network probably doesn't pass broadcasts (VLANs, guest Wi-Fi, client isolation). Ask the unit directly instead:

java -jar midea-ac-1.0.0.jar keys --ip 192.168.1.50
DeviceInfo dev = MideaDiscovery.discover("192.168.1.50", Duration.ofSeconds(5));

Look at protocol:

  • V2: you're done. V2 units need no token. Go to Connecting.
  • V3: continue with step 2.
  • V1: very old module, not supported.

2. Get the token and key (V3 only)

V3 units only accept connections with a token and key from the Midea cloud. The library logs in once, asks for the candidates, and tries each one against the unit with a real handshake. What you get back is known to work.

Command line, with the account of the app your unit is paired with:

java -jar midea-ac-1.0.0.jar keys --ip 192.168.1.50 --cloud msmart --user you@example.com --password secret
--id 151732605161920 --protocol 3 --port 6444
--token 4b2f...   (128 hex characters)
--key   9a1c...   (64 hex characters)
--cloud App
msmart MSmartHome (most current units in Europe)
nethome NetHome Plus
mideaair Midea Air
(left out) the shared account that Home Assistant ships with

The shared account often works too, because the token lookup isn't tied to the account that owns the unit. Try it first if you'd rather not type your password.

In code:

DeviceInfo dev = MideaDiscovery.discover("192.168.1.50", Duration.ofSeconds(5));

DeviceKey key = KeyResolver.resolve(dev, MideaCloud.msmartHome("you@example.com", "secret"))
        .orElseThrow(() -> new IllegalStateException("unit accepted none of the keys"));

System.out.println(key.token());
System.out.println(key.key());

Other cloud clients: MideaCloud.netHomePlus(user, pw), MideaCloud.mideaAir(user, pw), MideaCloud.presetAccount().

3. Store them

Put token and key somewhere safe: an environment variable, a config file outside the repository, your secret store. Never commit them.

They stay valid until the unit is reset or paired again in the app. The app keeps working alongside local control, so there's no need to remove the unit from it.

Next: Connecting

Clone this wiki locally