Sending Commands - LinzN/midea2mqtt GitHub Wiki
There are two ways to send a command. Both do the same thing.
# JSON on .../set: any number of keys at once
mosquitto_pub -t midea2mqtt/livingroom/set -m '{"mode":"cool","targetTemperature":22.5,"fanSpeed":"auto"}'
# plain value on .../set/<key>: one key per message
mosquitto_pub -t midea2mqtt/livingroom/set/targetTemperature -m 21Use the JSON form when you change several things: they go out as one command, so the unit beeps once and never passes through intermediate states.
Values are flexible: booleans can be true/false, "on"/"off", 1/0 or "yes"/"no"; numbers can be JSON numbers or strings; enum values are case insensitive and accept - or a space instead of _ (fan-only, Fan Only).
Every key has the same name and value format as in the state.
These are always sent together as one command, together with the unit's other current settings.
| Key | Values |
|---|---|
power |
boolean |
mode |
auto, cool, dry, heat, fan_only. Also switches the unit on |
targetTemperature |
16 to 31.5, rounded to 0.5 |
fanSpeed |
silent, low, medium, high, full, auto, or a number 1–100 (102 = auto) for stepless fans |
swing |
off, vertical, horizontal, both
|
preset |
none, comfort, eco, boost, sleep, away. Selecting one clears the others and power saving |
powerSaving |
boolean, exclusive with the presets |
auxHeating, dry, smartEye, naturalWind, anion
|
boolean |
fahrenheit |
boolean, temperature unit on the unit's display |
Each of these goes out as its own command, after the basic settings. Not every unit has every feature; check the capabilities.
| Key | Values |
|---|---|
screenDisplay |
boolean. The unit only knows "toggle", so nothing is sent if the display is already in the requested state |
screenDisplayAlternate |
boolean, display on units using the newer protocol |
breezeless |
boolean, draught-free mode |
indirectWind |
boolean, keep the airflow off people |
horizontalVane |
off, left, left_mid, middle, right_mid, right
|
verticalVane |
off, up, up_mid, middle, down_mid, down
|
outdoorSilent |
boolean, quiet outdoor unit |
sound |
boolean, indoor unit buzzer |
selfClean |
boolean, self cleaning cycle |
rateSelect |
power limit: 1, 20, 40, 60, 80, 100, or 50, 75, 100 on two-level units |
freshAir |
boolean, fresh air module. Keeps the current fan speed, or 100 if it was 0 |
freshAirFanSpeed |
0 to 100. Alone it also switches the module on (speed > 0) or off (0) |
Read-only keys such as indoorTemperature, fanSpeedRaw or eco are rejected; use preset to switch eco on.
-
poweris applied last within the basic settings.{"power": false, "mode": "heat"}sets heat mode and leaves the unit off; without thepowerkey, setting a mode switches the unit on. - Coming out of
dry, the fan goes back to auto unless the same command setsfanSpeed. - Basic settings first, then the extra features.
The whole command is checked before anything is sent. An unknown key, a read-only key or an invalid value rejects the command, and the unit isn't touched.
Problems are published to <base>/<device>/error (not retained):
{
"topic": "midea2mqtt/livingroom/set",
"payload": "{\"mode\":\"turbo\"}",
"error": "'mode': 'turbo' is not one of auto, cool, dry, heat, fan_only"
}| Error | Cause |
|---|---|
unknown or read-only key 'x' |
typo, or a key that can only be read |
'mode': 'x' is not one of ... |
invalid enum value, the message lists the valid ones |
'targetTemperature': 'x' is not a number |
|
payload is not a JSON object |
on .../set, the payload must be {...}
|
basic settings: ... |
the unit rejected or didn't take the basic command, e.g. temperature out of range |
<key>: ... |
an extra feature failed, e.g. fresh air on a unit without the module |
unit not reachable: ... |
network problem; the bridge keeps reconnecting in the background |
If an extra feature fails, the other parts of the same command still go through; each failure is reported separately.
There is no separate acknowledgement. When the unit confirms a command, the new state appears on <base>/<device>/state right away. If no confirmation comes, the requested values show up anyway and the next refresh corrects them if the unit didn't follow (see How it behaves).
# off
mosquitto_pub -t midea2mqtt/livingroom/set -m '{"power": false}'
# heat to 21 °C, quiet fan
mosquitto_pub -t midea2mqtt/livingroom/set -m '{"mode":"heat","targetTemperature":21,"fanSpeed":"silent"}'
# eco preset on, swing off
mosquitto_pub -t midea2mqtt/livingroom/set -m '{"preset":"eco","swing":"off"}'
# display off and louver fixed in the middle
mosquitto_pub -t midea2mqtt/livingroom/set -m '{"screenDisplay":false,"verticalVane":"middle"}'
# single values
mosquitto_pub -t midea2mqtt/livingroom/set/mode -m fan_only
mosquitto_pub -t midea2mqtt/livingroom/set/power -m on