Midea Portasplit (Air Conditioner) - MQTT bridge

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

Post Reply
dzdm
Posts: 15
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Midea Portasplit (Air Conditioner) - MQTT bridge

Post by dzdm »

Hi,

I wrote a small Python bridge (see attachment) that connects Midea/Comfee/Electra split ACs via msmart-ng (only local LAN supported) to Domoticz using the native domoticz/in + domoticz/out MQTT topics. No plugins, no extra hardware — just a script running as a systemd service.

Features:

- Full bidirectional control: power, mode, fan speed, swing, target temperature
- Reads indoor + outdoor temperature
- Eco, Turbo, iECO, Purifier/ION, Freeze Protection, Rate Select, Self-Clean
- Display (LED) toggle
- Energy monitoring (real-time Watt + kWh counter)
- Configurable polling interval
- Pure JSON config file

Requirements:

msmart-ng (Midea LAN protocol library)
paho-mqtt >= 2.1.0
Domoticz with MQTT broker

How it works:

The bridge polls the AC directly over LAN every N seconds (default 30 s) and publishes state to Domoticz virtual devices. Commands from Domoticz Selector/Switch devices are forwarded to the AC in real time. You first have to setup msmart-ng (https://github.com/mill1000/midea-msmart):

msmart-ng discover <ip of your midea>

Note your midea id, key and token and add them to config.json. Additionally, the domoticz devices need to be created manually (virtual sensors/switches/selectors) - more details in SETUP.md


Tested with msmart-ng 2026.4.1, but should work with any device supported by msmart-ng.


Have fun :)
Attachments
midea-mqtt.tar.gz
Midea MQTT bridge
(7.84 KiB) Downloaded 61 times
User avatar
waltervl
Posts: 7020
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2026.3
Location: NL
Contact:

Re: Midea Portasplit (Air Conditioner) - MQTT bridge

Post by waltervl »

If your airco is not compatible with the existing python plugin I can understand you wrote something different.

But the suggestions your solution is more easy than a python plugin is doubtful. But perhaps I interpreted it incorrectly..
For python plugin:
Install the plugin and its required python modules, activate it in Domoticz and go. Devices will be created automatically.

In your solution
Install the script and its required python module, make it a service (how?), manually create all the required virtual devices (and first enable the hardware gateway), create the configuration file.

So definitely not simpler than simply install a python plugin (in my humble opinion :) )
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
dzdm
Posts: 15
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Re: Midea Portasplit (Air Conditioner) - MQTT bridge

Post by dzdm »

Hey,

I just did a quick google search for domoticz and midea and I only found one plugin (https://github.com/hubertverstraete/Qlima/), but this seemed to use midea-discover which did not work with my AC. So I just created this bridge. Usage is really simple, create virtual devices, edit config, install the systemd config and start the service, that's it (ok pip3 install <module> is also required ;)

And for the the domoticz python plugin support - honestly, I don't like it. I had many problems with different plugins in the past, which lead to hard to debug crashes of domoticz, so I got rid of most of them (maybe this has changed during the last versions though).

So I just shared it, if someone likes to use it - fine - if not - that's also fine for me ;)
Post Reply