Add missing _template variables for mqtt climate components

I like the fact that I can register mqtt climate components in HA (in my case fibaro heat controllers that are connected to a separate zwave2mqtt docker container), but right now the component available is only usable as a read-only component in case the supported modes of your device does’t conform to the default modes that HA offers:

[“auto”, “off”, “cool”, “heat”, “dry”, “fan_only”]

There is a cool feature to create a template for mapping actual modes to these modes in HA via the mode_state_template configuration variable which gives HA the possibility to show the correct state of your component but right now, the mqtt climate component is not smart enough to ‘reverse’ this template for the use of the ‘mode_command_topic’. There also isn’t a mode_command_template configuration variable present and I believe this is a big miss! Any chance that this can be added/fixed?

In the below linked community page there are mentions of the following missing template variables:

  1. mode_command_template
    Convert mode with a template for publishing to MQTT
  2. fan_mode_command_template
    Convert fan_mode with a template for publishing to MQTT
  3. hold_command_template
    Convert hold with a template for publishing to MQTT

source: Enhanced version of MQTT HVAC (Climate platform) with proper History Chart

About how many votes does something like this need before it works? There was previous a previous climate replacement that has now been abandoned that supported this. Using that as a starting point seems like a fairly low effort way to significantly improve the ability to use the climate control.

There’s no threshold for when a Feature Request is implemented. Anything posted here serves as a ‘wish’ that you hope may be granted by a volunteer developer. The timing of when the wish is granted (if ever) depends on if it piques someone’s interest to implement it.

I abandoned maintaining a custom version of MQTT HVAC because the important bits were added to the standard version during the “Climate 1.0” re-design (many versions ago). I use simple workarounds to handle the extra options that were not included.

For the three command topics that do not support templates, I simply publish them to “middleman” topics. For example, my thermostat is not subscribed to any of these topics:

    mode_command_topic: "temp/climate/hvac_mode"
    fan_mode_command_topic: "temp/climate/fan_mode"
    hold_command_topic: "temp/climate/hold_mode"

However, I have three automations and each one is subscribed to one of the “middleman” topics. When it receives a payload, it converts it into the format my thermostat requires and then it publishes it to the thermostat’s topic.

- alias: 'Convert hvac_mode'
  description: 'Convert HVAC mode to Premise'
  initial_state: true
  trigger:
    platform: mqtt
    topic: temp/climate/hvac_mode
  action:
    service: mqtt.publish
    data_template:
      topic: premise/command/home/thermostat/temperaturemode
      payload: >
        {% set values = { 'auto':'0', 'heat':'1',  'cool':'2',  'off':'4'} %}
        {{ values[trigger.payload] if trigger.payload in values.keys() else '4' }}


- alias: 'Convert fan_mode'
  description: 'Convert fan mode to Premise'
  initial_state: true
  trigger:
    platform: mqtt
    topic: temp/climate/fan_mode
  action:
    service: mqtt.publish
    data_template:
      topic: premise/command/home/thermostat/fancontrol
      payload: >
        {% set values = { 'auto':'0', 'on':'1'} %}
        {{ values[trigger.payload] if trigger.payload in values.keys() else '0' }}


- alias: 'Convert hold_mode'
  description: 'Convert hold mode to Premise'
  initial_state: true
  trigger:
    platform: mqtt
    topic: temp/climate/hold_mode
  action:
  - service: mqtt.publish
    data_template:
      topic: premise/command/home/thermostat/mode
      payload: "{{ '2' if trigger.payload == 'Hold' else '0' }}"

Yep, I too implemented a middleman automation. It’s a reasonable work around, but it does add some complexity to the environment. Thanks for the clarification.