Registry / http-networking / midea-local

midea-local

JSON →
library6.7.2pypypiunverified

midea-local is a Python library designed to control Midea M-Smart appliances directly via the local area network, bypassing the cloud. It provides an interface to discover, connect to, and manage various Midea devices such as air conditioners, dehumidifiers, and water heaters. The library is actively maintained, with frequent minor releases (typically monthly or bi-monthly) to add new features and support for more device models. The current version is 6.6.0, requiring Python >=3.11.

pip install midea-local
INSTALL
IMPORT
SIG · MIDEA-LOCAL
M
midea-local
http-networkingpythonv6.7.2
Install
5.0s avg
Import
Disk
39MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 5.25s
py 3.11
✓ —
✓ 5.3s
py 3.12
✓ —
✓ 4.75s
py 3.13
✓ —
✓ 4.85s
py 3.9
✕ build_error
✕ build_error
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Appliance
from midealocal.device import Appliance
from midealocal.appliance import Appliance

This quickstart demonstrates how to connect to a Midea appliance using its IP address, device ID, token, and key, then read its power state and toggle it, and set the target temperature for AC units. It also prints all available attributes. Remember to replace the placeholder credentials with your actual device details, which often require prior setup using other tools (like midea-discover) to extract from the official Midea app.

import asyncio import os from midea_local.appliance import Appliance from midea_local.exceptions import MideaError async def control_midea_appliance(): # Replace with your appliance's actual IP, ID, token, and key # These credentials are often difficult to obtain and may require special tools. device_ip = os.environ.get('MIDEA_DEVICE_IP', '192.168.1.100') device_id = int(os.environ.get('MIDEA_DEVICE_ID', '12345678901')) token = os.environ.get('MIDEA_DEVICE_TOKEN', 'your_32_byte_token_hex_string') # e.g., 'AABBCCDD...' (64 chars) key = os.environ.get('MIDEA_DEVICE_KEY', 'your_16_byte_key_hex_string') # e.g., '11223344...' (32 chars) if not all([device_ip, device_id, token, key]): print("Please set MIDEA_DEVICE_IP, MIDEA_DEVICE_ID, MIDEA_DEVICE_TOKEN, and MIDEA_DEVICE_KEY environment variables.") return try: # Find and create the appliance instance # protocol_version can be 1 or 3, 3 is default and for newer devices. appliance = await Appliance.find_and_create_appliance( device_ip, device_id, token, key, protocol_version=3 ) if appliance: print(f"Connected to appliance: {appliance.name} ({appliance.ip_address})") print(f"Current power state: {appliance.power_state}") # Example: Turn on the appliance if it's off if not appliance.power_state: print("Turning appliance ON...") await appliance.set_attribute("power_state", True) await appliance.refresh() print(f"New power state: {appliance.power_state}") # Example: Set target temperature (for AC units) if hasattr(appliance, 'target_temperature'): current_temp = appliance.target_temperature new_temp = current_temp + 1 if current_temp < 30 else 20 # Cycle temperature print(f"Setting target temperature from {current_temp}°C to {new_temp}°C...") await appliance.set_attribute("target_temperature", new_temp) await appliance.refresh() print(f"New target temperature: {appliance.target_temperature}°C") # Example: Print all available attributes and their values print("\n--- Appliance Attributes ---") for attr in dir(appliance): if not attr.startswith('_') and not callable(getattr(appliance, attr)): try: print(f"{attr}: {getattr(appliance, attr)}") except Exception: pass # Some attributes might not be directly readable else: print("Failed to find or connect to the appliance.") except MideaError as e: print(f"MideaError: {e}") except Exception as e: print(f"An unexpected error occurred: {e}") if __name__ == "__main__": asyncio.run(control_midea_appliance())
Debug
Known issues
breakingThe primary class for Midea cloud interactions (`midea_local.cloud`) was refactored in v6.0.0. If you were directly using `midea_local.cloud.MSmartHomeAppliance` (pre-6.0.0) for cloud operations (e.g., discovery or obtaining credentials), you must now use `midea_local.cloud.MSmartHome`.
fix
Update your import statement and class instantiation from `from midea_local.cloud import MSmartHomeAppliance` to `from midea_local.cloud import MSmartHome`.
affects: >=6.0.0
gotchaObtaining the `token` (32-byte hex string) and `key` (16-byte hex string) for Midea devices is the most common hurdle for local control. These credentials are device-specific and are not easily found in the official Midea app. Users often resort to third-party tools (e.g., midea-discover), network traffic sniffing, or older versions of the Midea app to extract them.
fix
Consult the `midea-local` GitHub repository's README or community forums for methods to acquire your device's `token` and `key` before attempting to use the library.
affects: All versions
gotchaMidea appliances exhibit significant variations in their supported features, firmware, and communication protocols. Not all devices or all features of a device may be fully supported by the library, or they might require a specific `protocol_version` when instantiating the `Appliance` object.
fix
If a feature is not working or an attribute is missing, check the device type/model specific discussions in the `midea-local` GitHub issues. You might need to experiment with `protocol_version` (e.g., `protocol_version=1` for older devices) or update your library version for newer device support.
affects: All versions
Upgrade
Version history
6.7.2latest on PyPI · released Jun 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
32
Amazon
1
Resources
midea-local — pip install midea-local · libregistry