Repository navigation
Home Assistant
The bridge doesn't announce itself through MQTT discovery (yet), so the unit is added with a few lines of YAML. Replace livingroom with your device name.
Remove the unit from Home Assistant's own
mideaintegration first, or switch that integration off. Most Wi-Fi modules accept only one connection, and two clients will keep pushing each other off.
In configuration.yaml:
mqtt:
climate:
- name: "Living room AC"
unique_id: midea2mqtt_livingroom
availability:
- topic: midea2mqtt/bridge/status
- topic: midea2mqtt/livingroom/availability
availability_mode: all
# mode, including "off"
modes: ["off", "auto", "cool", "dry", "heat", "fan_only"]
mode_state_topic: midea2mqtt/livingroom/state
mode_state_template: "{{ value_json.mode if value_json.power else 'off' }}"
mode_command_topic: midea2mqtt/livingroom/set
mode_command_template: >-
{% if value == 'off' %}{"power": false}{% else %}{"mode": "{{ value }}"}{% endif %}
# set point
temperature_state_topic: midea2mqtt/livingroom/state
temperature_state_template: "{{ value_json.targetTemperature }}"
temperature_command_topic: midea2mqtt/livingroom/set/targetTemperature
min_temp: 16
max_temp: 30
temp_step: 0.5
precision: 0.5
temperature_unit: C
# sensors
current_temperature_topic: midea2mqtt/livingroom/state
current_temperature_template: "{{ value_json.indoorTemperature }}"
current_humidity_topic: midea2mqtt/livingroom/state
current_humidity_template: "{{ value_json.indoorHumidity | default(none) }}"
# fan
fan_modes: ["auto", "silent", "low", "medium", "high", "full"]
fan_mode_state_topic: midea2mqtt/livingroom/state
fan_mode_state_template: "{{ value_json.fanSpeed }}"
fan_mode_command_topic: midea2mqtt/livingroom/set/fanSpeed
# swing
swing_modes: ["off", "vertical", "horizontal", "both"]
swing_mode_state_topic: midea2mqtt/livingroom/state
swing_mode_state_template: "{{ value_json.swing }}"
swing_mode_command_topic: midea2mqtt/livingroom/set/swing
# presets ("none" is added by Home Assistant itself and clears the preset)
preset_modes: ["eco", "comfort", "boost", "sleep", "away"]
preset_mode_state_topic: midea2mqtt/livingroom/state
preset_mode_value_template: "{{ value_json.preset }}"
preset_mode_command_topic: midea2mqtt/livingroom/set/presetHow it maps:
- Home Assistant's
offmode becomes{"power": false}. Selecting any other mode sends{"mode": ...}, which also switches the unit on. - The state template shows
offwheneverpoweris false, even though the unit keeps reporting its last mode. -
set/<key>topics take Home Assistant's plain payloads directly, so fan, swing, preset and temperature need no command template. - Remove
swing_modesentries your unit doesn't have (checkcapabilities), and dropcurrent_humidity_*if it doesn't report humidity.
If the unit reports energy:
mqtt:
sensor:
- name: "Living room AC power"
unique_id: midea2mqtt_livingroom_power
state_topic: midea2mqtt/livingroom/state
value_template: "{{ value_json.realtimePower | default(none) }}"
unit_of_measurement: W
device_class: power
state_class: measurement
availability:
- topic: midea2mqtt/bridge/status
- topic: midea2mqtt/livingroom/availability
availability_mode: all
- name: "Living room AC energy"
unique_id: midea2mqtt_livingroom_energy
state_topic: midea2mqtt/livingroom/state
value_template: "{{ value_json.totalEnergyConsumption | default(none) }}"
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
- name: "Living room outdoor temperature"
unique_id: midea2mqtt_livingroom_outdoor
state_topic: midea2mqtt/livingroom/state
value_template: "{{ value_json.outdoorTemperature | default(none) }}"
unit_of_measurement: "°C"
device_class: temperature
state_class: measurementThe energy sensor can go straight into the Energy dashboard.
Example for the display; the same pattern works for every boolean key (breezeless, outdoorSilent, sound, ...):
mqtt:
switch:
- name: "Living room AC display"
unique_id: midea2mqtt_livingroom_display
state_topic: midea2mqtt/livingroom/state
value_template: "{{ 'ON' if value_json.screenDisplay else 'OFF' }}"
command_topic: midea2mqtt/livingroom/set/screenDisplay
payload_on: "on"
payload_off: "off"
state_on: "ON"
state_off: "OFF"Any MQTT publish works, for example to switch off when a window opens:
action:
- action: mqtt.publish
data:
topic: midea2mqtt/livingroom/set
payload: '{"power": false}'midea2mqtt · LGPLv3 · Built on midea-ac · Not affiliated with Midea
Getting started
Using the bridge
More