Skip to content

About

ESPHome for Midea, Inventor, Comfee Dehumidifiers

Resources

Stars

90 stars

Watchers

3 watching

Forks

Repository files navigation

Support Chreece on Ko-fi

esp8266-midea-dehumidifier

Free your dehumidifier from the cloud — now with ESPHome

This project is an ESPHome-based port of Hypfer’s esp8266-midea-dehumidifier. While the original version used a custom MQTT firmware, this one is a native ESPHome component, providing full Home Assistant integration without MQTT or cloud dependencies. Minimum ESPHome version: 2025.11

Example entities for Inventor EVA II pro:

image image image

✨ Features

This component allows you to directly control and monitor Midea-based dehumidifiers via UART, completely bypassing the Midea cloud dongle.

Supported entities:

Entity Type Description
Climate Power, mode, fan speed, swing (vertical/horizontal) and presets
Bucket Full Binary Sensor (optional) "Bucket Full" indicator
Clean Filter Binary Sensor (optional) "Clean Filter" notification if supported
Defrosting Binary Sensor (optional) Defrosting indicator if supported
Error Sensor (optional) Reports current error code
Tank Water Level Sensor (optional) Reports current tank water level
Humidity Sensor (optional) Reports current ambient humidity (chartable in HA)
Temperature Sensor (optional) Reports current ambient temperature (chartable in HA)
PM2.5 Sensor (optional) Reports PM2.5 particles from sensor if supported
ION Switch (optional) Controls ionizer state if supported
Beep Switch (optional) Controls buzzer on HA commands if supported
Sleep Switch (optional) Controls sleep mode if supported
Pump Switch (optional) Controls pump if supported
Timer Number (optional) Controls the internal device timer if supported
Target Humidity Number (optional) Standalone humidity setpoint control
Filter Cleaned Button (optional) Resets the filter clean notification
Reset Water Level Button (optional) Resets the water-level runtime counter
Capabilities Text Sensor (optional) Shows discovered device capabilities
Protocol Text Sensor (optional) Shows active protocol version (V1/V2/auto)

Optional entities can be included or excluded simply by adding or omitting them from your YAML.


🧠 Background

Midea-made dehumidifiers (sold under brands like Inventor, Comfee, Midea, etc.) use a UART-based protocol behind their “WiFi SmartKey” dongles.

Those dongles wrap simple serial communication in cloud encryption and authentication layers. By connecting directly to the UART pins inside the unit, you can fully control it locally — no cloud, no reverse proxy, no token handshakes.


🧩 Compatibility

Confirmed & Expected Models

If unsure, use protocol_version: 0 (auto-detect) — it tries both protocols at boot. Models marked ? need verification but are expected to work.

Brand Name Model Protocol
Midea Cube 20 Pint MAD20S1QWT v1
Midea Cube 35 Pint MAD35S1QWT v1
Midea Cube 50 Pint MAD50S1QWT ?
Midea Cube 50 Pint with Pump MAD50PS1QWT ?
Midea Cube 50 Pint with Pump MAD50PS1QWT-A v2
Midea Cube 50 Pint with Pump MAD50PS1QWT-B ?
Midea Cube 50 Pint with Pump MAD50PS1QWT-S ?
Midea Cube 50 Pint with Pump (GR) MAD50PS1QGR ?
Midea 50 Pint with Pump MAD50PS1BWT-C v2
Midea Dehumidifier MAD22S1WWT v1
Midea Dehumidifier MAD50C1AWS v1
Comfee Dehumidifier MDDF-16DEN7-WF v1
Comfee Dehumidifier MDDF-20DEN7-WF v1
Comfee Dehumidifier CDDF7-16DEN7-WFI v1
Inventor Eva II PRO Wi-Fi v1
Inventor EVA ION PRO Wi-Fi 20L v1
Emelson Dehumidifier EMLDH20DFR29 v1

Protocol versions:

  • 0 — auto-detect (default) — Alternates V1/V2 every 1s until the MCU responds, then locks in the matching protocol. Gives up after 2 minutes if no response. Tries the implemented protocol variants; compatibility with unlisted models still needs verification. Enable handshake_enabled to run discovery.
  • 1 — Original implementation. Works with most Midea-based dehumidifiers.
  • 2 — Based off of the stock RTL8720 dongle (MAD50PS1QWT-A verified).

Only the selected version(s) are compiled into firmware, keeping flash usage minimal. Pin the protocol with protocol_version: 1 or protocol_version: 2 if you know your device — it skips the auto-detect window and speeds up boot.

Models without USB or Wi-Fi button (e.g., Comfee MDDF-20DEN7, Emelson EMLDH20DFR29) could also work with small wiring changes.

For the full V2 wire protocol specification (frame layouts, handshake sequence, status byte map), see protocol_v2.md.


🧰 Hardware Setup

You’ll need:

  • An ESP32 or ESP8266 board with accessible UART pins.
  • A passive connector breakout or suitable appliance UART adapter.
  • A regulated supply compatible with the ESP board.
  • Logic-level conversion wherever the appliance and ESP signal levels differ.

Passive USB-A breakout with exposed contacts

Connection requirements

On supported appliances that use a USB-A Wi-Fi socket, the connector carries UART at 9600 baud, not USB data. A computer USB-to-serial programmer, USB hub or ordinary USB peripheral cannot serve as a direct UART connection through its USB port. A charge-only cable does not provide the necessary data contacts.

Use a passive breakout or an adapter designed for the appliance interface. Verify connector orientation, power, ground, TX/RX and signal levels before wiring.

Verified appliance signal Connect to
MCU TX ESP RX, with level conversion if required
MCU RX ESP TX, with level conversion if required
GND Common ground
Supply A compatible board power input or regulator

Supply voltage and GPIO voltage

5 V power input does not make an ESP's GPIO 5 V tolerant. Do not apply a 5 V UART signal directly to ESP8266 or ESP32 GPIO. Bare 3.3 V modules need regulated 3.3 V power. Direct UART wiring is suitable only when both devices' signal levels are compatible or conversion is already present.

See HARDWARE.md for adapter categories, wiring principles, power and signal-level requirements, UART configuration and troubleshooting.


⚙️ ESPHome Configuration

For an adjustable humidity target, select Setpoint (manual dehumidification) if your unit supports it. The firmware accepts targets from 35% to 85%. If your YAML has display_mode_setpoint: 'UNUSED', remove that line to expose the preset.

In Continuous, many units keep reporting a stored target such as 50% while drying below it. The climate entity and optional target number show the value returned by the appliance in this preset. The Drying action is an estimate based on the selected preset, power and status flags. A full or removed tank or a defrost cycle can put the action back to Idle.

Automatic fan speeds

Fan capabilities are detected separately from the UART protocol. Leave fan_speed_count out of your YAML to use automatic detection with either V1 or V2. No device-name rule or model-specific setting is required.

The component queries the appliance's capabilities even when the optional capabilities text sensor is absent. Recognized responses select Low/High, Low/Medium/High, or Auto only. The detected profile is cached through ESPHome preferences and restored when available at the next boot; a fresh capability response can update it. The cache belongs to the ESPHome component configuration, not a verified appliance identity, so fresh status observations can expand cached options when the appliance returns no recognized capability response. Fan state in Home Assistant follows the appliance's response, so sending a command alone does not confirm that the requested speed took effect. Changes to humidity, timers, or other features preserve the fan value reported by the appliance.

When the fan profile is unknown, Low/Medium/High remain available as fallback choices. A Medium request sends the actual middle value instead of converting it to High because V2 is active. Three consistent, valid polled reports of the middle value during normal Setpoint or Continuous operation can establish three-speed support without sending test commands. This does not exclude Auto: repeated Auto feedback can add Auto, and learned Medium and Auto support are retained together regardless of observation order or reboot. Passive feedback does not establish an exhaustive list; only a fresh capability response does. These fallback choices do not guarantee that every appliance supports all three manual speeds. Explicit 2 or 3 overrides take precedence over both capability responses and passive learning.

At startup, discovery may delay the native API connection by up to eight seconds so Home Assistant can receive the detected fan options in its first entity listing. If discovery finishes later, or a later response changes the profile, updated options appear on the next API reconnect. The log indicates when a refresh is needed; reload the affected ESPHome integration if its fan options remain stale. The firmware does not force clients to disconnect, which also avoids retriggering api.on_client_connected automations.

An explicit override is available for appliances that need one:

fan_speed_count Behavior
Omitted or 0 Automatic capability detection; recommended default
2 Explicit Low/High override
3 Explicit Low/Medium/High override

Compile and install the updated firmware to use automatic detection. Existing explicit 2 or 3 settings remain overrides; remove them or use 0 to enable detection. See the fan protocol notes for the capability values, fallback rules, and hardware verification limits.

Example YAML with all supported sensors - controls, full example in dehumidifier.yaml:

external_components:
  - source:
      type: git
      url: https://github.com/Chreece/ESPHome-Dehumidifier
      ref: main
    components: [midea_dehum]
    refresh: 0min

uart:
  id: uart_midea
  tx_pin: GPIO16 # replace with the TX pin used from esp
  rx_pin: GPIO17 # replace with the RX pin used from esp
  baud_rate: 9600

midea_dehum:
  id: midea_dehum_comp
  uart_id: uart_midea
  # protocol_version: 0  # 0=auto-detect (default), 1=V1, 2=V2 — pin if known to speed up boot
  # fan_speed_count: 0  # Default: automatic; optional overrides: 2=Low/High, 3=Low/Medium/High
  handshake_enabled: false # Optional if you have problems with unknown states on esp boot
  handshake_fallback_timeout: 15000 # Optional, ms to wait for the handshake's final status frame before polling anyway. 0=wait forever. Default: 15000ms
  status_poll_interval: 1000 # Optional, how often should get a status update in ms (1000ms=1sec). Default: 1000ms

  # 🆕 Optional: Rename display modes to match your device’s front panel.
  # For example, your unit may label these as “Cont”, “Dry”, or “Smart”.
  # These names only affect how the presets appear in Home Assistant —
  # the internal logic and protocol remain the same.
  # 💡 Tip:
  # If any of the modes below are set to "UNUSED" (case-insensitive),
  # that preset will NOT appear in the Home Assistant UI.
  # Use this if your device doesn’t support or respond to a specific mode.
  # For instance, if pressing “SMART”, your unit doesn't change any mode,
  # set display_mode_smart: "UNUSED" to hide it from the UI.
  display_mode_setpoint: 'Setpoint'
  display_mode_continuous: 'Cont'
  display_mode_smart: 'Smart'
  display_mode_clothes_drying: 'Dry'

climate:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
    name: "Inventor Dehumidifier"
# Optional vertical swing control (if supported)
    swing: true
# Optional horizontal swing control (if supported)
    horizontal_swing: true

binary_sensor:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
# Optional sensor to inform when the Bucket is full
    bucket_full:
      name: "Bucket Full"
# Optional sensor to inform that a filter cleaning is required (only if supported)
    clean_filter:
      name: "Clean Filter Request"
# Optional sensor to inform if the defrosting procedure running (only if supported)
    defrost:
      name: "Defrosting"

button:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
# Optional button to reset the filter clean binary_sensor
    filter_cleaned:
      name: "Reset Filter Cleaning"
# Optional button to reset the water-level runtime counter (V2 only)
    reset_water_level:
      name: "Reset Water Level"

# Optional error sensor remove this block if not needed
sensor:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
    error:
      name: "Error Code"
# Optional tank water level sensor (if supported)
    tank_level:
      name: "Tank water level"
# Optional current humidity sensor (chartable in Home Assistant)
    humidity:
      name: "Current Humidity"
# Optional current temperature sensor (chartable in Home Assistant)
    temperature:
      name: "Current Temperature"
# Optional pm2.5 sensor (if supported)
    pm25:
      name: "pm2.5"

# Optional switches
switch:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
# Optional ionizer control, add this block only if your device has Ionizer
    ionizer:
      name: "Ionizer"
# Optional control the device pump (if supported)
    pump:
      name: 'Pump'
# Optional sleep mode toggle (not all models support this)
# Enables or disables “Sleep” mode if available on your device (not tested!).
    sleep:
      name: "Sleep Mode"
# Optional beep control
# When enabled, the device will emit a beep sound when it receives
# commands (e.g. from Home Assistant or OTA updates).
    beep:
      name: "Beep on Command"

# Optional timer number entity for the internal device timer
# When device off -> timer to turn on
# When device on -> timer to turn off
# Toggling the device on/off resets the timer
# 0.5h increments, max: 24h
number:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
    timer:
      name: "Internal Device Timer"
# Optional standalone humidity setpoint control (35-85%)
    target_humidity:
      name: "Target Humidity"

# Optional text sensors
text_sensor:
  - platform: midea_dehum
    midea_dehum_id: midea_dehum_comp
# Optional text sensor to show discovered device capabilities
# Useful for diagnostics — helps confirm which features your model supports.
# (Note: Not all capabilities are necessarily showed.)
    capabilities:
      name: "Device Capabilities"
# Optional text sensor showing the active protocol version (V1/V2/auto)
    protocol:
      name: "Protocol Version"

All entities appear automatically in Home Assistant with native ESPHome support.


🧩 Component Architecture

File Purpose
midea_dehum.cpp / midea_dehum.h Core component class, climate control, packet dispatch
midea_dehum_uart.cpp Low-level UART transport — frame assembly, CRC, TX/RX
midea_dehum_state.cpp Status frame decoder — parses 36-byte status into component fields
midea_dehum_fan.cpp Fan capability discovery, passive learning and preference cache
midea_dehum_features.cpp Optional feature implementations (ion, pump, beep, sleep, timer, capabilities)
midea_dehum_protocol.h ProtocolVTable interface — one struct per version
midea_dehum_protocol_v1.cpp Protocol v1: Chreece original handshake + status logic
midea_dehum_protocol_v2.cpp Protocol v2: MAD50PS1QWT-A verified handshake + Midea Cube 50 support
midea_dehum_protocol_auto.cpp / .h Auto-detect state machine (only compiled when protocol_version: 0)
__init__.py Main component config — UART wiring, protocol selection, display modes
climate.py Climate entity — mode, fan, humidity, swing
binary_sensor.py Bucket full, clean filter, defrosting sensors
button.py Filter cleaned + reset water level buttons
sensor.py Error code, tank water level, humidity, temperature, PM2.5 sensors
switch.py Ionizer, beep, sleep, pump switches
number.py Timer + target humidity number entities
text_sensor.py Device capabilities + protocol version text sensors

🧪 Supported Features

  • Power on/off
  • Mode control (Setpoint, Continuous, Smart, ClothesDrying, etc.)
  • Fan speed control
  • Humidity control target & current humidity (via native ESPHome climate interface)
  • Standalone target humidity number entity
  • Standalone current humidity sensor (chartable in Home Assistant)
  • Current temperature (via climate interface)
  • Standalone current temperature sensor (chartable in Home Assistant)
  • PM2.5 level
  • Tank water level
  • Bucket full status
  • Defrosting status
  • Clean filter request
  • Filter cleaned button
  • Reset water level button
  • Error code reporting
  • Ionizer toggle
  • Vertical swing control
  • Horizontal swing control
  • Buzzer (beep) control on HA commands
  • Pump switch
  • Sleep switch
  • On/Off timer
  • Device capabilities discovery
  • Protocol version reporting (V1/V2/auto-detect)

Note: The temperature and humidity values from the device aren't always reliable — better not use them for automations. The standalone humidity and temperature sensors are provided for monitoring/charting convenience.


⚠️ Safety Notice

Many of these dehumidifiers use R290 (Propane) as refrigerant. This gas is flammable. Be extremely careful when opening or modifying your unit. Avoid sparks, heat, or metal contact that could pierce the sealed system.


⚠️ Disclaimer

This project interacts directly with hardware inside a mains-powered appliance that may use R290 (propane) refrigerant. Modifying or opening such devices can be dangerous and may cause electric shock, fire, or injury if not done safely.

By using this project, you agree that:

You perform all modifications at your own risk.

The author(s) and contributors are not responsible for any damage, data loss, or injury.

Always disconnect power before working on the device.

Never operate the unit open or modified near flammable materials.

If you’re not confident working with electrical components, don’t attempt this modification.


🧑‍💻 Contributors and credits

This ESPHome component builds on Hypfer's original esp8266-midea-dehumidifier project. Thank you to Hypfer and the original project's contributors for that foundation.

Thank you to everyone who has contributed to this repository:

Contributor Contributions
CDank Swing control, native humidity integration and entity improvements
gfaidley V1 handshake completion, network-status handling and status-query fixes
kratz00 ESPHome compatibility updates and follow-up fixes
nbogojevic Startup state handling, handshake fallback, polling reliability and regression tests
Rogue136198 Hardware compatibility testing and supported-model documentation
sargas V1 handshake investigation, protocol analysis and test contributions
sirwolfgang V2 protocol support, automatic protocol detection, test infrastructure, component architecture and hardware/protocol documentation

Thanks also to everyone who reports bugs, verifies hardware, shares logs, reviews changes and improves documentation.

See the contributor history for contributions over time.

About

ESPHome for Midea, Inventor, Comfee Dehumidifiers

Resources

Stars

90 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages