Thermostat Card and MQTT numerical values for modes

Hi All,

Trying to figure this one out. I’m using MHI2MQTT to grab data from my aircons.
This is all coming in fine.

The problem lies with the thermostat card that is expecting words…when the payload values reported back by this program are numbers eg:

0 = Off
1 = Heat
2 = Cool
3 = Auto
4 = Dry
5= Fan
6 = On (Last state)

Same thing for Vanes where 5 = Swing

My configuration.yaml is currently like this (I haven’t changed the modes yet as I’m just starting to get an idea of what is going on here…presumably that may need to be changed)

Wonder if anyone is able to set me on the right path here… I did try having a search around but hard to know exactly what I want… I did come acruss value.templates but not sure if that is correct.

Thanks

mqtt:
  climate:
    unique_id: mhi-office
    name: mhi-office
    initial: 22
    min_temp: 18
    max_temp: 30
    modes:
      - "auto"
      - "dry"
      - "cool"
      - "fan_only"
      - "heat"
      - "off"
    swing_modes:
      - "1"
      - "2"
      - "3"
      - "4"
      - "Swing"
    fan_modes:
      - "1"
      - "2"
      - "3"
      - "4"
    mode_command_topic: "Office/Aircon/State"
    mode_state_topic: "Office/Aircon/statusState"
    temperature_command_topic: "Office/Aircon/Setpoint"
    temperature_state_topic: "Office/Aircon/statusSetpoint"
    fan_mode_command_topic: "Office/Aircon/Fanspeed"
    fan_mode_state_topic: "Office/Aircon/statusFanspeed"
    swing_mode_command_topic: "Office/Aircon/Vanes"
    swing_mode_state_topic: "Office/Aircon/statusVanes"
    current_temperature_topic: "Office/Aircon/statusRoomtemp"

I ended up figuring it out using the state_templates. Not sure if its the most effective way of doing it but for now it works as expected witht he MHI2MQTT addon, finally.

mqtt:
  climate:
    unique_id: mhi-office
    name: mhi-office
    initial: 22
    min_temp: 18
    max_temp: 30
    
    modes:
      - "auto"
      - "dry"
      - "cool"
      - "fan_only"
      - "heat"
      - "off"
    swing_modes:
      - "1"
      - "2"
      - "3"
      - "4"
      - "Swing"
    fan_modes:
      - "1"
      - "2"
      - "3"
      - "4"
    mode_command_topic: "Office/Aircon/State"
    mode_command_template: >-
      {% set values = { 'off':'0', 'heat':'1', 'cool':'2', 'auto':'3', 'dry':'4', 'fan_only':'5'} %}
      {{ values[value] | default('0') }}
    mode_state_topic: "Office/Aircon/statusState"
    mode_state_template: >-
      {% set values = { '0':'off', '1':'heat', '2':'cool', '3':'auto', '4':'dry', '5':'fan_only'} %}
      {{ values[value] | default('off') }}
    temperature_command_topic: "Office/Aircon/Setpoint"
    temperature_state_topic: "Office/Aircon/statusSetpoint"
    fan_mode_command_topic: "Office/Aircon/Fanspeed"
    fan_mode_state_topic: "Office/Aircon/statusFanspeed"
    swing_mode_command_topic: "Office/Aircon/Vanes"
    swing_mode_command_template: >-
      {% set values = { '1':'1', '2':'2', '3':'3', '4':'4', 'Swing':'5'} %}
      {{ values[value] | default('5') }}
    swing_mode_state_topic: "Office/Aircon/statusVanes"
    swing_mode_state_template: >-
      {% set values = { '1':'1', '2':'2', '3':'3', '4':'4', '5':'Swing'} %}
      {{ values[value] | default('Swing') }}
    current_temperature_topic: "Office/Aircon/statusRoomtemp"