MQTT HVAC Configuration for MHI-AC-CTRL (ESP8266)

Using MQTT HVAC to control my ACs at home, I managed to get them configured with some workaround previously posted (to make them work with slightly different commands that need to be published).

It’s currently running in optimistic for power and modes. The AC currently publishes to 2 seperate topics
/Mode and /Power
How can I combine these 2 and then feed it back into MQTT HVAC? I tried adding another Automation as such:

- alias: ACmode controller
  trigger:
    platform: mqtt
    topic: MHI-AC-Ctrl-GYGYAC/Mode
  trigger:
    platform:mqtt
    topic: MHI-AC-Ctrl-GYGYAC/Power
  action:
    service: mqtt.publish
    data_template:
      topic: MHI-AC-Ctrl-GYGYAC/Mode/HVAC
      payload: >
        {% set values = { "Auto":"auto", "Fan":"fan_only", "Cool":"cool", "Dry":"dry", "Off","off"} %}
        {{ values[trigger.payload] if trigger.payload in values.keys() else "Auto" }}

The logic is not quite right, as I’m thinking I’m triggering on anything that’s changing. How do I make it such that it only publishes a payload when /Power is “On” and at the same time ‘convert’ the values to something that MQTT HVAC expects.

This would hopefully solve another side issue that I have, which is that I still sometimes run the ACs with their remotes (horrors). /Power will update accordingly, however I’d still need to feed that into MQTT HVAC so I don’t have to say toggle it on and then off as it’s in an unknown state.

You can only have one trigger block in each automation, so for multiple triggers list them like this:

- alias: ACmode controller
  trigger:
    - platform: mqtt
      topic: MHI-AC-Ctrl-GYGYAC/Mode
    - platform: mqtt
      topic: MHI-AC-Ctrl-GYGYAC/Power
  action:
...

Also you are missing a space in your second platform:

    platform:mqtt

I have not debugged your action payload.

Ah, got the 2 points you raised. I’m fairly concerned with the logic that needs to go into the action payload though.

/Mode can be “Auto”, “Dry”, “Cool”, “Fan”
/Power is either “On” or “Off”

MQTT HVAC expects “off”, “auto”, “cool”, “fan_only”, “dry”.

There’s a convert to lower case filter so:

  action:
    service: mqtt.publish
    data_template:
      topic: MHI-AC-Ctrl-GYGYAC/Mode/HVAC
      payload: >
       {% if trigger.payload == 'On' %}
         auto
       {% elif trigger.payload == 'Fan' %}
         fan_only
       {% else %}
         {{ trigger.payload |lower }}
       {% endif %}

Let me give that a try

Edit: it does work, thank you very much. Have flagged it as the solution.

Just to be clear it’s

- alias: GYACmode_power controller
  trigger:
    - platform: mqtt
      topic: MHI-AC-Ctrl-MBMBAC/Mode
    - platform: mqtt
      topic: MHI-AC-Ctrl-MBMBAC/Power
  action:
    service: mqtt.publish
    data_template:
      topic: MHI-AC-Ctrl-MBMBAC/Mode/HVAC
      payload: >
       {% if trigger.payload == 'On' %}
         auto
       {% elif trigger.payload == 'Fan' %}
         fan_only
       {% else %}
         {{ trigger.payload |lower }}
       {% endif %}
        
1 Like