Tuesday, 16 March 2021

Home Assistant control of Mitsubishi MCFZ-A24 WV A/C - Part 3

With the hardware built and Tasmota compiled the final piece is to link it up to Home Assistant. 




I am using the built-in MQTT broker and Tasmota is configured with the Home Assistant address. I've added a dedicated user name and password for Tasmota devices via the MQTT configuration.



Adding the climate control to Home Assistant is relatively easy, although it's not automatically discovered as it is with other ESP8266 firmware projects. To add the climate component manually edit the configuration.yaml file and add:
climate:
  - platform: mqtt
    current_temperature_topic: "tele/tasmota_xxx/SENSOR"
    current_temperature_template: "{{ value_json['BME280']['Temperature'] }}"
    temperature_unit: "C"
    name: Conservatory
    modes:
      - "off"
      - "cool"
      - "heat"
      - "dry"
    swing_modes:
      - "on"
      - "off"
    fan_modes:
      - "high"
      - "medium"
      - "low"
    min_temp: 16
    max_temp: 31
    initial: 18
    power_command_topic: "cmnd/conservatoryac"
    mode_command_topic: "cmnd/conservatoryac"
    temperature_command_topic: "cmnd/conservatoryac"
    fan_mode_command_topic: "cmnd/conservatoryac"
    swing_mode_command_topic: "cmnd/conservatoryac"
    precision: 1.0

The first section is relatively straightforward and configures the climate control with the available functions and where to get the temperature data. The second section was more difficult to work out because I had to try and associate the actions from the control with the IRhvac function of Tasmota. I try not to use custom controls where possible to avoid upgrade problems in the future. I initially struggled to find something that would work with the built-in Home Assistant functions but did get some inspiration from the Home Assistant forum.

What seems to work quite well is having the climate control publish to a temporary topic in MQTT and then using that to trigger an automation using automations.yaml. I need to finish off passing through the swing modes to IRhvav but I don't often use that setting.

- id: ac-control
  alias: AC Control
  trigger:
    platform: mqtt
    topic: cmnd/conservatoryac
  action: 
    - service: mqtt.publish
      data_template:
        topic: cmnd/tasmota_888715/IRhvac
        payload: >
          {% set pwr = 'on' if states.climate.conservatory.state != 'off' else 'off' %}
          {% set mitmode = 'cool' if states.climate.conservatory.state == 'off' else states.climate.conservatory.state %}
          {"Vendor":"MITSUBISHI112","Power":"{{pwr}}","Mode":"{{mitmode}}","FanSpeed":"{{state_attr('climate.conservatory', 'fan_mode')}}","Temp":{{state_attr('climate.conservatory', 'temperature')}},"SwingH":"Off","SwingV":"middle"}
  mode: single

Putting it all together, the card looks nice on the dashboard and is easy to use. Extra options are available from the ⁝ icon.

Pushing one of the icons on the climate controls results in a "beep" from the A/C and a log entry in the Tasmota cosole.


No comments:

Post a Comment

Heltec v3 and Wireless Tracker poor Bluetooth

The Heltec LoRa32 v3 and Wireless Tracker both seem to suffer from a limited Bluetooth range. In my experience unless you are in the same r...